import type { Token } from 'style-dictionary' import type { NameTransform } from 'style-dictionary/types' import { prefixTransform } from '../utils/prefix-transform' type Transformer = NameTransform['transform'] export function filter(token: Token): boolean { return token.attributes?.category === 'grid' } export const tailwindGridTokenNameTransform: Transformer = (token, config) => { if (!token.attributes) { return token.name } const { category, type, item, subitem } = token.attributes as Record< string, string > let name = String(category) if (type) name += `-${type}` if (subitem) name += `-${subitem}` if (item) name += `--${item}` return name } export const transform = prefixTransform(tailwindGridTokenNameTransform)