Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return Object.keys(style).reduce((acc, rule) => {
// Transform unitless numbers to pixels
if (typeof style[rule] === 'number') {
if (['lineHeight'].includes(rule)) {
return { ...acc, [rule]: style[rule].toString() };
}
return { ...acc, [rule]: `${style[rule]}px` };
}
// Expand hex colors
if (rule.toLowerCase().includes('color')) {
return { ...acc, [rule]: expandHexColor(style[rule]) };
}
return { ...acc, [rule]: style[rule] };
}, {});
}
.reduce((out, [name, value]) => {
return {
...out,
[camelizeStyleName(name)]: /color/i.test(name)
? expandHexColor(value)
: value,
};
}, {})
);