2016-12-06 13:50:24 +02:00
|
|
|
const calc = require('reduce-css-calc');
|
|
|
|
|
2016-10-28 17:14:35 +03:00
|
|
|
module.exports = {
|
2016-11-02 19:34:08 +02:00
|
|
|
remcalc: function(values) {
|
2016-12-08 14:08:04 +02:00
|
|
|
values = values.toString().replace('px', '').split(' ');
|
2016-10-28 17:14:35 +03:00
|
|
|
|
|
|
|
let outputRems = '';
|
|
|
|
const base = 16;
|
|
|
|
|
|
|
|
values.forEach( (value, i) => {
|
|
|
|
const remValue = value / base;
|
|
|
|
outputRems += i === 0 ? `${remValue}rem` : ` ${remValue}rem`;
|
|
|
|
});
|
|
|
|
|
|
|
|
return outputRems;
|
2016-12-06 13:50:24 +02:00
|
|
|
},
|
|
|
|
calc: function(str) {
|
|
|
|
return calc(`calc(${str})`);
|
2016-10-28 17:14:35 +03:00
|
|
|
}
|
|
|
|
};
|