UNPKG

style-dictionary-utils

Version:
19 lines (18 loc) 854 B
import { isTypographyFilter } from '../filter/isTypography.js'; import { getValue } from '../utilities/getValue.js'; import { dimensionValueTransformer } from './dimension-css.js'; import { fontWeightValueTransformer } from './fontWeight-css.js'; import { fontFamilyValueTransformer } from './fontFamily-css.js'; /** * @description convert a w3c `typography` token to a value that can be used with the css `font` property */ export const typographyCss = { name: 'typography/css', type: `value`, transitive: true, filter: isTypographyFilter, transform: (token, platform) => { const { fontWeight, fontSize, lineHeight, fontFamily } = getValue(token); return `${fontWeightValueTransformer(fontWeight)} ${dimensionValueTransformer(fontSize, platform)}/${lineHeight} ${fontFamilyValueTransformer(fontFamily)}`; }, };