An open source design system that's fully customizable and agent ready
TypeScript
fix(cli): remove stale Tailwind preset output from theme build (#747)
Cindy Zhang9e07d7a0bb84
diff --git a/packages/cli/src/commands/build-theme.mjs b/packages/cli/src/commands/build-theme.mjsindex b70615fc00..55be4c25aa 100644--- a/packages/cli/src/commands/build-theme.mjs+++ b/packages/cli/src/commands/build-theme.mjs@@ -254,113 +254,6 @@ function generateProseCSS(themeDef) {return `@scope (${scopeSelector}) to ([data-xds-theme]) {\n${inner}\n}`;}-// =============================================================================-// Tailwind preset generation-// =============================================================================--/**- * Generate a Tailwind CSS preset that maps XDS tokens to CSS variable references.- */-function generateTailwindPreset(themeDef) {- // Categorize tokens by prefix- const colors = {};- const spacing = {};- const borderRadius = {};- const fontSize = {};- const fontFamily = {};- const fontWeight = {};- const boxShadow = {};- const transitionDuration = {};-- // Collect all tokens (overrides + defaults we know about)- const allTokenNames = [- // Colors- 'accent', 'accent-deemphasized', 'accent-text',- 'surface', 'wash', 'card', 'popover', 'navbar',- 'text-primary', 'text-secondary', 'text-disabled', 'text-link', 'text-placeholder',- 'icon-primary', 'icon-secondary', 'icon-tertiary', 'icon-disabled',- 'divider', 'divider-high-contrast', 'divider-emphasized',- 'positive', 'positive-deemphasized', 'negative', 'negative-deemphasized',- 'warning', 'warning-deemphasized', 'educational', 'educational-deemphasized',- 'hover-overlay', 'pressed-overlay', 'focus-outline', 'deemphasized',- 'disabled-overlay', 'overlay',- ];-- for (const name of allTokenNames) {- colors[name] = `var(--color-${name})`;- }-- // Spacing- for (const n of [0, '0-5', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) {- spacing[n] = `var(--spacing-${n})`;- }-- // Radius- borderRadius['2'] = 'var(--radius-2)';- borderRadius['3'] = 'var(--radius-3)';- borderRadius['1'] = 'var(--radius-1)';- borderRadius['0'] = 'var(--radius-0)';- borderRadius['rounded'] = 'var(--radius-rounded)';-- // Font size- for (const size of ['4xl', '3xl', '2xl', 'xl', 'lg', 'base', 'sm', 'xsm']) {- fontSize[size] = `var(--text-${size})`;- }-- // Font family- fontFamily['heading'] = 'var(--font-heading)';- fontFamily['body'] = 'var(--font-body)';- fontFamily['code'] = 'var(--font-code)';-- // Font weight- fontWeight['normal'] = 'var(--font-weight-normal)';- fontWeight['medium'] = 'var(--font-weight-medium)';- fontWeight['semibold'] = 'var(--font-weight-semibold)';- fontWeight['bold'] = 'var(--font-weight-bold)';-- // Elevation- boxShadow['sm'] = 'var(--shadow-sm)';- boxShadow['md'] = 'var(--shadow-md)';- boxShadow['lg'] = 'var(--shadow-lg)';-- // Transitions- transitionDuration['fast'] = 'var(--transition-fast)';- transitionDuration['normal'] = 'var(--transition-normal)';- transitionDuration['slow'] = 'var(--transition-slow)';-- // Size tokens (component heights)- spacing['size-sm'] = 'var(--size-sm)';- spacing['size-md'] = 'var(--size-md)';- spacing['size-lg'] = 'var(--size-lg)';-- return `/**- * XDS Tailwind Preset — ${themeDef.name} theme- * Generated by \`npx xds theme build --tailwind\`- *- * Usage in tailwind.config.js:- * import { xdsPreset } from './${themeDef.name}.tailwind';- * export default { presets: [xdsPreset] };- *- * Then use XDS tokens in Tailwind classes:- * <div className="bg-surface text-text-primary p-4 rounded-container">- */-export const xdsPreset = {- theme: {- extend: {- colors: ${JSON.stringify(colors, null, 6).replace(/\n/g, '\n ')},- spacing: ${JSON.stringify(spacing, null, 6).replace(/\n/g, '\n ')},- borderRadius: ${JSON.stringify(borderRadius, null, 6).replace(/\n/g, '\n ')},- fontSize: ${JSON.stringify(fontSize, null, 6).replace(/\n/g, '\n ')},- fontFamily: ${JSON.stringify(fontFamily, null, 6).replace(/\n/g, '\n ')},- fontWeight: ${JSON.stringify(fontWeight, null, 6).replace(/\n/g, '\n ')},- boxShadow: ${JSON.stringify(boxShadow, null, 6).replace(/\n/g, '\n ')},- transitionDuration: ${JSON.stringify(transitionDuration, null, 6).replace(/\n/g, '\n ')},- },- },-};-`;-}-/*** Extract the theme definition from a JS/TS file by evaluating it.* We look for the defineTheme() call and extract its argument.@@ -617,7 +510,6 @@ export function registerTheme(program) {.description('Compile a defineTheme file to CSS + JS').option('-o, --out <path>', 'Output CSS file path').option('--no-prose', 'Skip prose mappings (h1, p, code, hr, etc.)')- .option('--tailwind', 'Generate a Tailwind CSS preset file').action(async (file, options) => {const filePath = path.resolve(process.cwd(), file);@@ -724,13 +616,6 @@ export function registerTheme(program) {console.log(`✓ ${path.relative(process.cwd(), jsPath)}`);console.log(`✓ ${path.relative(process.cwd(), dtsPath)}`);- // Generate Tailwind preset if requested- if (options.tailwind) {- const twPath = path.join(outDir, `${baseName}.tailwind.js`);- fs.writeFileSync(twPath, generateTailwindPreset(themeDef));- console.log(`✓ ${path.relative(process.cwd(), twPath)}`);- }-// Print install instructionsconst relDir = path.relative(process.cwd(), outDir);const exportName = `${toIdentifier(baseName)}Theme`;