feat(segmented-control): introduce segmented control #1094
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
feat(segmented-control): introduce
bl-segmented-controlAs discussed in the previous PR, I extended the suggested
bl-togglecomponent from #1089 into a new more functional and distinct component.This PR is related to #1092.
Summary
This PR adds a new Segmented Control component (
<bl-segmented-control) to the Baklava Design System. It supports RTL out-of-the-box, multiple sizes, inverted styling, and customization via CSS properties. The PR also includes documentation (Storybook stories) and unit tests with 100% coverage for the new logic.Motivation and Context
The segmented control provides more distinct visual change of context compared to similar-functinality components (e.g. radio group) where switching between binary context is not enough. It is a linear control which has a set of
2 ≤options, each functioning as a button or a value provider.What’s Included
src/components/segmented-controllabel-false,label-truetext labelsicon-false,icon-trueicon namesdisabled,inverted,size(small | medium | large),icons-onlybl-segmented-control-change(detail: Emitted when the value changes. Event detail is the selected value. )role="radiogroup",aria-disableddisabledsetDirectionPropertyutility and logical label placement based on direction--bl-segment-bg--bl-segment-color--bl-segment-selected-bg--bl-segment-selected-color--bl-segment-widthsrc/components/segmented-control/bl-segmented-control.csssrc/components/segmented-control/bl-segmented-control.stories.mdxsrc/components/segmented-control/bl-segmented-control.test.tsAccessibility Details (A11y)
role="radiogroup"witharia-checkedis kept in sync with the checked state.aria-disabledis applied when disabled;tabIndexbecomes-1to remove from tab order.aria-labelfor assistive technologies.RTL Support
setDirectionPropertyutility and logical placement so that:dir="rtl"to verify layout and behavior.Documentation
bl-segmented-control.aria-label) and no indeterminate state.Checklist (per CONTRIBUTING.md)
npm run lint)npm test), new tests added for all logic pathsdir="rtl"example and logical placementAdditional Notes