Reputation: 2763
I have _variables.scss which is structured like this following BEM naming conventions.
$slot-width: 100px;
$slot-height: 10px;
$slot-title-width: 80px;
$slot-title-height: 10px;
I'm repeating variable names $slot-
. Is there a way to do something like:
$slot {
&-width: 100px;
&-height: 10px;
&-title {
&-width: 80px;
&-height: 10px;
}
}
And it compiles to the above?
Upvotes: 3
Views: 160
Reputation: 12431
You could use a map :
$slot: (
"width": 100px,
"height": 10px
);
.some_bem__selector { width: map-get($slot, width); }
Upvotes: 1
Reputation: 8064
You could use Sass Maps:
$slot: (
"width": 100px,
"height": 10px,
"title": (
"width": 80px,
"height": 10px
)
);
Additionally, here's a good article on getting values out of deep Sass maps.
However, it may be easier to continue using regular variables with hyphens, as you already have.
Upvotes: 3