Reputation: 8103
say this (sass maps):
$small:(
side-spacing: 14px
);
$medium-aux:(
side-spacing: 28px
);
$large:(
side-spacing: 38px
);
Is there a way to build a 'function' that outputs the above, receiving the values? Like (fake):
build_spacings(14px, 28px, 38px);
They asked me why this is not a duplicate question: I'm speaking specifically of sass maps, and not necessarilly global ones.
Upvotes: 1
Views: 54
Reputation: 2786
You can set those global variables if you use the !global
keyword.
Here is working code that will generate the maps in your question:
@mixin build_spacings ($s, $m, $l) {
$small: (
side-spacing: $s
) !global;
$medium-aux: (
side-spacing: $m
) !global;
$large: (
side-spacing: $l
) !global;
}
@include build_spacings(14px, 28px, 38px);
You can see it working at SassMeister.
Upvotes: 1