-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
[color-swatch] Add support for color difference (Delta E) and contrast #119
base: main
Are you sure you want to change the base?
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
@@ -131,7 +131,7 @@ future_swatch_container.append(swatch); | |||
### The `info` attribute | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That said, we may want to think about how to support actual deltas (e.g. hue difference)
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 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
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.
Could you add comments above the new props about what kind of info they include? I haven't looked at this in a while and I'm a bit lost
… `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 <[email protected]>
0f303aa
to
a839910
Compare
@@ -338,6 +358,8 @@ These properties are read-only. | |||
| `--transparency-cell-size` | `<length>` | The size of the cells of the transparency gradient. | | |||
| `--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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand what these mean.
@@ -7,6 +7,8 @@ | |||
0 0 / calc(2 * var(--_transparency-cell-size)) calc(2 * var(--_transparency-cell-size)) | |||
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%)); |
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.
Nit: you don't need commas.
}, | ||
}, | ||
/** | ||
* Specified deltaE and contrast |
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 this be "or contrast"?
(in terms of design, related to #96; and is also its evolution)
The main features are:
vs
color to calculate deltas and contrast againstinfo
attribute 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 wordcontrast
is 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