Repository navigation
feat(color-picker): color panel and color picker improvements - #2649
Open
rkaraivanov wants to merge 7 commits into
Open
rkaraivanov wants to merge 7 commits into
rkaraivanov wants to merge 7 commits into
Conversation
Modern CSS colors, such as oklch(), lab(), color() and color-mix(), now parse into sRGB and no longer give NaN. A color that depends on its context, such as currentcolor or var(), clears the value. The area keys move the marker 1 % (10 % with Shift, Page Up/Down and Home/End) at any area size. In input mode, a clear icon shows while a color is set, with clear(), a clear-icon slot and a part (#2647). The text field exposes the field, input, native-input, label, prefix and suffix parts (#2637). The new igc-color-panel is the picker surface as its own element. The picker shows it in its popup, with the same parts and behavior. The new igc-color-swatch and igc-color-swatch-group add swatches as light DOM children of the panel or the picker, in labelled groups. All swatches are one listbox with arrow, Home/End, Enter and Space keys. A swatch can be a no-color swatch or use var(). views and active-view add a swatch view with a view switcher. The new strings show in English until igniteui-i18n-core ships them. The swatch, group and switcher styles are temporary until the design is ready.
Modern CSS colors, such as oklch(), lab(), color() and color-mix(), now parse into sRGB and no longer give NaN. A color that depends on its context, such as currentcolor or var(), clears the value. The area keys move the marker 1 % (10 % with Shift, Page Up/Down and Home/End) at any area size. In input mode, a clear icon shows while a color is set, with clear(), a clear-icon slot and a part (#2647). The text field exposes the field, input, native-input, label, prefix and suffix parts (#2637). The new igc-color-panel is the picker surface as its own element. The picker shows it in its popup, with the same parts and behavior. The new igc-color-swatch and igc-color-swatch-group add swatches as light DOM children of the panel or the picker, in labelled groups. All swatches are one listbox with arrow, Home/End, Enter and Space keys. A swatch can be a no-color swatch or use var(). views and active-view add a swatch view with a view switcher. The new strings show in English until igniteui-i18n-core ships them. The swatch, group and switcher styles are temporary until the design is ready.
With selection-commit="confirm", changes in the popup are a draft: value keeps its color and the picker emits no igcInput. Apply emits one igcChange at once and closes the popup. Enter on the canvas marker, a slider or a swatch also applies the draft; Space on a swatch only picks. Cancel and every other close drop the draft. A write of a new color from code also ends the draft. A preview shows the initial color beside the draft, and a click on the initial color restores it. The new footer slot adds content below the color panel in both modes. New parts style the footer, the preview and the buttons. The Apply, Cancel and Initial color strings show in English until igniteui-i18n-core ships them, and the footer styles are temporary until the design is ready. The combo and the date range picker now render their Cancel and Apply (or Done) buttons through the same shared template. Their output does not change.
… feedback The hue slider now gives its angle and hue name, such as "120 degrees, green", to assistive technology. The alpha slider gives its percentage. Both use the number format of the locale. While a color is set, the value text of the canvas marker ends with the color name, such as "dark vibrant blue". The color name comes from the OKLCH lightness, chroma and hue of the color. Lightness and chroma are compared with the most chromatic sRGB color of the hue, so pure yellow and navy get sensible names. The words and their order come from the resource strings. A swatch without a label now takes its color name, with its alpha when it is not opaque, instead of the color string. After a copy, the copy button shows a check icon and "Copied" for one second. After a failed copy, or where there is no clipboard, it shows an error icon and "Copy failed". Only the latest copy shows its result. The 25 new strings show in English until igniteui-i18n-core ships them. The internal canvas now takes its finished value text from the panel.
In input mode, the text field took the width of its content, so the clear icon made it 45 px wider while a color was set. Now the picker is a block and the field fills its container, as in the date picker. The clear icon takes its space from the text. Default mode stays inline. Apps that use input mode get a wider field. To keep it narrow, set the width of the picker.
With `contrast-against`, the color panel and the popup of the color picker show the WCAG 2 contrast ratio of the color over that background, such as "Contrast 4.54:1". They also show "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 goes over white. The ratio is cut to two decimals, not rounded, so it never shows a level that it fails. `contrast-against` takes any CSS color. A color that depends on its context, such as a `var()`, `currentcolor` or `light-dark()`, resolves from the panel. The `var()` swatches now use the same resolver, so they no longer wait for their first render. An empty or invalid color, or an empty value, hides the readout. A server render has no readout; it shows after hydration. The `contrast`, `contrast-ratio`, `contrast-mark`, `pass` and `fail` parts style the readout. Its five new strings show in English until igniteui-i18n-core ships them, and its styles are temporary until the design is ready.
In the oklch format, the area shows OKLCH lightness by chroma at the OKLCH hue, and the hue slider moves the OKLCH hue on a track of cusp colors. In the other formats, the area stays HSV. - The area paints only the sRGB gamut, with smooth edges, and leaves the rest transparent. At the blue hue, the black-to-blue edge is a thin spike, painted as a 1 px line. - A pick or hue change beyond the gamut edge keeps the lightness and cuts the chroma back to the edge. - The color model keeps an OKLCH space. A gray keeps its hue across HSV and OKLCH. - The marker has a new name and value text (2 new strings).
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Adds
igc-color-panel, the color picker surface as a standalone component (for theme editors and sidebars), and the features of the color picker plan. The picker shows the panel in its popup, so the picker gets every feature too.New
igc-color-panel: the picker surface in the page. It emitsigcInputandigcChange, and it is not a form control.igc-color-swatchandigc-color-swatch-group: swatches in the light DOM, in labeled groups. All swatches are one listbox, with arrow keys.viewsandactive-viewswitch between the gradient and the swatches.oklchformat. In this format, the area is OKLCH lightness by chroma and the hue slider is the OKLCH hue. The area paints only the sRGB gamut.selection-commit="confirm": changes in the popup are a draft until the user applies them.contrast-against: a WCAG 2 contrast readout with AA and AAA marks.fieldpart forwarding (Color Picker: expose the input-mode field as a part #2637).Fixed
oklch(),lab(),color(),color-mix()and relative colors gaveNaNchannels. The picker now converts them to sRGB and clips them to the sRGB gamut.currentcolor,var(), system colors) are now invalid. Before, they turned into black or into their light value.Changed behavior (see the
Changedsection of the CHANGELOG)igc-color-swatchelements.Notes
rkaraivanov/color-picker-stringsin igniteui-i18n.Type of Change
Related Issues
Closes #2647
Closes #2637
Testing
npm run test(Chromium): 7476 passed. The new specs cover the panel, the swatches, OKLCH, contrast, color names and the confirm mode, with a11y audits and fast-check property tests.npm run lintandnpm run check.Checklist
npm run public-api:updateand committedpublic-api.jsonandapi-reference/CHANGELOG.mdentry under[Unreleased]