Skip to content
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-picker] Alpha #57

Open
LeaVerou opened this issue May 21, 2024 · 3 comments
Open

[color-picker] Alpha #57

LeaVerou opened this issue May 21, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@LeaVerou
Copy link
Member

<color-picker> should optionally support alpha (see https://colorjs.io/apps/picker/ )

We could have a boolean alpha property for that.
If the picker color includes alpha, but this.alpha === false, the generated color would just continue having that alpha.

Though, we can kill two birds with one stone and have a sliders or show property that controls all sliders shown and their order. E.g. show="l, c, h, alpha".

In the future it could even be extended to include sliders from other color spaces, like sliders="oklch.h, lch.c, hsl.l", though not sure whether there are use cases for that. But the syntax can support it if use cases arise!

@LeaVerou LeaVerou added the enhancement New feature or request label May 21, 2024
@DmitrySharabin
Copy link
Collaborator

DmitrySharabin commented May 21, 2024

But we still need a way to add the alpha channel, right? We probably don’t want authors to specify all channels to simply enable alpha.

Something like <color-picker space="hsl" alpha> is a shortcut for <color-picker space="hsl" sliders="h, s, l, alpha">?

@LeaVerou
Copy link
Member Author

How about channels instead of sliders for the attribute name? For example, <color-picker space="oklch" channels="h, l">. Looks rad. :)

Not sure if alpha can be considered a channel, but otherwise not opposed to it.

But we still need a way to add the alpha channel, right? We probably don’t want authors to specify all channels to simply enable alpha.

Something like <color-picker space="hsl" alpha> is a shortcut for <color-picker space="hsl" sliders="h, s, l, alpha">?

Oooh that’s a good point. It may be trivial to specify them for static spaces, but it becomes quite a hassle when the color space is dynamic. I'm trying to avoid introducing error conditions, and having two attributes that need to be in sync creates an error condition.

I can see two solutions:

  1. Relative identifiers, e.g. show="+alpha" (or channels="+alpha") would mean "add alpha to whatever you'd normally show", whereas show="alpha" would mean "_only_ show alpha", and show="-c" would mean "remove c from what you’d normally show. This is probably the most flexible, but not sure it’s worth the complexity.
  2. Just go with the boolean alpha attribute for now, and if we introduce a channels attribute it would only be for channels. This is definitely simpler to implement, and it means we can defer channels to later.

@DmitrySharabin
Copy link
Collaborator

2. Just go with the boolean alpha attribute for now, and if we introduce a channels attribute it would only be for channels. This is definitely simpler to implement, and it means we can defer channels to later.

Already done in #63. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants