Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 7 additions & 1 deletion .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@
"stylelint",
"webcomponents",
"noopener",
"noreferrer"
"noreferrer",
"srgb",
"rgba",
"oklch",
"oklab",
"currentcolor",
"WCAG"
],
"ignoreRegExpList": ["θ"]
}
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
### Added
- #### Color panel
- New `igc-color-panel` component: the surface of the color picker, alone in the page, for theme editors and sidebars. It has `value`, `format`, `show-alpha`, `hide-formats` and `swatches`. It emits `igcInput` while the user changes the color and `igcChange` when the change ends, as a native range input does. It is not a form control. The color picker shows a panel in its popup, and its parts and behavior do not change.
- New `igc-color-swatch` and `igc-color-swatch-group` components: swatches as light DOM children of a color panel or a color picker, in groups with a label. A swatch has `color` and `label`. A swatch without a color is the no-color swatch, and a pick of it clears the value. A swatch resolves `var()`, and a pick writes the resolved color.
- All swatches are the options of one listbox: the arrow keys move the focus, also to the row above or below, <kbd>Home</kbd> and <kbd>End</kbd> go to the first and last swatch, and <kbd>Enter</kbd> or <kbd>Space</kbd> picks. The first swatch that has the color of the value is selected, with `aria-selected`, the `ig-selected` custom state, and the `selected` part for a swatch of `swatches`.
- `views` (`gradient`, `swatches` or both) and `active-view` set the views of the panel. With both views, a view switcher shows at the top.
- #### Color picker
- `format` takes `oklch`, also in the color panel, and the format select has an OKLCH item. The value writes as `oklch(L% C H)`, with an alpha below 1 as `oklch(L% C H / A)`. Firefox and Safari read the same 8-bit color back from it. Chromium converts OKLCH with other matrices, so for 0.45 % of the colors a channel near 0 comes back one step off. A gray writes its hue as 0.
- `selection-commit="confirm"` makes the changes in the popup a draft. `value` keeps its color, and the picker emits no `igcInput` until the user applies the draft with Apply, or with <kbd>Enter</kbd> on the canvas marker, a slider or a swatch. Apply emits one `igcChange` at once. Cancel and every other close drop the draft. A preview shows the initial color beside the draft, and a click on the initial color restores it. The `footer` slot adds content below the color panel in both modes. The `footer`, `actions`, `preview`, `preview-initial`, `preview-current`, `cancel-button` and `apply-button` parts style them, and the `color_picker_apply`, `color_picker_cancel` and `color_picker_initial_color` strings give their texts. The preview, Cancel and Apply styles are temporary until the design is ready.
- The picker shows its `igc-color-swatch` and `igc-color-swatch-group` children in its popup, and passes `views` and `active-view` to the color panel. A view that the user picks becomes the `activeView` of the picker.
- The hue and alpha sliders have value text for assistive technology, also in the color panel: the angle and the name of the hue, such as "120 degrees, green", and the alpha percentage, in the number format of the locale. The value text of the saturation and value marker ends with the color name, such as "dark vibrant blue", while a color is set. The picker makes the color name from the OKLCH lightness, chroma and hue of the color, with the `color_picker_name_*` words and word order of the resource strings, and `color_picker_value_with_name` joins a value and a name.
- After a copy, the copy button shows a check icon and the name "Copied" for one second, or an error icon and "Copy failed". A copy without a clipboard API, as outside a secure context, also shows "Copy failed". The `color_picker_copied` and `color_picker_copy_failed` strings give the names.
- `contrast-against` shows a contrast readout at the bottom of the popup, also in the color panel: the WCAG 2 contrast ratio of the color over that background, such as "Contrast 4.54:1", and "pass" or "fail" for the AA (4.5:1) and AAA (7:1) levels for normal text. A color with alpha goes over the background, and a background with alpha over white. `contrast-against` takes any CSS color, and a color that depends on its context, such as a `var()`, `currentcolor` or `light-dark()`, resolves from the popup. An empty or invalid color, or an empty value, hides the readout. The `contrast`, `contrast-ratio`, `contrast-mark`, `pass` and `fail` parts style it, and the `color_picker_contrast_ratio`, `color_picker_contrast_pass`, `color_picker_contrast_fail`, `color_picker_contrast_aa` and `color_picker_contrast_aaa` strings give its texts. Its styles are temporary until the design is ready.
- In the `oklch` format, the area of the popup shows the OKLCH lightness by chroma at the OKLCH hue, also in the color panel. The hue slider is the OKLCH hue, so the area, the slider and the color text show the same numbers. The chroma axis goes from 0 to 0.33 for every hue. The area paints only the sRGB colors, and a drag beyond the gamut edge keeps the lightness and cuts the chroma back to the edge. A gray keeps its hue, also across a format switch. The marker is named "Lightness and chroma" for assistive technology. The out-of-gamut look is temporary until the design is ready.
- The new strings of the color names, the copy button, the contrast readout and the OKLCH area show in English until igniteui-i18n-core ships them.
- In input mode, a clear icon shows in the text field while a color is set. A click clears the value, and `igcChange` reports it when the focus leaves the picker. The `clear-icon` slot and part customize it, and `clear()` clears the value from code with no events. Assistive technology reads it as a "Clear color" button. [#2647](https://github.com/IgniteUI/igniteui-webcomponents/issues/2647)
- In input mode, the `field` part is the text field, so `--ig-input-group-*` variables set on `::part(field)` style it and not the inputs inside the picker. The field also forwards `input`, `native-input`, `label`, `prefix` and `suffix`, as in the select and the combo. [#2637](https://github.com/IgniteUI/igniteui-webcomponents/issues/2637)
- #### QR code
- `dot-style`, `square-style` and `corner-dot-style` take `squircle`, a square with soft corners.
- `corner-dot-style` sets the shape of the inner corner dots. When you do not set it, the inner corner dots use `dot-style`, as before.
Expand All @@ -26,6 +42,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- The Material switch moves its thumb with a transition only. Before, it also played a keyframe animation, also on the first render.
- #### Chip
- A selection change by the user animates the chip, as in Ignite UI for Angular. The colors fade, and the selection indicator opens and fades in, or fades out and closes. A change from code and the first render show at once, so a virtualized list does not animate its chips while it scrolls. With `prefers-reduced-motion: reduce`, the chip does not animate. [#2621](https://github.com/IgniteUI/igniteui-webcomponents/issues/2621)
- #### Color picker
- A swatch of `swatches` is an `igc-color-swatch` element, not a `button`, and an empty string in `swatches` gives the no-color swatch. The swatch list is always in the DOM, hidden without swatches. The swatch list is one tab stop, and the arrow keys move between the swatches. Before, each swatch was a tab stop.
- A swatch without a `label` is named by its color name, such as "vibrant red", with its alpha when it is not opaque, such as "vibrant red, alpha 50%". Before, its name was the color string.
- The names of the formats in the format select come from the resource strings. Before, they were fixed English text.
- A value from code with the same color keeps the hue of a gray, as the user set it.
- An arrow key moves the saturation and value marker 1 % of the area, at any area size, and <kbd>Shift</kbd> + Arrow, <kbd>Page Up</kbd>, <kbd>Page Down</kbd>, <kbd>Home</kbd> and <kbd>End</kbd> move it 10 %. Before, an arrow key moved it 1 pixel, and there was no large step.
- In input mode, the picker is a block and the text field fills its container, as in the date picker. The clear icon takes its space from the text, so the field keeps its width when the value clears. Before, the field had the width of its content. To keep a narrow field, set the width of the picker. [#2647](https://github.com/IgniteUI/igniteui-webcomponents/issues/2647)
- #### Combo
- A change of `showSelectAll` or `groupSelection` keeps the active item. Before, no option was active after the change. When the change removes the active select-all option, or an active group header is no longer an option, no option is active.
- #### Date picker
Expand Down Expand Up @@ -71,6 +94,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- #### Checkbox, Radio, Switch
- A change of `value` no longer makes a checked control dirty, so a later `defaultChecked` still sets the checked state, as for a native checkbox or radio.
- #### Color picker
- A value in a notation other than hex, `rgb()` and `hsl()`, such as `oklch()`, `lab()`, `lch()`, `color()`, a relative color or `color-mix()`, gave `NaN` channels in Chromium and Safari. The picker now converts it to sRGB, and clips a color outside the sRGB gamut to it, as Firefox already did.
- A color that depends on its context, such as `currentcolor`, `var()`, `light-dark()` or a system color like `Canvas`, is invalid and clears the value, also when the user types it. Before, Chromium and Safari turned `currentcolor` into black and a system color into its light value.
- A color change of the user marks the picker touched, so a change that fails validation shows the invalid styles at once.
- A value set from code while the focus is in the picker no longer emits `igcChange` when the focus leaves.
- In input mode, the text input no longer shows the invalid styles when the focus moves from it to the color button. The text input shows the invalid state of the picker, together with its validation message.
Expand Down
105 changes: 105 additions & 0 deletions api-reference/igc-color-panel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# igc-color-panel

A color selection surface that stays in the page.

The user picks a color with the color area, the hue slider and the optional
alpha slider. The area is saturation by value, or lightness by chroma at the
OKLCH hue in the `oklch` format. The user can also type any CSS color string,
such as hex, `rgb()`, `hsl()`, `oklch()` or a named color, pick a swatch, or
pick a color from the screen with the native EyeDropper API, where the
browser provides one.

The panel is not a form control. The color picker shows it in a popup.

```ts
import { defineComponents, IgcColorPanelComponent } from 'igniteui-webcomponents';

defineComponents(IgcColorPanelComponent);
```

## Properties

- `value`: `string`. Attribute: `value`.
The value of the component as a CSS color string, in `format`. Accepts any
CSS color, such as hex, `rgb()`, `hsl()`, `oklch()`, `color()` or a named
color. A color outside the sRGB gamut is clipped to it.

An empty, whitespace-only or invalid string clears the value. So does a
color that depends on its context: `currentcolor`, `var()`, `light-dark()`
or a system color.
- `format`: `'hex' | 'rgb' | 'hsl' | 'oklch'`. Default: `'hex'`. Attribute: `format`.
The color format of the string value.

A format change renders `value` in the new notation. The color does not
change, so the component emits no `igcInput` or `igcChange`.
- `hideFormats`: `boolean`. Default: `false`. Attribute: `hide-formats`.
Whether the format select is hidden.
- `showAlpha`: `boolean`. Default: `false`. Attribute: `show-alpha`.
Whether to show the alpha slider and input.
- `swatches`: `string[]`. Default: `[]`. No attribute.
Pre-defined color strings. The component renders them as swatches in its
swatch list, in front of the swatch children. An empty string gives the
no-color swatch.
- `views`: `string`. Default: `'gradient'`. Attribute: `views`.
The views of the component, as a space-separated list of `gradient` and
`swatches`. With both views, a view switcher shows at the top.

With only the gradient view, the swatch list shows below the gradient
controls. With the swatch view, the swatch list shows only in that view.
- `activeView`: `'gradient' | 'swatches'`. Default: `'gradient'`. Attribute: `active-view`.
The view on screen: `gradient` or `swatches`. The view switcher sets it
and emits no event. A view that `views` does not have gives the first
view of `views`.
- `contrastAgainst`: `string`. Default: `''`. Attribute: `contrast-against`.
The background color of the contrast readout, as any CSS color. A color
that depends on its context, such as a `var()`, resolves from the
component. The readout shows the WCAG 2 contrast ratio of the value over
this color, with the AA and AAA levels for normal text. An empty or
invalid color hides it.
- `locale`: `string`. Attribute: `locale`.
The locale of the component. Without it, the component takes its own
`lang`, else the locale of the nearest ancestor that has a `locale` (a
component) or a `lang`, and then the global locale.
- `resourceStrings`: `Required<IgcColorPickerResourceStrings>`. No attribute.
The texts of the component. The strings that you set replace the
strings of the current locale. Reading returns all the strings, with
your strings over the locale strings.

## Events

- `igcInput`
Emitted when the user changes the color with the canvas, the sliders, the alpha input, a swatch or the eye dropper.
- `igcChange`
Emitted when the user ends a change of the color: on the release of the canvas or a slider, on each key that moves them, on a commit of the color text or the alpha input, and on a swatch or an eye dropper pick.

## Slots

- default: The color swatches and swatch groups. The panel shows them in its swatch list, after the swatches of `swatches`.

## CSS parts

- `base`: The wrapper of the panel.
- `picker-canvas`: The area: saturation by value, or lightness by chroma in the `oklch` format.
- `marker`: The marker on the area that shows the picked color.
- `dragging`: Added to the marker part while the user drags it.
- `main-row`: The row containing the hue slider and the copy/eyedropper buttons.
- `alpha-row`: The row containing the alpha slider and input, rendered when `show-alpha` is set.
- `inputs-row`: The row containing the format select and the color value input.
- `buttons`: The wrapper around the copy and eyedropper buttons.
- `hue`: The hue slider.
- `alpha`: The alpha slider.
- `alpha-input`: The input of the alpha value, rendered when `show-alpha` is set.
- `copy`: The button that copies the current color value to the clipboard.
- `eye-dropper`: The button that activates the EyeDropper API.
- `format-select`: The select control used to switch the color string format.
- `swatches`: The swatch list.
- `swatch`: A swatch of the `swatches` property.
- `selected`: Added to the swatch part of the selected swatch.
- `view-switcher`: The view switcher, rendered when `views` has both views.
- `view-button`: A button of the view switcher.
- `active`: Added to the view-button part of the view on screen.
- `contrast`: The contrast readout, rendered when `contrast-against` has a color and the value is not empty.
- `contrast-ratio`: The contrast ratio of the value over `contrast-against`.
- `contrast-mark`: A WCAG level of the contrast readout, AA or AAA.
- `pass`: Added to the contrast-mark part of a level that the ratio passes.
- `fail`: Added to the contrast-mark part of a level that the ratio fails.
Loading