I’ll start with my code, as it should be easier to understand what I want to do:
@function get-color($color, $lightness) {
@return map-get(map-get($colors, $color), $lightness);
}
$colors: (
green: (
light: #A4EDE1,
mid: darken(get-color(green, light), 20%),
dark: darken(get-color(green, mid), 20%)
),
red: (
light: complement(get-color(green, light)),
mid: complement(get-color(green, mid)),
dark: complement(get-color(green, dark))
)
);
As you can see, I have created a multidimensional map, with my color values.
At the moment, I want to create the other colors, through the darken()
and the complement()
functions.
The problem with that is, that I need to reference variables inside of the $colors
variable, before it is completely filled. This results in an error for my get-color()
function, which tells me, there is no $colors
variable.
I know it would be possible to alter the colors outside of my $colors
map, but the benefit of doing it this way is, that I can always come back and define color values, that are not generated. This would be a huge benefit in maintaining the project.
So here my question: Is there any way to reference another variable in map, before the whole map is defined?