* add normalizeScreens function This will allow us to normalize the various kinds of inputs to a stable version that is consistent regardless of the input. * use normalized screens * add dedicated test for new tuple syntax * make test consistent with other tests While working on the normalizeScreens feature, some tests started failing (the one with multiple screens), while looking at them I made them consistent with the rest of the codebase. * add test to ensure consistent order in screens output * update changelog * Update CHANGELOG.md * Update CHANGELOG.md Co-authored-by: Adam Wathan <adam.wathan@gmail.com>
19 lines
600 B
JavaScript
19 lines
600 B
JavaScript
import { normalizeScreens } from '../util/normalizeScreens'
|
|
import buildMediaQuery from '../util/buildMediaQuery'
|
|
|
|
export default function ({ tailwindConfig: { theme } }) {
|
|
return function (css) {
|
|
css.walkAtRules('screen', (atRule) => {
|
|
let screen = atRule.params
|
|
let screens = normalizeScreens(theme.screens)
|
|
let screenDefinition = screens.find(({ name }) => name === screen)
|
|
|
|
if (!screenDefinition) {
|
|
throw atRule.error(`No \`${screen}\` screen found.`)
|
|
}
|
|
|
|
atRule.name = 'media'
|
|
atRule.params = buildMediaQuery(screenDefinition)
|
|
})
|
|
}
|
|
}
|