My sass map contains a variety of color shades, and the full code can be found on Codepen:
$pbcolors: (
pbcyan : (
50: #E5F5FC,
100: #CCEBF9,
200: #99D7F2,
300: #66C3EC,
400: #33AFE5,
500: #009DBF,
600: #008CAB,
700: #007C98,
800: #006D85,
900: #005D72
),
pbmediumblue: (
50: #E5F1F8,
100: #CCE3F1,
200: #99C7E3,
300: #66AAD4,
400: #338EC6,
500: #0072B8,
600: #0065A5,
700: #005A93,
800: #004F80,
900: #00436E
),
pbpurple: (
50: #F5ECF5,
100: #ECD9EB,
200: #D9B2D7,
300: #C68CC3,
400: #B365AF,
500: #A03F9B,
600: #90388B,
700: #80327C,
800: #702C6C,
900: #60255D
);
I'm attempting to generate classes using a loop that combines the color and shade as part of the class name with the corresponding hex value as the background color. An example class would look like this:
.bg-pbmediumblue-100 { background: #CCE3F1; }
However, my current loop syntax seems to be incorrect as I am not progressing to the second level of the map:
@each $item, $color in $pbcolors {
@each $shade, $value in $item {
.bg-#{$shade}-#{$shade} {
background-color: map-get(map-get($pbcolors, $item), 50);
}
}
}
As a result, I'm only retrieving the 50 value of each color and the class names are incorrect:
.bg-pbcyan-pbcyan {
background-color: #E5F5FC;
}
.bg-pbmediumblue-pbmediumblue {
background-color: #E5F1F8;
}
Where did I make a mistake?