1
0
mirror of https://github.com/yldio/copilot.git synced 2024-11-28 14:10:04 +02:00

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