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

CSSColorValue.colorSpace restricts naming of future color functions and color() keywords #1070

Closed
tabatkins opened this issue Apr 19, 2022 · 6 comments

Comments

@tabatkins
Copy link
Member

CSSColorValue exposes a .colorSpace attribute and a .to(colorSpace) method, which use the same set of strings. For color() functions, the corresponding string is the color space keyword; for the other color functions, the corresponding string is the function name.

These two sets of names aren't guaranteed to be distinct! Currently, there's no overlap, but there was in a previous revision to the spec when color(lab ...) was allowed.

@svgeesus and @LeaVerou, do you think restricting these two sets to be non-overlapping in the future is reasonable? Or do you think it's plausible we may want to have such an overlap? If the latter, I think the easiest solution for this is to use parens at the end of the string for the function names, so CSSRGB.colorSpace would return "rgb()", you'd call c.to("rgb()"), etc. Thoughts?

@LeaVerou
Copy link
Member

Yeah we keep going back and forth about which or even whether color functions should be representable in color().

But let's step back for a bit.

Do we actually need a .to(colorSpace) method in CSSColorValue? It cannot actually convert in many cases (e.g when values contain variables or relative values of some sort), and I believe was added as a stopgap before we resolved to have a separate Color class. I think conversions make more sense to be handled by the Color class, which would only accept resolved values and thus wouldn't have the problem of only being able to convert sometimes. It will be more verbose, but I think the predictability is worth it.

@svgeesus
Copy link
Contributor

For color() functions, the corresponding string is the color space keyword; for the other color functions, the corresponding string is the function name.

This follows naturally from the design decision in Typed OM that retaining and exposing the syntax is the most important thing (thus, lots of different ways to specify an sRGB color), while in the Color object exposing the values and the colorspace is the key thing. And thus, conversion to sRGB in the Color object does not need to have options to pick which of the many syntaxes you get.

I agree with Lea that handling color conversions based on fully resolved values in the Color class makes more sense.

@tabatkins
Copy link
Member Author

I've let this sit overnight, and I think I can agree with y'all. Assuming work continues on Color, I can see dropping the .to() function, and then moving .colorSpace to the CSSColor subclass where it's still needed. We can always revisit if necessary in the future.

That'll make this issue moot, then. Thanks!

@LeaVerou
Copy link
Member

Assuming work continues on Color

Chris and I definitely intend to continue working on it (for me as time allows, unless I can get sponsorship for this work), but I will point out you can also pitch in to the work as a co-editor 😉

@tabatkins
Copy link
Member Author

If I had the time to work on everything I had interest in....

@LeaVerou
Copy link
Member

If I had the time to work on everything I had interest in....

I know the feeling 😕

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants