-
Notifications
You must be signed in to change notification settings - Fork 30
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
[Feature]: make 'ts/color/modifiers' use references by using CSS color functions #198
Comments
For some context I'd like to add these two examples that showcase the difference between stacking the transitive transforms of color modifiers and not stacking them: Why is this relevant? Because when you would replace the modifier with color-mix, it means you'd get nested color-mix() calls for the stacking example, similar to how if you created a transitive transform that wraps math statements in calc(), you get nested calc() statements (even though that's redundant in this example, it is not redundant when we talk about nested color-mix calls). {
"colors": {
"red": {
"100": {
"value": "{colors.red.500}",
"type": "color",
"$extensions": {
"studio.tokens": {
"modify": {
"type": "lighten",
"value": "0.4",
"space": "hsl"
}
}
}
}
}
}
} Non stacking: :root {
--sdColorsRed100: color-mix(in srgb, var(--sdColorsRed500), #fff 40%);
}
{
"colors": {
"red": {
"100": {
"value": "{colors.red.200}",
"type": "color",
"$extensions": {
"studio.tokens": {
"modify": {
"type": "lighten",
"value": "0.1",
"space": "hsl"
}
}
}
}
}
}
} Assuming the above, and assuming 200 refers to 300, etc. with the same lighten 0.1, stacking up Stacking (without outputReferences): :root {
--sdColorsRed100:
color-mix(in srgb,
color-mix(in srgb,
color-mix(in srgb,
color-mix(in srgb, #f00, #fff 10%) ,
#fff 10%),
#fff 10%),
#fff 10%);
} I did some testing and the above seems to work in CSS :) so that's good! Finally, stacking without outputReferences: :root {
--sdColorsRed100: var(--sdColorsRed200);
} And now we get back to the topic of that outputReferences is undoing the work of the transform: all this work of transitively wrapping in color-mix, what you actually want is: :root {
--sdColorsRed100: color-mix(in srgb, var(--sdColorsRed200), #fff 10%);
} What that means is that when outputReferences is enabled, we would like the color-mix transform to apply after the output references has been put back... which currently happens on format level :\ although we can potentially change that, so let's take a hypothetical scenario, where we don't resolve references to begin with: Once we hit the color modifier transform, we have: {
"colors": {
"red": {
"100": {
"value": "{colors.red.200}",
"type": "color",
"$extensions": {
"studio.tokens": {
"modify": {
"type": "lighten",
"value": "0.1",
"space": "hsl"
}
}
}
}
}
}
} What if, the color modifier transform ignores the fact that the value contains references, and runs in it regardless, then we get So this requires a change to outputReferences where we don't resolve references whatsoever, but it also requires that transforms have the ability to transform values with references in them, again this is also useful for This is quite a bit of thinking out loud and throwing examples and maybe exploding this issue a bit as a result, but I think it's really important that we tackle this from all the angles:
|
What feature would you like?
color-mix
is now supported in all major browsers. It would be cool ifts/color/modifiers
makes use of this so it's still able to reference variables.For example, take the following case
This now outputs:
but by using color-mix it could output
Which then gives you the ability to modify those references separately, giving you more flexibility in subtheming and darkmode etc...
Would you be available to contribute this feature?
The text was updated successfully, but these errors were encountered: