Skip to content

Instantly share code, notes, and snippets.

@asvny
Created September 3, 2015 13:42
Show Gist options
  • Save asvny/4d733d54e53ef5e62cf7 to your computer and use it in GitHub Desktop.
Save asvny/4d733d54e53ef5e62cf7 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// libsass (v3.2.5)
// ----
$themes: (
theme1: theme-light,
theme2: theme-dark
);
@function setStyle($map, $object, $style) {
@if map-has-key($map, $object) {
@return map-get(map-get($map, $object), $style);
}
@warn "The key ´#{$object} is not available in the map.";
@return null;
}
$config: (
theme1: (
background: #f2f2f2,
color: #000
),
theme2: (
background: #666,
color: #fff
)
);
.m-button {
@each $key, $value in $themes {
@if map-has-key($config, $key) {
.#{$value} & {
background: setStyle($config, $key, background);
color: setStyle($config, $key, color);
}
} @else {
@warn "The key ´#{$key} isn’t defined in the map $config´"
}
}
}
.theme-light .m-button {
background: #f2f2f2;
color: #000;
}
.theme-dark .m-button {
background: #666;
color: #fff;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment