Skip to content

Commit a8b1f93

Browse files
author
AMJones
committed
Allows nested media query conditions (list of lists).
1 parent 31ebe51 commit a8b1f93

1 file changed

Lines changed: 24 additions & 19 deletions

File tree

scss/_rwd-functions.scss

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -143,27 +143,32 @@
143143
@function media-condition($conditions...) {
144144
$compiled-list: ();
145145
@for $i from 1 through length($conditions) {
146-
$condition: unquote(quote(nth($conditions,$i)));
147-
// Basic String Conditions
148-
@if map-has-key($condition-map, $condition) {
149-
$pre: map-get($condition-map,$condition);
150-
@if(type-of($pre) == list) {
151-
@for $ii from 1 through length($pre) {
152-
$part: unquote(quote(nth($pre,$ii)));
153-
$compiled-list: append( $compiled-list, $part, comma );
154-
}
155-
} @else {
156-
$compiled-list: append( $compiled-list, map-get( $condition-map,$condition ), comma );
157-
}
146+
$nth: nth($conditions,$i);
147+
@if(type-of($nth) == list) {
148+
$compiled-list: append($compiled-list, media-condition($nth), comma );
158149
} @else {
159-
$operator: get-expression-operator($condition);
160-
$value: get-expression-value($condition,$operator);
161-
@if map-has-key($grid-breakpoints, $value) {
162-
// Breakpoint Based Conditions
163-
$compiled-list: append($compiled-list, get-breakpoint-string($value, $operator), comma);
150+
$condition: unquote(quote(nth($conditions,$i)));
151+
// Basic String Conditions
152+
@if map-has-key($condition-map, $condition) {
153+
$pre: map-get($condition-map,$condition);
154+
@if(type-of($pre) == list) {
155+
@for $ii from 1 through length($pre) {
156+
$part: unquote(quote(nth($pre,$ii)));
157+
$compiled-list: append( $compiled-list, $part, comma );
158+
}
159+
} @else {
160+
$compiled-list: append( $compiled-list, map-get( $condition-map,$condition ), comma );
161+
}
164162
} @else {
165-
// Width Based Condition
166-
$compiled-list: append($compiled-list, get-width-string($operator,$value,$value), comma );
163+
$operator: get-expression-operator($condition);
164+
$value: get-expression-value($condition,$operator);
165+
@if map-has-key($grid-breakpoints, $value) {
166+
// Breakpoint Based Conditions
167+
$compiled-list: append($compiled-list, get-breakpoint-string($value, $operator), comma);
168+
} @else {
169+
// Width Based Condition
170+
$compiled-list: append($compiled-list, get-width-string($operator,$value,$value), comma );
171+
}
167172
}
168173
}
169174
}

0 commit comments

Comments
 (0)