style-dictionary-utils
Version:
Utilities to use in your style dictionary config
19 lines (18 loc) • 854 B
JavaScript
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)}`;
},
};