Last active
August 29, 2015 14:01
-
-
Save pizzapanther/66efc58684ad5017c5af to your computer and use it in GitHub Desktop.
Less for each loop for theme building
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
| // .for | |
| .for(@i, @n) {.-each(@i)} | |
| .for(@n) when (isnumber(@n)) {.for(1, @n)} | |
| .for(@i, @n) when not (@i = @n) { | |
| .for((@i + (@n - @i) / abs(@n - @i)), @n); | |
| } | |
| // .for-each | |
| .for(@array) when (default()) {.for-impl_(length(@array))} | |
| .for-impl_(@i) when (@i > 1) {.for-impl_((@i - 1))} | |
| .for-impl_(@i) {.-each(extract(@array, @i))} | |
| // ............................................................ | |
| .theme(textmate) { | |
| @bg: #dcdcdc; | |
| @fg: #333; | |
| } | |
| .theme(terminal) { | |
| @bg: #000; | |
| @fg: #fff; | |
| } | |
| @themes: 'textmate', 'terminal'; | |
| body { | |
| .for(@themes); .-each(@color) { | |
| @name: e(@color); | |
| &.@{name} { | |
| .theme(@name); | |
| color: @fg; | |
| background-color: @bg; | |
| } | |
| } | |
| } | |
| /* Output | |
| body.textmate { | |
| color: #333333; | |
| background-color: #dcdcdc; | |
| } | |
| body.terminal { | |
| color: #ffffff; | |
| background-color: #000000; | |
| } | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment