-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathindex.js
More file actions
31 lines (26 loc) · 736 Bytes
/
index.js
File metadata and controls
31 lines (26 loc) · 736 Bytes
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
28
29
30
31
function processSize (propPrefix, decl, list) {
let sizes = list.space(decl.value)
if (sizes.length === 1) sizes[1] = sizes[0]
decl.cloneBefore({ prop: propPrefix + 'width', value: sizes[0] })
decl.cloneBefore({ prop: propPrefix + 'height', value: sizes[1] })
decl.remove()
}
module.exports = () => {
return {
Declaration: {
'max-size': (decl, { list }) => {
processSize('max-', decl, list)
},
'min-size': (decl, { list }) => {
processSize('min-', decl, list)
},
'size': (decl, { list }) => {
if (decl.parent.name !== 'page') {
processSize('', decl, list)
}
}
},
postcssPlugin: 'postcss-size'
}
}
module.exports.postcss = true