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', () => {
6464 ` )
6565} )
6666
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+
67117test . only ( 'the container can be centered by default' , ( ) => {
68118 const { components } = processPlugins (
69119 [ container ( ) ] ,
Original file line number Diff line number Diff line change @@ -26,15 +26,19 @@ module.exports = function() {
2626 return function ( { addComponents, theme } ) {
2727 const minWidths = extractMinWidths ( theme ( 'container.screens' , theme ( 'screens' ) ) )
2828
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+ } ,
3438 } ,
35- } ,
36- }
37- } )
39+ }
40+ } )
41+ . value ( )
3842
3943 addComponents ( [
4044 {
You can’t perform that action at this time.
0 commit comments