-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
22 lines (21 loc) · 876 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
var postcss = require('postcss');
module.exports = postcss.plugin('postcss-fontsize', opts => {
opts = opts || {};
return function (css) {
var options = {};
options.fallback = opts.fallback !== undefined ? opts.fallback : false;
css.walkDecls('fontsize', decl => {
let sizeValue = decl.value;
let lhValue = decl.value * 1.5;
let fontREM = sizeValue / 16;
let lhREM = lhValue / 16;
if (options.fallback) {
decl.before({ prop: 'font-size', value: sizeValue + 'px' });
decl.before({ prop: 'line-height', value: lhValue + 'px' });
}
decl.before({ prop: 'font-size', value: fontREM + 'rem' });
decl.before({ prop: 'line-height', value: lhREM + 'rem' });
decl.remove();
});
};
});