@primer/primitives
Version:
Typography, spacing, and color primitives for Primer design system
17 lines (16 loc) • 786 B
JavaScript
/**
* @description converts the [TransformedToken's](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts) `.path` array to a slash/notation string
* @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` on slash/notation
*/
export const namePathToSlashNotation = {
name: 'name/pathToSlashNotation',
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('/'));
},
};