I tried to make the following code look fancier with an @each
or a @for
loop (without any usable result).
.btn[data-btn-color="black"] {
@include colored-btn($black);
}
.btn[data-btn-color="blue"] {
@include colored-btn($blue);
}
.btn[data-btn-color="red"] {
@include colored-btn($red);
}
// ... and more colors ...
My current approach is to take value from the variable to use it as the value for the data-btn-color
attribute and put that snippet into an @each
loop.
Something like
@each $color in ($black, $blue) {
@include colored-btn($color);
}
which compiles into:
.btn[data-btn-color="black"] {
background-color: #000; // $black
}
.btn[data-btn-color="blue"] {
background-color: #00f; // $blue
}
Is there any function, which allows me to do such a thing?