UNPKG

style-dictionary-utils

Version:
23 lines (22 loc) 962 B
import { isBorderFilter } from '../filter/isBorder.js'; import { getValue } from '../utilities/getValue.js'; import { dimensionValueTransformer } from './dimension-css.js'; import { colorValueTransformer } from './color-css.js'; /** * @description convert a w3c `border` token to a value that can be used with the css `border` property */ export const borderCss = { name: 'w3c-border/css', type: `value`, transitive: true, filter: isBorderFilter, transform: (token, platform) => { // get the token value const tokenValue = getValue(token); // check for valid style proeprty if (typeof tokenValue.style !== 'string') throw new Error('Only string stroke styles are supported for border tokens'); // return token as css border value return `${dimensionValueTransformer(tokenValue.width, platform)} ${tokenValue.style} ${colorValueTransformer(tokenValue.color, platform)}`; }, };