joyent-portal/ui/src/shared/functions.js

21 lines
431 B
JavaScript
Raw Normal View History

2016-12-06 13:50:24 +02:00
const calc = require('reduce-css-calc');
module.exports = {
remcalc: function(values) {
2016-10-28 18:39:35 +03:00
values = values.replace('px', '').split(' ');
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})`);
}
};