color-js / elements

WIP
14 stars 1 forks source link

[color-swatch] Add support for color difference (Delta E) and contrast #119

Open DmitrySharabin opened 1 month ago

DmitrySharabin commented 1 month ago

(in terms of design, related to #96; and is also its evolution)

The main features are:

To see it in action: https://deploy-preview-119--color-elements.netlify.app/src/color-swatch/#the-vs-attribute

netlify[bot] commented 1 month ago

Deploy Preview for color-elements ready!

Name Link
Latest commit 4109c43dfe395283d6b68e6b04ea60a5774d1dfc
Latest deploy log https://app.netlify.com/sites/color-elements/deploys/6745c64b86039b000881132f
Deploy Preview https://deploy-preview-119--color-elements.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

LeaVerou commented 1 month ago

Why do we have two different syntaxes to parameterize what algorithm is used? For ΔE we use the function name (deltaE2000) but for contrast we use space separated identifiers. We should pick one syntax and go with it.

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 <color-swatch> somewhere else? But then how does this work in the <color-scale> case where there is no (light DOM) <color-swatch> to link to?

DmitrySharabin commented 1 month ago

Why do we have two different syntaxes to parameterize what algorithm is used? For ΔE we use the function name (deltaE2000) but for contrast we use space separated identifiers. We should pick one syntax and go with it.

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, info="deltaE.2000, contrast.WCAG21". It's aligned with the rest of the info value (if specified) and makes it look more “balanced,” if I can say so.

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 <color-swatch> somewhere else? But then how does this work in the <color-scale> case where there is no (light DOM) <color-swatch> to link to?

Interesting. I need to think about it.

LeaVerou commented 1 month ago

Why do we have two different syntaxes to parameterize what algorithm is used? For ΔE we use the function name (deltaE2000) but for contrast we use space separated identifiers. We should pick one syntax and go with it.

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, info="deltaE.2000, contrast.WCAG21". It's aligned with the rest of the info value (if specified) and makes it look more “balanced,” if I can say so.

I like it!

DmitrySharabin commented 1 month ago

Updated usage examples: info="deltaE.2000, contrast.WCAG21", info="Contrast: contrast.Michelson", info="DeltaE: deltaE.ITP, DeltaPhi: contrast.DeltaPhi"

DmitrySharabin commented 7 hours ago

There's so much happening around <color-swatch> now:

I wonder what PR we should get done and merge first. There will definitely be merge conflicts. 😭