Skip to content

Commit 088cdc9

Browse files
committed
Refactor container plugin to CSS-in-JS
1 parent 6e7ae58 commit 088cdc9

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

src/plugins/container.js

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
/* eslint-disable no-shadow */
22
import _ from 'lodash'
3-
import postcss from 'postcss'
4-
import defineClass from '../util/defineClass'
53

64
function extractMinWidths(breakpoints) {
75
return _.flatMap(breakpoints, breakpoints => {
@@ -31,22 +29,21 @@ module.exports = function(options) {
3129
const minWidths = extractMinWidths(screens)
3230

3331
const atRules = _.map(minWidths, minWidth => {
34-
const atRule = postcss.atRule({
35-
name: 'media',
36-
params: `(min-width: ${minWidth})`,
37-
})
38-
atRule.append(
39-
defineClass('container', {
40-
'max-width': minWidth,
41-
})
42-
)
43-
return atRule
32+
return {
33+
[`@media (min-width: ${minWidth})`]: {
34+
'.container': {
35+
'max-width': minWidth,
36+
},
37+
},
38+
}
4439
})
4540

4641
addComponents([
47-
defineClass('container', {
48-
width: '100%',
49-
}),
42+
{
43+
'.container': {
44+
width: '100%',
45+
},
46+
},
5047
...atRules,
5148
])
5249
}

0 commit comments

Comments
 (0)