UNPKG

style-dictionary-utils

Version:
19 lines (18 loc) 719 B
import { isGradientFilter } from '../filter/isGradient.js'; import { getValue } from '../utilities/getValue.js'; import { colorValueTransformer } from './color-css.js'; export const gradientCss = { name: 'gradient/css', type: `value`, transitive: true, filter: isGradientFilter, transform: (token, platform) => { const tokenValue = getValue(token); // combine stops to string const stops = tokenValue .map((stop) => `${colorValueTransformer(stop.color, platform)}${stop.position ? ` ${Math.floor(stop.position * 100)}%` : ''}`) .join(', '); // return gradient value return `${token.angle ? `${token.angle}, ` : ''}${stops}`; }, };