UNPKG

@primer/primitives

Version:

Typography, spacing, and color primitives for Primer design system

24 lines (23 loc) 1.06 kB
import { isCubicBezier } from '../filters/isCubicBezier.js'; /** * @description converts cubicBezeir tokens array value to a css cubic-bezier * @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts) * @matcher matches all tokens of $type `duration` * @transformer returns a css cubic-bezier function */ export const cubicBezierToCss = { name: 'cubicBezeir/css', type: 'value', transitive: true, filter: isCubicBezier, transform: (token, _config) => { var _a; const value = (_a = token.$value) !== null && _a !== void 0 ? _a : token.value; // throw value of more or less than 4 items in array if (value.length !== 4 || value.some((item) => typeof item !== 'number')) { throw new Error(`Invalid cubicBezier token ${token.path.join('.')}, must be an array with 4 numbers, but got this instead: ${JSON.stringify(value)}`); } // return value return `cubic-bezier(${value.join(',')})`; }, };