-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
27 lines (21 loc) · 819 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const postcss = require('postcss')
const getLightLevelAndParams = require('./lib/get-light-level-and-params')
const getMediaQueryFunction = require('./lib/get-media-query-function')
module.exports = postcss.plugin('postcss-light-levels', options => {
/* eslint-disable-next-line */
let prefix = (options && options.prefix) || ".light-level-";
if (typeof prefix !== 'string') {
throw new Error('prefix option must be a string')
}
return root => {
root.walkAtRules('media', atRule => {
// Don't bother parsing other media queries
if (!atRule.params.includes('light-level')) return
let obj = getLightLevelAndParams(atRule)
if (obj.mediaType) {
getMediaQueryFunction(obj.mediaType)(atRule, obj, root, prefix)
}
})
/* eslint-disable-next-line */
};
})