REM Function - updating function to allow for multiple values to be pased in single arguement

This commit is contained in:
Alex Windett 2016-10-27 16:47:03 +01:00
parent b3bc167898
commit 0a08aa84df

View File

@ -17,11 +17,16 @@ const plugins = {
require('postcss-modules-values'),
require('postcss-functions')({
functions: {
remCalc: function(pixels) {
pixels = pixels.replace('px', '');
const baseValue = 16;
const remSize = pixels / baseValue;
return `${remSize}rem`;
remCalc: function(values) {
values = values.replace('px', '');
values = values.split(' ');
let outputRems = '';
const base = 16;
values.forEach( (value, i) => {
const remValue = value / base;
outputRems += i === 0 ? `${remValue}rem` : ` ${remValue}rem`;
});
return outputRems;
}
},
}),