-
Notifications
You must be signed in to change notification settings - Fork 715
[css-color-5] Is relative colors "omitted alpha" rule useful? #10991
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
Comments
Completely agreed, no idea what I was thinking when I wrote that — if I did write that — it’s not part of my original proposal; @tabatkins proposed it later though that was in the context of omitting any value, which was still on the table. Looking at commits it appears that it was you @svgeesus that introduced it? So I suspect we'll have consensus to remove the rule, the tricky part now is web compat… |
There is interop for the current specification and this behavior is well documented: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_colors/Relative_colors#:~:text=Optionally%2C%20an%20alpha%20channel%20value%20for%20the%20output%20color%20can%20be%20defined%2C%20preceded%20by%20a%20slash%20(/).%20If%20the%20alpha%20channel%20value%20is%20not%20explicitly%20specified%2C%20it%20defaults%20to%20the%20alpha%20channel%20value%20of%20the%20origin%2Dcolor%20(not%20100%25%2C%20which%20is%20the%20case%20for%20absolute%20color%20values). There also is no way to do feature detection for such a change. Authors could always write an explicit alpha component even for |
Yeah, I argued for the omitted-alpha behavior (and was actually the original contributor; Chris's commit is just rearranging that text), and I still think it's a good idea. Alpha is the only channel that exists in every single color syntax, with identical meaning. So it's always safe to transfer the alpha like this, in a way that any other channel wouldn't be. More importantly, it's pretty much independent of the rest of the color. Nearly any meaningful operation you could possibly do to a color will adjust its non-alpha components only, unless the operation is specifically to adjust the alpha. Virtually nothing does both: lighten, darken, saturate, grayscale, sepia, hue shift, they're all alpha-independent. As such, it's easy to forget to handle the alpha when you're working on non-alpha components. Put another way, almost every single relative color ever written (that's not just doing an alpha modification itself) will want to put So, no, we won't have consensus to remove it; I feel pretty strongly that the current behavior is a good idea. |
I also feel that the current omitted-alpha behavior is the most useful one. Avoiding having to type |
To be clear, I don't have a too strong feeling one way or the other. I did find it confusing as an author, and when reviewing code to implement it. But I guess I could see it being useful? It's just a bit "too magic" for my taste. If you accidentally find this behavior and don't want it, it's not super-clear that you need |
Ok, after reading @tabatkins’s comment, I'm also convinced it’s a good idea 😁 |
+1 for preserving origin alpha. The way I think about it is: in relative color syntax, the author is starting with an origin color and then specifying modifications to it. If they don't say anything about a particular aspect of the origin color, it should be left untouched. |
So, @emilio can we close this? |
Sure, sounds fine :) |
https://drafts.csswg.org/css-color-5/#rcs-intro says:
That was a bit unexpected to me, and feels it could be for authors as well. Given authors can just type an extra
alpha
on the color, is it really worth the confusion?cc @svgeesus @weinig
The text was updated successfully, but these errors were encountered: