-
Notifications
You must be signed in to change notification settings - Fork 231
docs(color-handle): enhance README with detailed component overview #5663
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
Conversation
…nd usage examples
|
📚 Branch Preview🔍 Visual Regression Test ResultsWhen a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:
Deployed to Azure Blob Storage: If the changes are expected, update the |
Tachometer resultsCurrently, no packages are changed by this PR... |
packages/color-handle/README.md
Outdated
|
||
#### Keyboard Support | ||
|
||
While the color handle itself is not directly keyboard accessible, it works in conjunction with its parent components (`<sp-color-area>`, `<sp-color-slider>`, `<sp-color-wheel>`) which provide comprehensive keyboard navigation. |
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 add a small example to surface this usage to our customers?
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.
Done!
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.
instead of an example here bringing in another component, I would like to suggest that we link to the other components docs to see it in use
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.
Done!
packages/color-handle/README.md
Outdated
<sp-table> | ||
<sp-table-head> | ||
<sp-table-head-cell>Format</sp-table-head-cell> | ||
<sp-table-head-cell>Example Values</sp-table-head-cell> | ||
<sp-table-head-cell>Description</sp-table-head-cell> | ||
</sp-table-head> | ||
<sp-table-body> | ||
<sp-table-row> | ||
<sp-table-cell>Hex3</sp-table-cell> | ||
<sp-table-cell><code>#f00</code>, <code>#0a5</code></sp-table-cell> | ||
<sp-table-cell>3-digit hexadecimal</sp-table-cell> | ||
</sp-table-row> | ||
<sp-table-row> | ||
<sp-table-cell>Hex4</sp-table-cell> | ||
<sp-table-cell><code>#f00f</code>, <code>#0a58</code></sp-table-cell> | ||
<sp-table-cell>3-digit hexadecimal + alpha</sp-table-cell> | ||
</sp-table-row> | ||
<sp-table-row> | ||
<sp-table-cell>Hex6</sp-table-cell> | ||
<sp-table-cell><code>#ff0000</code>, <code>#00aa55</code></sp-table-cell> | ||
<sp-table-cell>6-digit hexadecimal</sp-table-cell> | ||
</sp-table-row> | ||
<sp-table-row> | ||
<sp-table-cell>Hex8</sp-table-cell> | ||
<sp-table-cell><code>#ff0000ff</code>, <code>#00aa5580</code></sp-table-cell> | ||
<sp-table-cell>6-digit hexadecimal + alpha</sp-table-cell> | ||
</sp-table-row> | ||
<sp-table-row> | ||
<sp-table-cell>RGB</sp-table-cell> | ||
<sp-table-cell><code>rgb(255, 0, 0)</code>, <code>rgb(0, 170, 85)</code></sp-table-cell> | ||
<sp-table-cell>Red, Green, Blue values (0-255)</sp-table-cell> | ||
</sp-table-row> | ||
<sp-table-row> | ||
<sp-table-cell>RGBA</sp-table-cell> | ||
<sp-table-cell><code>rgba(255, 0, 0, 1)</code>, <code>rgba(0, 170, 85, 0.5)</code></sp-table-cell> | ||
<sp-table-cell>RGB + Alpha channel (0-1)</sp-table-cell> | ||
</sp-table-row> | ||
<sp-table-row> | ||
<sp-table-cell>HSL</sp-table-cell> | ||
<sp-table-cell><code>hsl(0, 100%, 50%)</code>, <code>hsl(150, 100%, 33%)</code></sp-table-cell> | ||
<sp-table-cell>Hue (0-360°), Saturation, Lightness</sp-table-cell> | ||
</sp-table-row> | ||
<sp-table-row> | ||
<sp-table-cell>HSLA</sp-table-cell> | ||
<sp-table-cell><code>hsla(0, 100%, 50%, 1)</code>, <code>hsla(150, 100%, 33%, 0.5)</code></sp-table-cell> | ||
<sp-table-cell>HSL + Alpha channel (0-1)</sp-table-cell> | ||
</sp-table-row> | ||
<sp-table-row> | ||
<sp-table-cell>HSV</sp-table-cell> | ||
<sp-table-cell><code>hsv(0, 100%, 100%)</code>, <code>hsv(150, 100%, 67%)</code></sp-table-cell> | ||
<sp-table-cell>Hue (0-360°), Saturation, Value</sp-table-cell> | ||
</sp-table-row> | ||
<sp-table-row> | ||
<sp-table-cell>HSVA</sp-table-cell> | ||
<sp-table-cell><code>hsva(0, 100%, 100%, 1)</code>, <code>hsva(150, 100%, 67%, 0.5)</code></sp-table-cell> | ||
<sp-table-cell>HSV + Alpha channel (0-1)</sp-table-cell> | ||
</sp-table-row> | ||
<sp-table-row> | ||
<sp-table-cell>Named Colors</sp-table-cell> | ||
<sp-table-cell><code>red</code>, <code>rebeccapurple</code>, <code>darkseagreen</code></sp-table-cell> | ||
<sp-table-cell>CSS color keywords (<a href="https://developer.mozilla.org/en-US/docs/Web/CSS/named-color">full list</a>)</sp-table-cell> | ||
</sp-table-row> | ||
</sp-table-body> | ||
</sp-table> |
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.
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.
Done!
packages/color-handle/README.md
Outdated
|
||
The `<sp-color-handle>` is used to select a colour on an `<sp-color-area>`, `<sp-color-slider>`, or `<sp-color-wheel>`. It functions similarly to the handle on an `<sp-slider>`. | ||
The `<sp-color-handle>` is used to select a color on an `<sp-color-area>`, `<sp-color-slider>`, or `<sp-color-wheel>`. It functions similarly to the handle on an `<sp-slider>`, providing a draggable control point for precise color selection within color components. |
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 highlight the functional difference between the color-handle and the handle in sp-slider? If there is no difference, I would remove the reference to sp-slider, as that causes confusion.
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.
Should we highlight that this is an atomic level component or maybe discuss the language we would like to use for internal/dumb components?
cc @nikkimk
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.
Done!
I added a note
**Note**:
is a primitive component designed to be used within other color selection components. It's not typically used directly in applications, but rather as part of higher-level color components like
,
, or
.
|
||
### States | ||
|
||
#### Standard |
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.
I dont think this is necessary...? @nikkimk are we showing default states in all components?
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.
I include the default if I used tabs for a visual comparison, and typically for variants more than states, but it's not necessarily a hill to die on for me.
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.
I think adding a default let the users compare what is the difference b/w default and other states
The color handle can receive keyboard focus when used within interactive color components. The focused state is managed automatically by the parent component and is indicated visually: | ||
|
||
```html | ||
<sp-color-handle focused></sp-color-handle> |
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.
since this is handled in the parent, should this example show more of the implementation pattern versus the output in the DOM?
cc @nikkimk
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.
I think it's good to include to show what focused state looks like and how it works within the component.
#### Touch Accessibility | ||
|
||
- **Color Loupe**: Automatically appears for touch input to ensure the selected color remains visible | ||
- **Large Touch Target**: The handle provides an appropriately sized touch target for mobile interaction |
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.
What is the size of the touch target?
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.
The size of sp-color-loupe
packages/color-handle/README.md
Outdated
<sp-color-handle></sp-color-handle> | ||
``` | ||
|
||
**Internal Structure**: The component renders an inner div with the background color and an `<sp-color-loupe>` element that appears when the `open` property is true and the component is not disabled. |
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.
this call out can be removed with the suggestion above, just added these details to the bullet points
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.
done
packages/color-handle/README.md
Outdated
</div> | ||
``` | ||
|
||
**Transparency Support**: When using transparent colors, the handle displays an opacity checkerboard pattern background to clearly show the transparency level. |
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.
Move this above the example
|
||
#### Color | ||
|
||
The `color` property sets the visual color displayed within the handle. This accepts any valid CSS color format. The default color is `rgba(255, 0, 0, 0.5)` (semi-transparent red). |
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.
We should add a table of the colors accepted OR we should add a line about how color uses the color-controller
and link to the color-controller
docs with the table
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.
Done
packages/color-handle/README.md
Outdated
|
||
When the `<sp-color-handle>` uses the `open` property, the `<sp-color-loupe>` component can be used above the handle to show the selected color that would otherwise be covered by a mouse, stylus, or finger on the down/touch state. This can be customized to appear only on finger-input, or always appear regardless of input type. | ||
When the `open` property is set, the `<sp-color-loupe>` component appears above the handle to show the selected color that would otherwise be covered by a mouse, stylus, or finger on the down/touch state. The loupe automatically appears for touch input (`pointerType === 'touch'`) and can be manually controlled for other input types. |
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.
we should show an example of how to set up the other input types
|
||
```html | ||
<div style="height: 72px"></div> | ||
<sp-color-handle open></sp-color-handle> | ||
``` | ||
|
||
**Automatic Behavior**: The loupe automatically opens when touched and closes when the touch interaction ends. For mouse and stylus input, the loupe remains hidden by default unless explicitly set to `open="true"`. |
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.
This shouldnt be needed, all details should be covered in the first paragraph, make updates there if you feel the wording needs updating
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.
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.
We are not exposing this to users The streamingListener
for internal use 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.
but isnt the streamingListener how a consumer using handle to make a new component would set it up for the event handlers? there is not functional code in handle that sets them up
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.
left a number of comments and happy to discuss further if anything was unclear :)
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.
This is going to be so helpful and timely for the other audit we're having done. Thanks!
Most of my changes are around making the ColorController
docs also follow the same heading structure as other components.
packages/color-handle/README.md
Outdated
|
||
The `<sp-color-handle>` is used to select a colour on an `<sp-color-area>`, `<sp-color-slider>`, or `<sp-color-wheel>`. It functions similarly to the handle on an `<sp-slider>`. | ||
The `<sp-color-handle>` is used to select a color on an `<sp-color-area>`, `<sp-color-slider>`, or `<sp-color-wheel>`. It functions similarly to the handle on an `<sp-slider>`, providing a draggable control point for precise color selection within color components. |
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.
I'd recommend revering to them my name and not stag unless you are referring to the code that creates them.
The `<sp-color-handle>` is used to select a color on an `<sp-color-area>`, `<sp-color-slider>`, or `<sp-color-wheel>`. It functions similarly to the handle on an `<sp-slider>`, providing a draggable control point for precise color selection within color components. | |
The color handle is used to select a color on a [color area](../color-area/), [color slider](../color-slider/), or [color wheel](../color-wheel/). It provides a draggable control point for precise color selection within color components. |
packages/color-handle/README.md
Outdated
- A visual handle element that indicates the current position | ||
- An optional color loupe that appears above the handle when active | ||
- Touch-responsive interaction areas | ||
- Color display showing the current selected color | ||
- Opacity checkerboard pattern for transparent colors |
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.
- A visual handle element that indicates the current position | |
- An optional color loupe that appears above the handle when active | |
- Touch-responsive interaction areas | |
- Color display showing the current selected color | |
- Opacity checkerboard pattern for transparent colors | |
A visual handle element that indicates the current position | |
- Touch-responsive interaction areas | |
- Color display showing the current selected color | |
- Opacity checkerboard pattern for transparent colors | |
- An optional color loupe that appears above the handle when active |
|
||
### States | ||
|
||
#### Standard |
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.
I include the default if I used tabs for a visual comparison, and typically for variants more than states, but it's not necessarily a hill to die on for me.
The color handle can receive keyboard focus when used within interactive color components. The focused state is managed automatically by the parent component and is indicated visually: | ||
|
||
```html | ||
<sp-color-handle focused></sp-color-handle> |
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.
I think it's good to include to show what focused state looks like and how it works within the component.
- **`hue`**: Gets or sets the hue value of the current color. | ||
- **`color`**: Gets or sets the current color value. The color can be provided in various formats, including strings, objects, or instances of the `Color` class. | ||
- **`colorValue`**: Gets the color value in various formats based on the original color input. | ||
- **`hue`**: Gets or sets the hue value of the current color. | ||
|
||
### Methods |
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.
Move color formats below the color options.
### Methods | |
#### Supported Color Formats | |
The `ColorController` supports a wide range of color formats for input and output: | |
<sp-table> | |
<sp-table-head> | |
<sp-table-head-cell>Format</sp-table-head-cell> | |
<sp-table-head-cell>Example Values</sp-table-head-cell> | |
<sp-table-head-cell>Description</sp-table-head-cell> | |
</sp-table-head> | |
<sp-table-body> | |
<sp-table-row> | |
<sp-table-cell>Hex3</sp-table-cell> | |
<sp-table-cell><code>#f00</code>, <code>#0a5</code></sp-table-cell> | |
<sp-table-cell>3-digit hexadecimal</sp-table-cell> | |
</sp-table-row> | |
<sp-table-row> | |
<sp-table-cell>Hex4</sp-table-cell> | |
<sp-table-cell><code>#f00f</code>, <code>#0a58</code></sp-table-cell> | |
<sp-table-cell>3-digit hexadecimal + alpha</sp-table-cell> | |
</sp-table-row> | |
<sp-table-row> | |
<sp-table-cell>Hex6</sp-table-cell> | |
<sp-table-cell><code>#ff0000</code>, <code>#00aa55</code></sp-table-cell> | |
<sp-table-cell>6-digit hexadecimal</sp-table-cell> | |
</sp-table-row> | |
<sp-table-row> | |
<sp-table-cell>Hex8</sp-table-cell> | |
<sp-table-cell><code>#ff0000ff</code>, <code>#00aa5580</code></sp-table-cell> | |
<sp-table-cell>6-digit hexadecimal + alpha</sp-table-cell> | |
</sp-table-row> | |
<sp-table-row> | |
<sp-table-cell>RGB</sp-table-cell> | |
<sp-table-cell><code>rgb(255, 0, 0)</code>, <code>rgb(0, 170, 85)</code></sp-table-cell> | |
<sp-table-cell>Red, Green, Blue values (0-255)</sp-table-cell> | |
</sp-table-row> | |
<sp-table-row> | |
<sp-table-cell>RGBA</sp-table-cell> | |
<sp-table-cell><code>rgba(255, 0, 0, 1)</code>, <code>rgba(0, 170, 85, 0.5)</code></sp-table-cell> | |
<sp-table-cell>RGB + Alpha channel (0-1)</sp-table-cell> | |
</sp-table-row> | |
<sp-table-row> | |
<sp-table-cell>HSL</sp-table-cell> | |
<sp-table-cell><code>hsl(0, 100%, 50%)</code>, <code>hsl(150, 100%, 33%)</code></sp-table-cell> | |
<sp-table-cell>Hue (0-360°), Saturation, Lightness</sp-table-cell> | |
</sp-table-row> | |
<sp-table-row> | |
<sp-table-cell>HSLA</sp-table-cell> | |
<sp-table-cell><code>hsla(0, 100%, 50%, 1)</code>, <code>hsla(150, 100%, 33%, 0.5)</code></sp-table-cell> | |
<sp-table-cell>HSL + Alpha channel (0-1)</sp-table-cell> | |
</sp-table-row> | |
<sp-table-row> | |
<sp-table-cell>HSV</sp-table-cell> | |
<sp-table-cell><code>hsv(0, 100%, 100%)</code>, <code>hsv(150, 100%, 67%)</code></sp-table-cell> | |
<sp-table-cell>Hue (0-360°), Saturation, Value</sp-table-cell> | |
</sp-table-row> | |
<sp-table-row> | |
<sp-table-cell>HSVA</sp-table-cell> | |
<sp-table-cell><code>hsva(0, 100%, 100%, 1)</code>, <code>hsva(150, 100%, 67%, 0.5)</code></sp-table-cell> | |
<sp-table-cell>HSV + Alpha channel (0-1)</sp-table-cell> | |
</sp-table-row> | |
<sp-table-row> | |
<sp-table-cell>Named Colors</sp-table-cell> | |
<sp-table-cell><code>red</code>, <code>rebeccapurple</code>, <code>darkseagreen</code></sp-table-cell> | |
<sp-table-cell>CSS color keywords (<a href="https://developer.mozilla.org/en-US/docs/Web/CSS/named-color">full list</a>)</sp-table-cell> | |
</sp-table-row> | |
</sp-table-body> | |
</sp-table> | |
#### Behaviors |
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.
We can do that in color-controller's docs audit ticket
``` | ||
|
||
## Supported Color Formats | ||
|
||
The `ColorController` supports a wide range of color formats for input and output: | ||
|
||
<sp-table> | ||
<sp-table-head> | ||
<sp-table-head-cell>Format</sp-table-head-cell> | ||
<sp-table-head-cell>Example Values</sp-table-head-cell> | ||
<sp-table-head-cell>Description</sp-table-head-cell> | ||
</sp-table-head> | ||
<sp-table-body> | ||
<sp-table-row> | ||
<sp-table-cell>Hex3</sp-table-cell> | ||
<sp-table-cell><code>#f00</code>, <code>#0a5</code></sp-table-cell> | ||
<sp-table-cell>3-digit hexadecimal</sp-table-cell> | ||
</sp-table-row> | ||
<sp-table-row> | ||
<sp-table-cell>Hex4</sp-table-cell> | ||
<sp-table-cell><code>#f00f</code>, <code>#0a58</code></sp-table-cell> | ||
<sp-table-cell>3-digit hexadecimal + alpha</sp-table-cell> | ||
</sp-table-row> | ||
<sp-table-row> | ||
<sp-table-cell>Hex6</sp-table-cell> | ||
<sp-table-cell><code>#ff0000</code>, <code>#00aa55</code></sp-table-cell> | ||
<sp-table-cell>6-digit hexadecimal</sp-table-cell> | ||
</sp-table-row> | ||
<sp-table-row> | ||
<sp-table-cell>Hex8</sp-table-cell> | ||
<sp-table-cell><code>#ff0000ff</code>, <code>#00aa5580</code></sp-table-cell> | ||
<sp-table-cell>6-digit hexadecimal + alpha</sp-table-cell> | ||
</sp-table-row> | ||
<sp-table-row> | ||
<sp-table-cell>RGB</sp-table-cell> | ||
<sp-table-cell><code>rgb(255, 0, 0)</code>, <code>rgb(0, 170, 85)</code></sp-table-cell> | ||
<sp-table-cell>Red, Green, Blue values (0-255)</sp-table-cell> | ||
</sp-table-row> | ||
<sp-table-row> | ||
<sp-table-cell>RGBA</sp-table-cell> | ||
<sp-table-cell><code>rgba(255, 0, 0, 1)</code>, <code>rgba(0, 170, 85, 0.5)</code></sp-table-cell> | ||
<sp-table-cell>RGB + Alpha channel (0-1)</sp-table-cell> | ||
</sp-table-row> | ||
<sp-table-row> | ||
<sp-table-cell>HSL</sp-table-cell> | ||
<sp-table-cell><code>hsl(0, 100%, 50%)</code>, <code>hsl(150, 100%, 33%)</code></sp-table-cell> | ||
<sp-table-cell>Hue (0-360°), Saturation, Lightness</sp-table-cell> | ||
</sp-table-row> | ||
<sp-table-row> | ||
<sp-table-cell>HSLA</sp-table-cell> | ||
<sp-table-cell><code>hsla(0, 100%, 50%, 1)</code>, <code>hsla(150, 100%, 33%, 0.5)</code></sp-table-cell> | ||
<sp-table-cell>HSL + Alpha channel (0-1)</sp-table-cell> | ||
</sp-table-row> | ||
<sp-table-row> | ||
<sp-table-cell>HSV</sp-table-cell> | ||
<sp-table-cell><code>hsv(0, 100%, 100%)</code>, <code>hsv(150, 100%, 67%)</code></sp-table-cell> | ||
<sp-table-cell>Hue (0-360°), Saturation, Value</sp-table-cell> | ||
</sp-table-row> | ||
<sp-table-row> | ||
<sp-table-cell>HSVA</sp-table-cell> | ||
<sp-table-cell><code>hsva(0, 100%, 100%, 1)</code>, <code>hsva(150, 100%, 67%, 0.5)</code></sp-table-cell> | ||
<sp-table-cell>HSV + Alpha channel (0-1)</sp-table-cell> | ||
</sp-table-row> | ||
<sp-table-row> | ||
<sp-table-cell>Named Colors</sp-table-cell> | ||
<sp-table-cell><code>red</code>, <code>rebeccapurple</code>, <code>darkseagreen</code></sp-table-cell> | ||
<sp-table-cell>CSS color keywords (<a href="https://developer.mozilla.org/en-US/docs/Web/CSS/named-color">full list</a>)</sp-table-cell> | ||
</sp-table-row> | ||
</sp-table-body> | ||
</sp-table> | ||
``` |
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.
Move this section above color properties.
``` | |
## Supported Color Formats | |
The `ColorController` supports a wide range of color formats for input and output: | |
<sp-table> | |
<sp-table-head> | |
<sp-table-head-cell>Format</sp-table-head-cell> | |
<sp-table-head-cell>Example Values</sp-table-head-cell> | |
<sp-table-head-cell>Description</sp-table-head-cell> | |
</sp-table-head> | |
<sp-table-body> | |
<sp-table-row> | |
<sp-table-cell>Hex3</sp-table-cell> | |
<sp-table-cell><code>#f00</code>, <code>#0a5</code></sp-table-cell> | |
<sp-table-cell>3-digit hexadecimal</sp-table-cell> | |
</sp-table-row> | |
<sp-table-row> | |
<sp-table-cell>Hex4</sp-table-cell> | |
<sp-table-cell><code>#f00f</code>, <code>#0a58</code></sp-table-cell> | |
<sp-table-cell>3-digit hexadecimal + alpha</sp-table-cell> | |
</sp-table-row> | |
<sp-table-row> | |
<sp-table-cell>Hex6</sp-table-cell> | |
<sp-table-cell><code>#ff0000</code>, <code>#00aa55</code></sp-table-cell> | |
<sp-table-cell>6-digit hexadecimal</sp-table-cell> | |
</sp-table-row> | |
<sp-table-row> | |
<sp-table-cell>Hex8</sp-table-cell> | |
<sp-table-cell><code>#ff0000ff</code>, <code>#00aa5580</code></sp-table-cell> | |
<sp-table-cell>6-digit hexadecimal + alpha</sp-table-cell> | |
</sp-table-row> | |
<sp-table-row> | |
<sp-table-cell>RGB</sp-table-cell> | |
<sp-table-cell><code>rgb(255, 0, 0)</code>, <code>rgb(0, 170, 85)</code></sp-table-cell> | |
<sp-table-cell>Red, Green, Blue values (0-255)</sp-table-cell> | |
</sp-table-row> | |
<sp-table-row> | |
<sp-table-cell>RGBA</sp-table-cell> | |
<sp-table-cell><code>rgba(255, 0, 0, 1)</code>, <code>rgba(0, 170, 85, 0.5)</code></sp-table-cell> | |
<sp-table-cell>RGB + Alpha channel (0-1)</sp-table-cell> | |
</sp-table-row> | |
<sp-table-row> | |
<sp-table-cell>HSL</sp-table-cell> | |
<sp-table-cell><code>hsl(0, 100%, 50%)</code>, <code>hsl(150, 100%, 33%)</code></sp-table-cell> | |
<sp-table-cell>Hue (0-360°), Saturation, Lightness</sp-table-cell> | |
</sp-table-row> | |
<sp-table-row> | |
<sp-table-cell>HSLA</sp-table-cell> | |
<sp-table-cell><code>hsla(0, 100%, 50%, 1)</code>, <code>hsla(150, 100%, 33%, 0.5)</code></sp-table-cell> | |
<sp-table-cell>HSL + Alpha channel (0-1)</sp-table-cell> | |
</sp-table-row> | |
<sp-table-row> | |
<sp-table-cell>HSV</sp-table-cell> | |
<sp-table-cell><code>hsv(0, 100%, 100%)</code>, <code>hsv(150, 100%, 67%)</code></sp-table-cell> | |
<sp-table-cell>Hue (0-360°), Saturation, Value</sp-table-cell> | |
</sp-table-row> | |
<sp-table-row> | |
<sp-table-cell>HSVA</sp-table-cell> | |
<sp-table-cell><code>hsva(0, 100%, 100%, 1)</code>, <code>hsva(150, 100%, 67%, 0.5)</code></sp-table-cell> | |
<sp-table-cell>HSV + Alpha channel (0-1)</sp-table-cell> | |
</sp-table-row> | |
<sp-table-row> | |
<sp-table-cell>Named Colors</sp-table-cell> | |
<sp-table-cell><code>red</code>, <code>rebeccapurple</code>, <code>darkseagreen</code></sp-table-cell> | |
<sp-table-cell>CSS color keywords (<a href="https://developer.mozilla.org/en-US/docs/Web/CSS/named-color">full list</a>)</sp-table-cell> | |
</sp-table-row> | |
</sp-table-body> | |
</sp-table> | |
``` |
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.
We can do that in color-controller's docs audit ticket
@@ -118,5 +118,74 @@ class Host extends LitElement { | |||
} | |||
|
|||
} | |||
``` |
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.
Move the Example after the anatomy section and before the options section.
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.
We can do that in color-controller's docs audit ticket
- **Color Management**: The `ColorController` allows you to manage color values in multiple formats, including RGB, HSL, HSV, and Hex. | ||
- **Validation**: It provides methods to validate color strings and ensure they conform to the expected formats. | ||
- **Conversion**: The class can convert colors between different color spaces, making it versatile for various applications. | ||
- **State Management**: It maintains the current color state and allows saving and restoring previous color values. | ||
|
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.
Move the example to the Anatomy section.
#### Example | |
```js | |
import { LitElement } from 'lit'; | |
import {ColorController} from '@spectrum-web-components/reactive-controllers/src/ColorController.js'; | |
class Host extends LitElement { | |
/** | |
* Gets the current color value from the color controller. | |
* | |
* @returns {ColorTypes} The current color value. | |
*/ | |
@property({ type: String }) | |
public get color(): ColorTypes { | |
return this.colorController.colorValue; | |
} | |
/** | |
* Sets the color for the color controller. | |
* | |
* @param {ColorTypes} color - The color to be set. | |
*/ | |
public set color(color: ColorTypes) { | |
this.colorController.color = color; | |
} | |
private colorController = new ColorController(this, { manageAs: 'hsv' }); | |
} | |
``` | |
The color Controller could also be initialised in the constructor as shown below | |
```js | |
import { LitElement } from 'lit'; | |
import {ColorController} from '@spectrum-web-components/reactive-controllers/src/ColorController.js'; | |
class Host extends LitElement { | |
/** | |
* Gets the current color value from the color controller. | |
* | |
* @returns {ColorTypes} The current color value. | |
*/ | |
@property({ type: String }) | |
public get color(): ColorTypes { | |
return this.colorController.colorValue; | |
} | |
/** | |
* Sets the color for the color controller. | |
* | |
* @param {ColorTypes} color - The color to be set. | |
*/ | |
public set color(color: ColorTypes) { | |
this.colorController.color = color; | |
} | |
private colorController: ColorController; ; | |
constructor() { | |
super(); | |
this.colorController = new ColorController(this, { manageAs: 'hsv' }); | |
} | |
} | |
``` |
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.
We can do that in color-controller's docs audit ticket
- **`restorePreviousColor(): void`**: | ||
Restores the previous color. | ||
- **`restorePreviousColor(): void`**: | ||
Restores the previous color. | ||
|
||
## Usage |
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.
Move the Usage section to above Anatomy
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.
We can do that in color-controller's docs audit ticket
Co-authored-by: Casey Eickhoff <[email protected]> Co-authored-by: Nikki Massaro <[email protected]>
Since the scope of this ticket is to audit and update the Docs for |
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.
LGTM
Overview
This PR reorganizes the color-handle README.md to follow the established documentation standards structure, improving accessibility and consistency with other components.
Changes Made
Structure Reorganization
bash
,javascript
)Content Improvements
color
,focused
)Accessibility Enhancements
Testing
Related Documentation
This reorganization makes the color-handle documentation more accessible, easier to navigate, and consistent with the established documentation standards across the Spectrum Web Components library.