UNPKG

@nex-ui/system

Version:

A lightweight and performant styling library based on Emotion, focusing on component architecture and developer experience.

15 lines (12 loc) 478 B
'use strict'; 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); }; exports.multiply = multiply; exports.negate = negate;