REM Function - updating function to allow for multiple values to be pased in single arguement
This commit is contained in:
parent
b3bc167898
commit
0a08aa84df
@ -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;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
Loading…
Reference in New Issue
Block a user