Last active
August 16, 2018 08:37
-
-
Save hc2p/5c091269e5cb902770e2 to your computer and use it in GitHub Desktop.
dry icon mixin
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
$icons: ( | |
follow: 'a', | |
followed: 'b', | |
unfollow: 'c', | |
checkmark: 'e' | |
); | |
$Placeholder-Selectors: (); | |
@mixin icon($name, $color, $extend: true) { | |
@include icon-static($extend); | |
&:before { | |
content: map-get($icons, $name); | |
@if $color { | |
color: $color; | |
} | |
} | |
} | |
@mixin icon-static($extend: true) { | |
$icon-selector: map-get($Placeholder-Selectors, 'icon'); | |
@if $extend == true { | |
@if $icon-selector == null { | |
$icon-selector: unique-id(); | |
$Placeholder-Selectors: map-merge($Placeholder-Selectors, ('icon': $icon-selector)) !global; | |
@at-root %#{$icon-selector} { | |
@include icon-static(false); | |
} | |
} | |
@at-root (without: media){ | |
@extend %#{$icon-selector}; | |
} | |
} | |
@else { | |
&:before { | |
font-family: "iconfont" !important; | |
font-style: normal !important; | |
font-weight: normal !important; | |
font-variant: normal !important; | |
text-transform: none !important; | |
speak: none; | |
line-height: 1; | |
-webkit-font-smoothing: antialiased; | |
-moz-osx-font-smoothing: grayscale; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment