Skip to content

Commit fefc53b

Browse files
committed
Reintroduce ability for screens to be passed explicitly
1 parent c6449f8 commit fefc53b

File tree

2 files changed

+29
-11
lines changed

2 files changed

+29
-11
lines changed

__tests__/containerPlugin.test.js

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,29 @@ test.only('options are not required', () => {
4141
`)
4242
})
4343

44+
test.only('screens can be passed explicitly', () => {
45+
const { components } = processPlugins(
46+
[container()],
47+
config({
48+
theme: {
49+
container: {
50+
screens: ['400px', '500px'],
51+
},
52+
},
53+
})
54+
)
55+
56+
expect(css(components)).toMatchCss(`
57+
.container { width: 100% }
58+
@media (min-width: 400px) {
59+
.container { max-width: 400px }
60+
}
61+
@media (min-width: 500px) {
62+
.container { max-width: 500px }
63+
}
64+
`)
65+
})
66+
4467
test.only('the container can be centered by default', () => {
4568
const { components } = processPlugins(
4669
[container()],
@@ -113,6 +136,7 @@ test.only('setting all options at once', () => {
113136
config({
114137
theme: {
115138
container: {
139+
screens: ['400px', '500px'],
116140
center: true,
117141
padding: '2rem',
118142
},
@@ -128,17 +152,11 @@ test.only('setting all options at once', () => {
128152
padding-right: 2rem;
129153
padding-left: 2rem
130154
}
131-
@media (min-width: 576px) {
132-
.container { max-width: 576px }
155+
@media (min-width: 400px) {
156+
.container { max-width: 400px }
133157
}
134-
@media (min-width: 768px) {
135-
.container { max-width: 768px }
136-
}
137-
@media (min-width: 992px) {
138-
.container { max-width: 992px }
139-
}
140-
@media (min-width: 1200px) {
141-
.container { max-width: 1200px }
158+
@media (min-width: 500px) {
159+
.container { max-width: 500px }
142160
}
143161
`)
144162
})

src/plugins/container.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function extractMinWidths(breakpoints) {
2424

2525
module.exports = function() {
2626
return function({ addComponents, config }) {
27-
const minWidths = extractMinWidths(config('theme.screens'))
27+
const minWidths = extractMinWidths(config('theme.container.screens', config('theme.screens')))
2828

2929
const atRules = _.map(minWidths, minWidth => {
3030
return {

0 commit comments

Comments
 (0)