Created
April 6, 2016 13:02
-
-
Save morganfeeney/0d671812cbb8f23d94a6da59bf63dce4 to your computer and use it in GitHub Desktop.
This file contains 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
@icon-pos: before, right; | |
@icon-pos-override: after, left; | |
@icon-position: extract(@icon-pos, 1); | |
@icon-offset: extract(@icon-pos, 2); | |
@icon-position-override: extract(@icon-pos-override, 1); | |
@icon-offset-override: extract(@icon-pos-override, 2); | |
// Icons | |
@oneIcon: "\f110"; | |
@twoIcon: "\f015"; | |
@iconsList: ~"oneIcon" ~"twoIcon"; | |
// ............................................................ | |
// .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) when (@i > 0) {.-each(extract(@array, @i))} | |
/* Base icon styles to be extended */ | |
.base-icon { | |
font-size: inherit; | |
text-rendering: auto; | |
display: inline-block; | |
-moz-osx-font-smoothing: grayscale; | |
-webkit-font-smoothing: antialiased; | |
} | |
.create-icon-content(@content) { | |
content: @content; | |
} | |
// Icon mixins | |
.create-icon-base (){ | |
&:extend(.base-icon); | |
} | |
.icon-mixin (@icon-pos: @icon-pos; @content: ""; @color: '#000'; @margin: 6px){ | |
&:@{icon-position} { | |
margin-@{icon-offset}:@margin; | |
content: @content; | |
} | |
} | |
.test-single-btn { | |
.icon-mixin() | |
} | |
.test-single-alert { | |
.icon-mixin(@icon-pos: @icon-pos-override) | |
} | |
.icon-builder(@list: @iconsList; @icon-pos: @icon-pos; @margin: 6px){ | |
&:@{icon-position} { | |
.create-icon-base(); | |
margin-@{icon-offset}:@margin; | |
} | |
.for(@list); .-each(@name) { | |
&-@{name}:@{icon-position} { | |
.create-icon-content(@@name); | |
} | |
} | |
} | |
.btn { | |
.icon-builder(@iconsList); | |
} | |
.alert { | |
.icon-builder(@icon-pos: @icon-pos-override; @iconsList); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment