A common use case for dynamic mixins (i.e. having the mixin name in a variable) is passing mixins around, so that a design system can communicate with components (e.g. "if you need to render a button, this is my button style").
Since dynamic mixins are hard (see #12927) a very low-fi way to do this would be if the component could specify something like "if you have a button style, I expect to find it in the mixin foo-bar-button"). Of course, it doesn't make sense for the design system to use foo-bar-button for its own needs, ergo aliasing.
Sure, we can already do:
@mixin --button(--priority: <syntax1>, --variant: <syntax2>) {
/* ... */
}
@mixin --foo-bar-button(--priority: <syntax1>, --variant: <syntax2>) {
@apply --button(var(--priority), var(--variant));
}
And if we do actually need to map arguments, it's the only way.
However, it would be nice if there was syntactic sugar, for the cases where we don't need to map arguments:
@mixin --foo-bar-button: --button;
We could even support currying (not MVP):
@mixin --foo-bar-button: --button(primary, danger);
Aliasing is definitely not MVP, so perhaps this should be under css-mixins-2, though it seems like such a small feature that maybe we can sneak it into level 1.
cc @tabatkins @andruud
A common use case for dynamic mixins (i.e. having the mixin name in a variable) is passing mixins around, so that a design system can communicate with components (e.g. "if you need to render a button, this is my button style").
Since dynamic mixins are hard (see #12927) a very low-fi way to do this would be if the component could specify something like "if you have a button style, I expect to find it in the mixin
foo-bar-button"). Of course, it doesn't make sense for the design system to usefoo-bar-buttonfor its own needs, ergo aliasing.Sure, we can already do:
And if we do actually need to map arguments, it's the only way.
However, it would be nice if there was syntactic sugar, for the cases where we don't need to map arguments:
We could even support currying (not MVP):
Aliasing is definitely not MVP, so perhaps this should be under css-mixins-2, though it seems like such a small feature that maybe we can sneak it into level 1.
cc @tabatkins @andruud