To avoid boilerplate, I want to write a function/mixin taking a list of CSS properties (at least one) and write the same transition for each, and also output will-change accordingly. Given margin-left, width, to output:
{
transition: margin-left $some-value, width $some-value;
will-change: margin-left, width;
}
I found I can use an arguments list with a spread operator (@mixin some-mixin($args...)) and tried looping using @each, but I don't really know how to use @each inside a single property and concatenate the results with a comma, without having an end comma.
Here is the github comment which led me to the answer.
There is a function called append in
'sass:list', which can be used to create a comma separated list, as follows:Input (SCSS):
Output (CSS):
See it working in SASS: Playground.