Last active
September 28, 2015 12:04
-
-
Save finikwashere/30917ad7fe8faeac211f to your computer and use it in GitHub Desktop.
Iterate through arguments in a 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
.thisGuyWithStates { | |
display: block; | |
background-color: black; | |
color: white; | |
} | |
.thisGuyWithStates:hover { | |
background-color: red; | |
} | |
.thisGuyWithStates:not(.state1, .state2):hover { | |
background-color: pink; | |
} | |
.thisGuyWithStates.state3:hover { | |
background-color: green; | |
} |
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
// ---- | |
// libsass (v3.2.5) | |
// ---- | |
@mixin notSelectHover($args...){ | |
$selectors: (); | |
@each $arg in $args { | |
$selectors: append($selectors, unquote('#{$arg}'), comma); | |
} | |
&:not(#{$selectors}):hover { | |
@content; | |
} | |
} | |
.thisGuyWithStates { | |
display:block; | |
background-color: black; | |
color: white; | |
&:hover { | |
background-color: red; | |
} | |
@include notClassHover('.state1', '.state2') { | |
background-color: pink; | |
} | |
&.state3:hover { | |
background-color: green; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
An example of simple iteration through mixin arguments which are selectors (classes)