Skip to content

Commit

Permalink
Refactor container plugin to CSS-in-JS
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwathan committed Mar 12, 2018
1 parent 6e7ae58 commit 088cdc9
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions src/plugins/container.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/* eslint-disable no-shadow */
import _ from 'lodash'
import postcss from 'postcss'
import defineClass from '../util/defineClass'

function extractMinWidths(breakpoints) {
return _.flatMap(breakpoints, breakpoints => {
Expand Down Expand Up @@ -31,22 +29,21 @@ module.exports = function(options) {
const minWidths = extractMinWidths(screens)

const atRules = _.map(minWidths, minWidth => {
const atRule = postcss.atRule({
name: 'media',
params: `(min-width: ${minWidth})`,
})
atRule.append(
defineClass('container', {
'max-width': minWidth,
})
)
return atRule
return {
[`@media (min-width: ${minWidth})`]: {
'.container': {
'max-width': minWidth,
},
},
}
})

addComponents([
defineClass('container', {
width: '100%',
}),
{
'.container': {
width: '100%',
},
},
...atRules,
])
}
Expand Down

0 comments on commit 088cdc9

Please sign in to comment.