Skip to content

Commit 074860e

Browse files
committed
Sort media queries. Fixes #577
1 parent 2e2677e commit 074860e

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

packages/css/src/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,10 @@ const responsive = styles => theme => {
166166
}
167167
for (let i = 0; i < value.slice(0, mediaQueries.length).length; i++) {
168168
const media = mediaQueries[i]
169-
if (value[i] == null) continue
169+
if (value[i] == null) {
170+
next[media] = {}
171+
continue
172+
}
170173
if (!media) {
171174
next[key] = value[i]
172175
continue

packages/css/test/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ test('skip breakpoints', () => {
263263
})(theme)
264264
expect(result).toEqual({
265265
width: '100%',
266+
'@media screen and (min-width: 40em)': {},
266267
'@media screen and (min-width: 52em)': {
267268
width: '50%',
268269
},
@@ -415,19 +416,19 @@ test('returns correct media query order', () => {
415416
const keys = Object.keys(result)
416417
expect(keys).toEqual([
417418
'width',
418-
'color',
419419
'@media screen and (min-width: 40em)',
420420
'@media screen and (min-width: 52em)',
421+
'color',
421422
])
422423
expect(result).toEqual({
423424
width: '100%',
424-
color: 'red',
425425
'@media screen and (min-width: 40em)': {
426426
color: 'green',
427427
},
428428
'@media screen and (min-width: 52em)': {
429429
width: '50%',
430430
color: 'blue',
431431
},
432+
color: 'red',
432433
})
433434
})

0 commit comments

Comments
 (0)