Last active
August 29, 2015 14:23
-
-
Save anatomic/fc2e9739b2041910eadf 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) | |
| // ---- | |
| // Our project defines some themes | |
| $themes: ( | |
| foo: ( | |
| foreground: #5b5b5b, | |
| background: #f3f3f3 | |
| ) | |
| ); | |
| // Our library also defines some themes | |
| $libraryThemes: ( | |
| foo: ( | |
| foreground: #ccc, | |
| background: #3b3b3b | |
| ), | |
| bar: ( | |
| foreground: #ccc, | |
| background: #3b3b3b | |
| ), | |
| ); | |
| // Our library checks to see if there any priority themes to use | |
| @if (variable-exists(themes)) { | |
| // if some exist, merge with the library giving the project themes priority | |
| $themes: map-merge($libraryThemes, $themes); | |
| } @else { | |
| // if there aren't, just use the library themes | |
| $themes: $libraryThemes; | |
| } | |
| // Now, how do we automate the production of themes in a centralised file? | |
| $themeMixins: ()!default; | |
| @mixin button-theme($name) { | |
| $theme: map-get($themes, $name); | |
| .btn-t-#{$name} { | |
| color: map-get($theme, foreground); | |
| background-color: map-get($theme, background); | |
| } | |
| } | |
| // add this mixin to our list | |
| $themeMixins: append($themeMixins, button-theme); | |
| @each $mixin in $themeMixins { | |
| @each $name in map-keys($themes) { | |
| test: call($mixin, $name); | |
| .debug { | |
| mixin: inspect($mixin); | |
| theme: inspect($name); | |
| } | |
| } | |
| } | |
| .debug{ | |
| themes: inspect($themeMixins); | |
| } |
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
| test: button-theme(foo); | |
| .debug { | |
| mixin: button-theme; | |
| theme: foo; | |
| } | |
| test: button-theme(bar); | |
| .debug { | |
| mixin: button-theme; | |
| theme: bar; | |
| } | |
| .debug { | |
| themes: button-theme; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment