| 1 |
@function shift($list) { |
| 2 |
@if length($list) == 1 { @return (); } |
| 3 |
|
| 4 |
$new: (); |
| 5 |
@for $i from 2 through length($list) { |
| 6 |
$new: append($new, nth($list, $i)); |
| 7 |
} |
| 8 |
@return $new; |
| 9 |
} |
| 10 |
|
| 11 |
@mixin media($medias...) { |
| 12 |
@if length($medias) == 0 { |
| 13 |
@content; |
| 14 |
} @else { |
| 15 |
@media #{nth($medias, 1)} { |
| 16 |
@include media(shift($medias)...) { |
| 17 |
@content; |
| 18 |
} |
| 19 |
} |
| 20 |
} |
| 21 |
} |
| 22 |
|
| 23 |
.foo { |
| 24 |
@include media('only screen', '(color)', '(orientation: portrait)') { |
| 25 |
content: bar; |
| 26 |
} |
| 27 |
} |
| 28 |
|
| 29 |
@include media('all', '(min-width: 42em)') { |
| 30 |
.foo { |
| 31 |
content: bar; |
| 32 |
} |
| 33 |
} |