Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: update slider with range variant #3789

Merged
merged 30 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
e6208b2
update usage.mdx
laurenmrice Oct 30, 2023
0ddc638
Merge branch 'main' into range-slider-docs
laurenmrice Oct 30, 2023
2040e66
update style.mdx
laurenmrice Oct 31, 2023
0e53f8c
Merge branch 'range-slider-docs' of https://github.com/laurenmrice/ca…
laurenmrice Oct 31, 2023
fe09ea3
remove unused images
laurenmrice Oct 31, 2023
d7d3f71
update usage.mdx
laurenmrice Nov 8, 2023
278ed0c
Merge branch 'main' into range-slider-docs
laurenmrice Nov 8, 2023
24bc8d1
update style.mdx
laurenmrice Nov 8, 2023
c9e0a7a
Merge branch 'range-slider-docs' of https://github.com/laurenmrice/ca…
laurenmrice Nov 8, 2023
970c139
update images
laurenmrice Nov 8, 2023
55e0bad
fix image
laurenmrice Nov 8, 2023
ddb03de
update style.mdx
laurenmrice Nov 13, 2023
c55c558
update usage.mdx
laurenmrice Nov 13, 2023
a6502da
new images
laurenmrice Nov 13, 2023
4f3644c
update a11y.mdx
laurenmrice Nov 13, 2023
6e8cadc
fix bugs
laurenmrice Nov 13, 2023
f2cd721
update style.mdx
laurenmrice Nov 13, 2023
53d097f
feat: add live demo range slider variant
andreancardona Nov 15, 2023
e807c57
Merge branch 'main' into range-slider-docs
andreancardona Nov 15, 2023
9f8fd02
update mp4 content
laurenmrice Nov 20, 2023
3841571
chore: format
laurenmrice Nov 20, 2023
528dd57
Merge branch 'main' into range-slider-docs
laurenmrice Nov 20, 2023
5160781
chore: format
andreancardona Nov 20, 2023
b85457e
chore: update yarn
andreancardona Nov 20, 2023
442d381
chore: replace yarn lockfile with main
alisonjoseph Nov 20, 2023
78e7da0
chore: update yarn version
alisonjoseph Nov 20, 2023
1ae2496
chore: fix yarn
alisonjoseph Nov 20, 2023
7d41e82
chore: fix ci
alisonjoseph Nov 20, 2023
ffb3011
update mp4 covers
laurenmrice Nov 21, 2023
3cd21f6
Merge branch 'range-slider-docs' of https://github.com/laurenmrice/ca…
laurenmrice Nov 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 72 additions & 10 deletions src/pages/components/slider/accessibility.mdx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
---
title: Slider
description:
Sliders provide a visual indication of adjustable content, where the user can
move the handle along a horizontal track to increase or decrease the value.
No accessibility annotations are needed for sliders, but keep these
considerations in mind if you are modifying Carbon or creating a custom
component.
tabs: ['Usage', 'Style', 'Code', 'Accessibility']
---

Expand All @@ -28,11 +29,12 @@ Carbon bakes keyboard operation into its components, improving the experience of
blind users and others who operate via the keyboard. Carbon incorporates many
other accessibility considerations, some of which are described below.

### Keyboard interactions
### Keyboard interactions (default slider)

Tab order goes from slider to text input. Arrow keys are used to change the
slider value. `Shift`+arrow changes the slider value by a larger increment (such
as by 10 instead of 1). Users can also directly enter a value in the input.
Tab order goes from slider to number input. Arrow keys are used to change the
slider value. `Shift` + `Arrow` changes the slider value by a larger increment
(such as by 10 instead of 1). Users can also directly enter a value in the
input.

<Row>
<Column colLg={8}>
Expand All @@ -46,16 +48,16 @@ as by 10 instead of 1). Users can also directly enter a value in the input.
</Column>
</Row>

### Labeling and updates
### Labeling and updates (default slider)

<Row>
<Column colLg={8}>

![slider label is connected to slider control and text input](images/slider-accessibility-2.png)
![slider label is connected to slider control and number input](images/slider-accessibility-2.png)

<Caption>
The slider label is programmatically associated with both the slider and
input.
The input value and slider position are in sync. An update to either causes
the other to update.
</Caption>

</Column>
Expand All @@ -70,6 +72,43 @@ as by 10 instead of 1). Users can also directly enter a value in the input.
aria-label="pointer clicks on slider range and input updates to 80. input value changes to 75 and slider repositions to match"
/>

<Caption>
The multiple ways of updating a value within the default slider component.
</Caption>

</Column>
</Row>

### Keyboard interactions (range slider)

For the range slider, tab order goes from the first number input, to the two
handles in turn, and then to the second number input. The handle keyboard
operation is the same as with the default slider. Users can also directly enter
numbers into the minimum and maximum value inputs.

<Row>
<Column colLg={8}>

![Both the slider and inputs are in the tab order and keyboard operable.](images/slider-accessibility-4.png)

<Caption>
Both the slider and inputs are in the tab order and keyboard operable.
</Caption>

</Column>
</Row>

### Labeling and updates (range slider)

The slider label is a description what kind of values will be selected from the
range slider. The minimum and maximum values are labeled with placeholder text
of min and max due to space constraints.

<Row>
<Column colLg={8}>

![The input value and slider position are in sync. An update to either causes the other to update.](images/slider-accessibility-5.png)

<Caption>
The input value and slider position are in sync. An update to either causes
the other to update.
Expand All @@ -78,6 +117,18 @@ as by 10 instead of 1). Users can also directly enter a value in the input.
</Column>
</Row>

<Row>
<Column colLg={8}>

![The multiple ways of updating a value within the range slider component.](images/slider-accessibility-6.png)

<Caption>
The multiple ways of updating a value within the range slider component.
</Caption>

</Column>
</Row>

## Development considerations

Keep these considerations in mind if you are modifying Carbon or creating a
Expand All @@ -91,3 +142,14 @@ custom component:
- See the
[ARIA authoring practices](https://www.w3.org/TR/wai-aria-practices-1.2/#slider)
for more considerations.

### Error handling

If an inputted value is outside the allowed range, the slider will auto-correct
to the nearest allowed digit. When the inputted value results in an error, the
error will display alongside the corresponding text input.

In the range slider, if the inputted value is not logically correct (for
example, if a minimum value is greater than the maximum value), a warning
message will be generated that informs the user that a value was autocorrected
to the nearest allowed digit.
4 changes: 4 additions & 0 deletions src/pages/components/slider/code.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,9 @@ documentation, see the Storybooks for each framework below.
label: 'Controlled Slider',
variant: 'components-slider--controlled-slider',
},
{
label: 'Range Slider',
variant: 'components-slider--two-handle-slider',
},
]}
/>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/pages/components/slider/images/slider-accessibility-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Diff not rendered.
Diff not rendered.
Diff not rendered.
145 changes: 118 additions & 27 deletions src/pages/components/slider/style.mdx
Original file line number Diff line number Diff line change
@@ -1,16 +1,33 @@
---
title: Slider
description:
Sliders provide a visual indication of adjustable content, where the user can
move the handle along a horizontal track to increase or decrease the value.
The following page documents visual specifications such as color, typography,
structure, and size.
tabs: ['Usage', 'Style', 'Code', 'Accessibility']
---

<PageDescription>

The following page documents visual specifications such as color, typography,
structure, and size.

</PageDescription>

<AnchorLinks>

<AnchorLink>Color</AnchorLink>
<AnchorLink>Typography</AnchorLink>
<AnchorLink>Structure</AnchorLink>
<AnchorLink>Size</AnchorLink>
<AnchorLink>Feedback</AnchorLink>

</AnchorLinks>

## Color

| Element | Property | Color token |
| ------------- | ---------------- | ------------------- |
| Thumb | fill | `$icon-primary` |
| Handle | fill | `$icon-primary` |
| Track | background-color | `$border-subtle` \* |
| Track: filled | background-color | `$border-inverse` |
| Label | text-color | `$text-secondary` |
Expand All @@ -24,36 +41,50 @@ tabs: ['Usage', 'Style', 'Code', 'Accessibility']
<Row>
<Column colLg={8}>

![Slider enabled state](images/slider-style-color.png)
<Tabs>

<Tab label="Default">

![Default slider color enabled state](images/color-default-slider.png)

</Tab>

<Tab label="Range">

![Range slider color enabled state](images/color-range-slider.png)

</Tab>

</Tabs>

</Column>
</Row>

### Interactive states

Slider uses a text input to type in values. See
[text input](https://carbondesignsystem.com/components/text-input/usage/#states)
for more information on its interactive states.
Slider uses a number input to type in values. See
[number input](https://carbondesignsystem.com/components/number-input/style) for
more information on its interactive states.

| State | Element | Property | Color token |
| --------- | --------------- | ---------------- | ------------------- |
| Focus | Thumb | border | `$focus` |
| Focus | Handle | border | `$focus` |
| | Track | background-color | `$interactive` |
| Active | Thumb | fill | `$interactive` |
| Active | Handle | fill | `$interactive` |
| | Track | background-color | `$interactive` |
| Error | Text input | border | `$support-error` |
| Error | Number input | border | `$support-error` |
| | Error icon | svg | `$support-error` |
| | Error message | text-color | `$text-error` |
| Warning | Warning icon | svg | `$support-warning` |
| | Warning message | text-color | `$text-primary` |
| Disabled | Label | text-color | `$text-disabled` |
| | Range label | text-color | `$text-disabled` |
| | Thumb | fill | `$border-disabled` |
| | Handle | fill | `$border-disabled` |
| | Track | background-color | `$border-disabled` |
| Read-only | Label | text-color | `$text-secondary` |
| | Range label | text-color | `$text-primary` |
| | Track | background-color | `$border-subtle` \* |
| | Track:filled | background-color | `$border-inverse` |
| | Track: filled | background-color | `$border-inverse` |

<Caption>
* Denotes a contextual color token that will change values based on the layer
Expand All @@ -63,7 +94,21 @@ for more information on its interactive states.
<Row>
<Column colLg={12}>

![Slider interactive states](images/slider-style-states.png)
<Tabs>

<Tab label="Default">

![Default slider interactive states](images/slider-default-style-states.png)

</Tab>

<Tab label="Range">

![Range slider interactive states](images/slider-range-style-states.png)

</Tab>

</Tabs>

</Column>
</Row>
Expand All @@ -82,31 +127,71 @@ phrase and any proper nouns capitalized, and no more than three words.

The width of a slider varies based on page content and layout.

| Element | Property | px / rem | Spacing token |
| ------------- | --------------------------- | ---------- | ------------- |
| Thumb | height, width | 14 / 0.875 | – |
| Thumb:active | height, width | 20 / 1.25 | – |
| Thumb:active | height, width | 20 / 1.25 | – |
| Track | height | 4 / 0.25 | – |
| | margin-left, margin-right | 8 / 0.5 | `$spacing-03` |
| Label | margin-bottom | 8 / 0.5 | `$spacing-03` |
| Range label | margin-right | 16 / 1 | `$spacing-05` |
| Error message | margin-top | 16 / 1 | `$spacing-05` |
| State icon | padding-right, padding-left | 16 / 1 | `$spacing-05` |
### Default slider structure

| Element | Property | px / rem | Spacing token |
| -------------- | --------------------------- | ---------- | ------------- |
| Handle | height, width | 14 / 0.875 | – |
| Handle: active | height, width | 20 / 1.25 | – |
| Track | height | 4 / 0.25 | – |
| | margin-left, margin-right | 8 / 0.5 | `$spacing-03` |
| Label | margin-bottom | 8 / 0.5 | `$spacing-03` |
| Range label | margin-right | 16 / 1 | `$spacing-05` |
| Error message | margin-top | 16 / 1 | `$spacing-05` |
| Error icon | padding-right, padding-left | 16 / 1 | `$spacing-05` |
| Tooltip | padding-bottom | 4 / 0.25 | `$spacing-02` |

<div className="image--fixed">

![Structure and spacing measurements for slider enabled state](images/slider-style-spec-enabled.png)
![Structure and spacing measurements for default slider enabled state](images/slider-style-structure-default-enabled.png)

</div>

<div className="image--fixed">

![Structure and spacing measurements for slider error state](images/slider-style-spec-error.png)
![Structure and spacing measurements for default slider error state](images/slider-style-structure-default-error.png)

</div>

### Recommended
<div className="image--fixed">

![Structure and spacing measurements for default sliders with tooltips and no number inputs](images/slider-style-structure-default-tooltip.png)

</div>

### Range slider structure

| Element | Property | px / rem | Spacing token |
| -------------- | --------------------------- | -------- | ------------- |
| Handle | height, width | 16 / 1 | `$spacing-05` |
| Handle: active | height, width | 16 / 1 | `$spacing-05` |
| Track | height | 4 / 0.25 | – |
| | margin-left, margin-right | 16 / 1 | `$spacing-05` |
| Label | margin-bottom | 8 / 0.5 | `$spacing-03` |
| Range label | margin-right | 16 / 1 | `$spacing-05` |
| Error message | margin-top | 16 / 1 | `$spacing-05` |
| Error icon | padding-right, padding-left | 16 / 1 | `$spacing-05` |
| Tooltip | padding-bottom | 0 | – |

<div className="image--fixed">

![Structure and spacing measurements for range slider enabled state](images/slider-style-structure-default-enabled.png)

</div>

<div className="image--fixed">

![Structure and spacing measurements for range slider error state](images/slider-style-structure-default-error.png)

</div>

<div className="image--fixed">

![Structure and spacing measurements forrange sliders with tooltips and no number inputs](images/slider-style-structure-range-tooltip.png)

</div>

## Size

The following specs are not built into the slider component but are recommended
by design as the proper sizing for the slider tracking line.
Expand All @@ -115,3 +200,9 @@ by design as the proper sizing for the slider tracking line.
| ------- | --------- | ---------- | ------------- |
| Slider | min-width | 200 / 12.5 | – |
| | max-width | 640 / 40 | – |

## Feedback

Help us improve this component by providing feedback, asking questions, and
leaving any other comments on
[GitHub](https://github.com/carbon-design-system/carbon-website/issues/new?assignees=&labels=feedback&template=feedback.md).
Loading
Loading