-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
27 lines (24 loc) · 875 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
var postcss = require('postcss');
module.exports = postcss.plugin('postcss-flex-to-table-cell', function (opts) {
opts = opts || {};
var ishasTouch = function (i, prop, value) {
return i.prop === prop && i.value === value
}
// Work with options here
return function (root, result) {
// Transform CSS AST here
root.walkRules(function (rule) {
rule.walkDecls(function (decl) {
var hasTouch = rule.some(function (i) {
return i.prop === 'display' && i.value === 'table'
})
// if (!hasTouch && decl.prop === 'display' && decl.value === 'flex'){
// rule.prepend({ prop: 'display', value: 'table' })
// }
if (decl.prop === 'align-items' && decl.value === 'center') {
rule.after(`${rule.selector} > * {display:table-cell;vertical-align:middle;}`)
}
})
})
};
});