1
Problem situation
I am creating a palette of colors that vary a lot in their references, being 10% of the base color down. For example:
$primary: #0069FF;
A 10% subtraction of this value is:
$primary-900: #1977FF;
Yeah, I’ll play up primary-100
, where its value is: #E5F0FF
.
Backgrounds variants
These backgrounds also vary, and I need to create a class name for each background variation... for example:
.bg-danger-100 {
background-color: $danger-100;
color: $danger;
}
.bg-danger-200 {
background-color: $danger-200;
color: $danger;
}
(...)
.bg-warning-100 {
background-color: $danger-100;
color: $danger;
}
.bg-warning-200 {
background-color: $danger-200;
color: $danger;
}
(...)
Variant texts
.text-danger-100 {
color: $danger-100;
}
.text-danger-200 {
color: $danger-200;
}
(...)
This gets very laborious as the color variations of the palette appear. And I wonder if there is a function that names these classes, as well as adds the relevant values to their variations?
Are there any feature to avoid repeats and lines of codes the color variations?
Maybe give yourself a light, try doing an @each with Darken, to have a result like
darken($danger, 10%)
– hugocsl
Well... the each with the dark I came to think, but did not know the procedure. I came to create a script that defines exactly these rules, and it generates the classes for me. I will comment on this post with the solution.
&#{$prefix}#{$name} { #{$attribute}: $hex; }
– Thiago Cunha