Last active
August 29, 2015 14:17
-
-
Save davidDuymelinck/d4fd0a3baee85dfee9b5 to your computer and use it in GitHub Desktop.
sass vs less
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
.quanty-query(@number, @comparison, @content) when (@comparison = 'greater'), (@comparison = 'more'), (@comparison = '>'){ | |
&:nth-last-child(n @{number}):first-child { | |
&, | |
& ~ * { | |
@content(); | |
} | |
} | |
} | |
.quanty-query(@number, @comparison, @content) when (@comparison = 'fewer'), (@comparison = 'less'), (@comparison = '<'){ | |
&:nth-last-child(-n @{number}):first-child { | |
&, | |
& ~ * { | |
@content(); | |
} | |
} | |
} | |
.quanty-query(@number, @comparison, @content) when (default()){ | |
&:nth-last-child(@{number}):first-child { | |
&, | |
& ~ * { | |
@content(); | |
} | |
} | |
} |
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
@mixin quantity-query( $number, $comparison: 'equal' ) { | |
@if index( ('greater' 'more' '>'), $comparison ) { | |
$nth: 'n + #{$number}'; | |
} @else if index( ('less' 'fewer' '<'), $comparison ) { | |
$nth: '-n + #{$number}'; | |
} @else if index( ('equal' 'same' '='), $comparison ) { | |
$nth: $number; | |
} @else { | |
@warn "Sorry, that’s an invalid $comparison value." | |
} | |
&:nth-last-child(#{$nth}):first-child { | |
&, | |
& ~ * { | |
@content; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment