I'm trying to have an array inside an object's value.
$background-things: (
'a': ['100vh', 'transparent', 'column'],
'higher': ['70vh', '#000', 'column'],
'lower': ['30vh', '#fff', 'row'],
);
and then later call them like this:
@each $name, $value in $background-things {
#background {
&-#{$name}: {
@include column($height:$value[0], $background-color:$value[1], $flex-direction:$value[2]);
}
}
}
This doesn't work. Is there any way to do this? On a side note, does the value $name work, because in the object's property I put '&-a'.
It is possible. @each part needs some modification:
&-#{$name}: should convert to &-#{$name}.nth function; for example nth($value, 1).'100vh' doesn't need '.More information about lists: https://sass-lang.com/documentation/modules/list
@each $name, $value in $background-things {
#background {
&-#{$name} {
@include column($height:nth($value, 1), $background-color:nth($value, 2), $flex-direction:nth($value, 3));
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With