Created
September 3, 2015 13:42
-
-
Save asvny/4d733d54e53ef5e62cf7 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ---- | |
// 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´" | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.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