@nex-ui/system
Version:
A lightweight and performant styling library based on Emotion, focusing on component architecture and developer experience.
12 lines (10 loc) • 438 B
JavaScript
const toExpression = (operator, ...operands)=>operands.map(String).join(` ${operator} `).replace(/calc/g, '');
const multiply = (...operands)=>`calc(${toExpression('*', ...operands)})`;
const negate = (x)=>{
const value = String(x);
if (value != null && !Number.isNaN(parseFloat(value))) {
return value.startsWith('-') ? value.slice(1) : `-${value}`;
}
return multiply(value, -1);
};
export { multiply, negate };