[color-swatch] Add support for color difference (Delta E) and contrast#119
[color-swatch] Add support for color difference (Delta E) and contrast#119DmitrySharabin wants to merge 7 commits intomainfrom
Conversation
✅ Deploy Preview for color-elements ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
|
Why do we have two different syntaxes to parameterize what algorithm is used? For ΔE we use the function name ( Also, thinking of how extends to the color scale case, do we want to be duplicating colors all over the place? Or do we want some way to "link" to another |
I just thought of another option. What if we adopt the way we used to specify color space and coordinate in one go and do the same thing with ΔE and contrast? For example,
Interesting. I need to think about it. |
f52e3a9 to
fa9fad2
Compare
I like it! |
fa9fad2 to
e92f8d5
Compare
|
Updated usage examples: |
0f4034e to
fbce8cf
Compare
src/color-swatch/README.md
Outdated
|
|
||
| You can use the `info` attribute to show information about the color. | ||
| Currently, the only type of information supported is color coords (in any color space), but more will be added in the future. | ||
| Currently, the types of information supported are color coords (in any color space), the difference (delta) and contrast between the current color and another one (specified via [the `vs` attribute](./#the-vs-attribute)). |
There was a problem hiding this comment.
| Currently, the types of information supported are color coords (in any color space), the difference (delta) and contrast between the current color and another one (specified via [the `vs` attribute](./#the-vs-attribute)). | |
| Currently, the types of information supported are color coords (in any color space), the difference (deltaE) and contrast between the current color and another one (specified via [the `vs` attribute](./#the-vs-attribute)). |
delta and deltaE are different things.
There was a problem hiding this comment.
That said, we may want to think about how to support actual deltas (e.g. hue difference)
There was a problem hiding this comment.
We already do it in the PR (see the colorDeltas prop). For hues, we constrain angles using the shorter arc.
fbce8cf to
4109c43
Compare
|
There's so much happening around
I wonder what PR we should get done and merge first. There will definitely be merge conflicts. 😭 |
4109c43 to
ff34d4c
Compare
… `method.algorithm`)
Weird formatting issue
ff34d4c to
ac79559
Compare
Done. Please let me know if I need to add some more. |
Co-authored-by: Lea Verou <lea@verou.me>
0f303aa to
a839910
Compare
| | `--transparcency-background` | `<color>` | The background color of the transparency gradient. | | ||
| | `--transparency-darkness` | `<percentage>` | The opacity of the black color used for dark parts of the transparency gradient. | | ||
| | `--positive-delta-color` | `<color>` | The color used for the positive color difference in color coords. | | ||
| | `--negative-delta-color` | `<color>` | The color used for the negative color difference in color coords. | |
There was a problem hiding this comment.
I don't understand what these mean.
| content-box border-box var(--_transparency-background) | ||
| ); | ||
| --_positive-delta-color: var(--positive-delta-color, hsl(120, 80%, 25%)); | ||
| --_negative-delta-color: var(--negative-delta-color, hsl(0, 85%, 40%)); |
| }, | ||
| }, | ||
| /** | ||
| * Specified deltaE and contrast |
(in terms of design, related to #96; and is also its evolution)
The main features are:
vscolor to calculate deltas and contrast againstinfoattribute now allows specific algorithms to be used to calculate DeltaE and contrast. Some usage examples:info="deltaE2000, WCAG21 contrast",info="Contrast: Michelson contrast",info="DeltaE: deltaEITP, DeltaPhi: DeltaPhi contrast"(when specifying the contrast method, the wordcontrastis mandatory)infoCoords,infoOther, etc) to get the advantage of caching (provided byNudeElement) and make code more DRYTo see it in action: https://deploy-preview-119--color-elements.netlify.app/src/color-swatch/#the-vs-attribute