Last active
August 29, 2015 14:00
-
-
Save yuijim/d8630adbfb40c46b3a58 to your computer and use it in GitHub Desktop.
Example of how to pass selectors to a mixin in LESS
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
.fade-toggle (@openSelector: ~'.open'; @inTransitionClassName: ~'transition-helper'; @openRight: 0; @zIndex: 1) { | |
.transition(opacity .25s ease-in-out); | |
position: absolute; | |
left: -9999em; | |
z-index: @zIndex; | |
opacity: 0; | |
@rls: { | |
left: 0; | |
right: @openRight; | |
}; | |
&.@{inTransitionClassName} { | |
@rls(); | |
} | |
.loop(@counter) when (@counter > 0) { | |
@selector: extract(@openSelector, @counter); | |
@{selector} > & { | |
@rls(); | |
opacity: 1; | |
} | |
.loop((@counter - 1)); | |
} | |
.loop(length(@openSelector)); | |
} | |
.subnav { | |
.fade-toggle(~'li:hover', ~'.open'; @openRight: auto); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment