tailwindcss/src/lib/substituteScreenAtRules.js

20 lines
464 B
JavaScript
Raw Normal View History

2017-10-05 20:20:43 -04:00
import _ from 'lodash'
2017-10-06 10:09:37 -04:00
import buildMediaQuery from '../util/buildMediaQuery'
2017-10-05 20:20:43 -04:00
export default function(config) {
2017-10-05 20:20:43 -04:00
return function(css) {
const options = config()
2017-10-05 20:20:43 -04:00
css.walkAtRules('screen', atRule => {
const screen = atRule.params
2017-10-05 20:20:43 -04:00
if (!_.has(options.screens, screen)) {
throw atRule.error(`No \`${screen}\` screen found.`)
2017-10-05 20:20:43 -04:00
}
atRule.name = 'media'
atRule.params = buildMediaQuery(options.screens[screen])
2017-10-05 20:20:43 -04:00
})
}
}