import { specifyErrors, SpecifyError } from '../../../errors/index.js'; import { TokenState } from '@specifyapp/specify-design-token-format'; const TYPE_MAPPING: { [key in TokenState['type']]?: string } = { bitmap: 'backgroundImage', blur: 'blur', // Composite token: Type is generated by the converter border: undefined, breakpoint: 'breakpoint', color: 'colors', cubicBezier: 'transitionTimingFunction', duration: 'transitionDuration', dimension: 'spacing', // Composite token: Type is generated by the converter font: undefined, fontFamily: 'fontFamily', fontWeight: 'fontWeight', gradient: 'backgroundImage', gradients: 'backgroundImage', opacity: 'opacity', radii: 'borderRadius', radius: 'borderRadius', shadow: 'dropShadow', shadows: 'dropShadow', spacing: 'spacing', spacings: 'spacing', stepsTimingFunction: 'transitionTimingFunction', // Composite token: Type is generated by the converter textStyle: undefined, // Composite token: Type is generated by the converter transition: undefined, vector: 'backgroundImage', zIndex: 'zIndex', }; export function tokenTypeToTailwind(type: TokenState['type']): string { const tailwindType = TYPE_MAPPING[type]; if (!tailwindType) throw new SpecifyError({ errorKey: specifyErrors.PARSERS_ENGINE_UNKNOWN_ERROR.errorKey, publicMessage: `Failed to map SDTF type: '${type}' to tailwind type`, }); return tailwindType; }