-
Notifications
You must be signed in to change notification settings - Fork 689
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
[css-values-5] Accept more than 2 values in *-mix(<progress>, ...)
and progress()
notations
#11530
Comments
*-mix(<progress>, ...)
notation with more than 2 values*-mix(<progress>, ...)
and progress()
notations
I don't understand what difference you are implying
I don't understand how this is supposed to behave |
This should be better explained in the spec, which just mentions the two concepts :/
Basically mixing has the opposite behavior of interpolation: While it's unclear what something like
I think understanding the difference of mixing vs interpolation is kinda a prerequisite for this proposal. |
I disagree that they are opposites. Whether you call
Well, I think https://drafts.csswg.org/css-color-5/#color-mix-percent-norm could be generalized in a quite natural way:
So in this case it would be
Yes that can work, though I would maybe call this color picking rather than mixing/interpolating. Because it's placing colors at equidistant positions between 0% and 100%, and then picking the color at the provided percentage, falling back to interpolating the nearest pair of colors if there is no color at that exact position. However, I think forcing equidistant positions may be a bit inflexible. Just like gradients, I suspect that authors will ask to be able to assign colors at a custom percentage position, or even a range. But these positions could be confused with mixing weights, so I would prefer a different function name. |
Happy to generalize it to the version with weights too, though I do think it's somewhat less intuitive.
Note that this doesn't just affect
I completely agree, but equidistant is fine for an MVP — we can add positions later. Far, far easier to add intermediate color stops to fake the lack of positions than to deal with a quadratic number of nested calls.
I agree |
A common need in design systems is to get a value based on its position in a list. E.g. get the lightest color tint, or the smallest font-size etc.
In css-values-5 we define
*-mix()
functions (calc-mix()
,color-mix()
etc) that interpolate rather than mix, i.e. 0% gets you the first color and 100% the second one instead of the way around which is how the mixing version works.This means they do not actually need to be limited to two arguments!
All we need to solve a lot of the use cases that motivated #10034 and a host more is to convert the grammars of these mix functions from:
to
And similarly for
cross-fade()
andtransform-mix()
though I haven't found use cases for these.Yes, it can be emulated with the 2-value
*-mix()
, but the code to do it is abysmal and its complexity increases quadratically with the number of values.The same argument applies to
progress()
, being the inverse of these. Currently it is defined as:With this change, it would become:
(or just
progress( <calc-sum>#)
but separating the first argument may be better for clarity)A nice-to-have could also be to support percentages as well with the values, which would work in the same way as gradient color stops, i.e. affect how the interpolation works.
This is a change that only very slightly increases implementation effort for these functions, and would save authors a ton of pain, so it seems like a no-brainer to me.
The text was updated successfully, but these errors were encountered: