File tree Expand file tree Collapse file tree 2 files changed +62
-8
lines changed Expand file tree Collapse file tree 2 files changed +62
-8
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,56 @@ test.only('screens can be passed explicitly', () => {
64
64
` )
65
65
} )
66
66
67
+ test . only ( 'screens are ordered ascending by min-width' , ( ) => {
68
+ const { components } = processPlugins (
69
+ [ container ( ) ] ,
70
+ config ( {
71
+ theme : {
72
+ container : {
73
+ screens : [ '500px' , '400px' ] ,
74
+ } ,
75
+ } ,
76
+ } )
77
+ )
78
+
79
+ expect ( css ( components ) ) . toMatchCss ( `
80
+ .container { width: 100% }
81
+ @media (min-width: 400px) {
82
+ .container { max-width: 400px }
83
+ }
84
+ @media (min-width: 500px) {
85
+ .container { max-width: 500px }
86
+ }
87
+ ` )
88
+ } )
89
+
90
+ test . only ( 'screens are deduplicated by min-width' , ( ) => {
91
+ const { components } = processPlugins (
92
+ [ container ( ) ] ,
93
+ config ( {
94
+ theme : {
95
+ container : {
96
+ screens : {
97
+ sm : '576px' ,
98
+ md : '768px' ,
99
+ 'sm-only' : { min : '576px' , max : '767px' } ,
100
+ } ,
101
+ } ,
102
+ } ,
103
+ } )
104
+ )
105
+
106
+ expect ( css ( components ) ) . toMatchCss ( `
107
+ .container { width: 100% }
108
+ @media (min-width: 576px) {
109
+ .container { max-width: 576px }
110
+ }
111
+ @media (min-width: 768px) {
112
+ .container { max-width: 768px }
113
+ }
114
+ ` )
115
+ } )
116
+
67
117
test . only ( 'the container can be centered by default' , ( ) => {
68
118
const { components } = processPlugins (
69
119
[ container ( ) ] ,
Original file line number Diff line number Diff line change @@ -26,15 +26,19 @@ module.exports = function() {
26
26
return function ( { addComponents, theme } ) {
27
27
const minWidths = extractMinWidths ( theme ( 'container.screens' , theme ( 'screens' ) ) )
28
28
29
- const atRules = _ . map ( minWidths , minWidth => {
30
- return {
31
- [ `@media (min-width: ${ minWidth } )` ] : {
32
- '.container' : {
33
- 'max-width' : minWidth ,
29
+ const atRules = _ ( minWidths )
30
+ . sortBy ( minWidth => parseInt ( minWidth ) )
31
+ . sortedUniq ( )
32
+ . map ( minWidth => {
33
+ return {
34
+ [ `@media (min-width: ${ minWidth } )` ] : {
35
+ '.container' : {
36
+ 'max-width' : minWidth ,
37
+ } ,
34
38
} ,
35
- } ,
36
- }
37
- } )
39
+ }
40
+ } )
41
+ . value ( )
38
42
39
43
addComponents ( [
40
44
{
You can’t perform that action at this time.
0 commit comments