This question already has an answer here:
- Creating or referencing variables dynamically in Sass 5 answers
I have a series of color variables for my site that are numbered off:
$red-1: #821B0D;
$red-2: #B13631;
$red-3: #D75B5B;
$red-4: #F18788;
$red-5: #FDB9B0;
I'd like to set up a mixin that calls them dynamically, like this:
@mixin link($color-name) {
color: $#{$color-name}-2;
&:hover {
color: white;
background-color: $#{$color-name}-4;
}
}
However, I can't figure how to call variables in a manner like this. (The above syntax doesn't work.)
(To head off the obvious suggestion: I'm not using SASS' color functions because my colors aren't set by linear saturation or lightness variations. I can't generate them programmatically in SASS. The lightness shift in reds between steps is not the same as the one between blues, which isn't the same as the one for greens, etc.)