-
Notifications
You must be signed in to change notification settings - Fork 236
docs(color-slider): enhance README with detailed sections #5728
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d12ad8c
docs(color-slider): enhance README with detailed sections
blunteshwar 6416156
docs(color-slider): add keyboard shortcuts for hue adjustments in README
blunteshwar f677eb5
Merge branch 'main' into SWC-370
blunteshwar f2bc09d
docs(color-slider): enhance README with accessible labels for color s…
blunteshwar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| ## Description | ||
| ## Overview | ||
|
|
||
| An `<sp-color-slider>` lets users visually change an individual channel of a color. The background of the `<sp-color-slider>` is a visual representation of the range of values a user can select from. This can represent color properties such as hues, color channel values (such as RGB or CMYK levels), or opacity. Currently, the slider only supports leveraging the `hue` property. | ||
|
|
||
|
|
@@ -8,51 +8,120 @@ An `<sp-color-slider>` lets users visually change an individual channel of a col | |
| [](https://bundlephobia.com/result?p=@spectrum-web-components/color-slider) | ||
| [](https://stackblitz.com/edit/vitejs-vite-enye2vau) | ||
|
|
||
| ``` | ||
| ```bash | ||
| yarn add @spectrum-web-components/color-slider | ||
| ``` | ||
|
|
||
| Import the side effectful registration of `<sp-color-slider>` via: | ||
|
|
||
| ``` | ||
| ```javascript | ||
| import '@spectrum-web-components/color-slider/sp-color-slider.js'; | ||
| ``` | ||
|
|
||
| When looking to leverage the `ColorSlider` base class as a type and/or for extension purposes, do so via: | ||
|
|
||
| ``` | ||
| ```javascript | ||
| import { ColorSlider } from '@spectrum-web-components/color-slider'; | ||
| ``` | ||
|
|
||
| ## Color Formatting | ||
| ### Anatomy | ||
|
|
||
| When using the color elements, use `el.color` to access the `color` property, which should manage itself in the colour format supplied. If you supply a color in `rgb()` format, `el.color` should return the color in `rgb()` format, as well. | ||
| The color slider consists of several key parts: | ||
|
|
||
| The current color formats supported are as follows: | ||
| - A gradient track showing the range of color values | ||
| - A draggable handle that indicates the current color position | ||
| - An accessible label for screen readers | ||
rise-erpelding marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - Hex3, Hex4, Hex6, Hex8 | ||
| - HSV, HSVA | ||
| - HSL, HSLA | ||
| - RGB, RGBA | ||
| - Strings (eg "red", "blue") | ||
| ```html | ||
| <sp-color-slider></sp-color-slider> | ||
| ``` | ||
|
|
||
| **Please note for the following formats: HSV, HSVA, HSL, HSLA** | ||
| When using the HSL or HSV formats, and a color's value (in HSV) is set to 0, or its luminosity (in HSL) is set to 0 or 1, the hue and saturation values may not be preserved by the element's `color` property. This is detailed in the [colorjs documentation](https://colorjs.io/docs/). Seperately, the element's `value` property is directly managed by the hue as represented in the interface. | ||
| ### Options | ||
|
|
||
| ## Default | ||
| #### Orientation | ||
|
|
||
| By default, the color slider is displayed horizontally. You can change the orientation to vertical using the `vertical` attribute: | ||
|
|
||
| ```html | ||
| <sp-color-slider></sp-color-slider> | ||
| <sp-color-slider vertical></sp-color-slider> | ||
| ``` | ||
|
|
||
| ### Vertical | ||
| ### States | ||
|
|
||
| #### Standard | ||
|
|
||
| The standard color slider allows users to select hue values from 0 to 360 degrees: | ||
|
|
||
| ```html | ||
| <sp-color-slider vertical></sp-color-slider> | ||
| <sp-color-slider></sp-color-slider> | ||
| ``` | ||
|
|
||
| ### Disabled | ||
| #### Disabled | ||
|
|
||
| A color slider in a disabled state shows that an input exists, but is not available in that circumstance. This can be used to maintain layout continuity and communicate that the slider may become available later. | ||
|
|
||
| ```html | ||
| <sp-color-slider disabled></sp-color-slider> | ||
| ``` | ||
|
|
||
| ### Behaviors | ||
|
|
||
| #### Color Formatting | ||
|
|
||
| When using the color elements, use `el.color` to access the `color` property, which should manage itself in the colour format supplied. If you supply a color in `rgb()` format, `el.color` should return the color in `rgb()` format, as well. | ||
|
|
||
| The current color formats supported are as follows: | ||
|
|
||
| - Hex3, Hex4, Hex6, Hex8 | ||
| - HSV, HSVA | ||
| - HSL, HSLA | ||
| - RGB, RGBA | ||
| - Strings (eg "red", "blue") | ||
|
|
||
| For a complete list of supported color formats, see the [ColorController documentation](/tools/color-controller#supported-color-formats). | ||
|
|
||
| **Please note for the following formats: HSV, HSVA, HSL, HSLA** | ||
| When using the HSL or HSV formats, and a color's value (in HSV) is set to 0, or its luminosity (in HSL) is set to 0 or 1, the hue and saturation values may not be preserved by the element's `color` property. This is detailed in the [colorjs documentation](https://colorjs.io/docs/). Seperately, the element's `value` property is directly managed by the hue as represented in the interface. | ||
rise-erpelding marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ### Accessibility | ||
|
|
||
| The `<sp-color-slider>` is rendered with appropriate ARIA attributes to ensure accessibility: | ||
|
|
||
| - Uses native `input[type="range"]` element with implicit "slider" role | ||
| - Provides value text announcements for screen readers | ||
| - Supports full keyboard navigation | ||
|
|
||
| #### Keyboard Navigation | ||
|
|
||
|
Comment on lines
+116
to
+117
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we wanna talk about shift+arrow keys here or not?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure! |
||
| <sp-table> | ||
| <sp-table-head> | ||
| <sp-table-head-cell>Key</sp-table-head-cell> | ||
| <sp-table-head-cell>Action</sp-table-head-cell> | ||
| </sp-table-head> | ||
| <sp-table-body> | ||
| <sp-table-row> | ||
| <sp-table-cell><kbd>Arrow Left</kbd>/<kbd>Arrow Down</kbd></sp-table-cell> | ||
| <sp-table-cell>Decreases the hue value</sp-table-cell> | ||
| </sp-table-row> | ||
| <sp-table-row> | ||
| <sp-table-cell><kbd>Arrow Right</kbd>/<kbd>Arrow Up</kbd></sp-table-cell> | ||
| <sp-table-cell>Increases the hue value</sp-table-cell> | ||
| </sp-table-row> | ||
| <sp-table-row> | ||
| <sp-table-cell><kbd>Page Down</kbd></sp-table-cell> | ||
| <sp-table-cell>Decreases the hue value by a larger step</sp-table-cell> | ||
rise-erpelding marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| </sp-table-row> | ||
| <sp-table-row> | ||
| <sp-table-cell><kbd>Page Up</kbd></sp-table-cell> | ||
| <sp-table-cell>Increases the hue value by a larger step</sp-table-cell> | ||
| </sp-table-row> | ||
| <sp-table-row> | ||
| <sp-table-cell><kbd>Home</kbd></sp-table-cell> | ||
| <sp-table-cell>Sets the hue to minimum value (0)</sp-table-cell> | ||
| </sp-table-row> | ||
| <sp-table-row> | ||
| <sp-table-cell><kbd>End</kbd></sp-table-cell> | ||
| <sp-table-cell>Sets the hue to maximum value (360)</sp-table-cell> | ||
| </sp-table-row> | ||
| </sp-table-body> | ||
| </sp-table> | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use
jsfor consistency?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For every color-component we have used javascript only
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and everywhere else we've used js. i dont know what is better tbh was just curious lol