UNPKG

@primer/primitives

Version:

Typography, spacing, and color primitives for Primer design system

17 lines (16 loc) 794 B
/** * @description converts the [TransformedToken's](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts) `.path` array to a kebab-case string, preserves casing of parts * @type name transformer — [StyleDictionary.NameTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts) * @matcher omitted to match all tokens * @transformer returns `string` kebab-case */ export const namePathToKebabCase = { name: 'name/pathToKebabCase', type: 'name', transform: (token, options) => { return ([options === null || options === void 0 ? void 0 : options.prefix, ...token.path] // remove undefined if exists .filter((part) => typeof part === 'string' && part !== '@') .join('-')); }, };