Files
Parsons/style-dictionary/config.js
Richie 9b75aa7ef3 Normalize organisms, PaymentStep feedback, cross-page spacing fix
- Organism normalize pass: fix FuneralFinderV3 transition timing
  (200ms → 150ms ease-in-out), add autodocs tag to V3 stories
- Navigation: fix logo a11y — div with role="link" → proper <a> tag
- ToggleButtonGroup: add align (start/center) and direction (row/column)
  props, bump description text from text.secondary to text.primary
- PaymentStep: divider under subheading, lock icon alignment, centre-
  aligned payment options, vertical payment method stack, checkbox align
- SummaryStep: save button → text variant (matches other pages), centred
- All wizard pages: heading mb: 1 → mb: 2 for better breathing room
- Style Dictionary: auto-generate tokens.d.ts, fix TS unused imports
- tokens.d.ts: generated type declarations for 398 token exports

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-31 14:13:40 +11:00

76 lines
2.0 KiB
JavaScript

/**
* Style Dictionary configuration for FA Design System (v4)
*
* Transforms W3C DTCG token JSON into:
* - CSS custom properties (for runtime theming)
* - JavaScript ES6 module (for MUI theme consumption)
* - JSON (for Penpot import)
*/
import StyleDictionary from 'style-dictionary';
const sd = new StyleDictionary({
source: ['tokens/**/*.json'],
usesDtcg: true,
platforms: {
// CSS custom properties
css: {
transformGroup: 'css',
prefix: 'fa',
buildPath: 'src/theme/generated/',
files: [{
destination: 'tokens.css',
format: 'css/variables',
options: {
outputReferences: true,
},
}],
},
// JavaScript ES6 module for MUI theme
js: {
transformGroup: 'js',
buildPath: 'src/theme/generated/',
files: [{
destination: 'tokens.js',
format: 'javascript/es6',
}],
},
// Flat JSON for Penpot import and other tools
json: {
transformGroup: 'js',
buildPath: 'tokens/export/',
files: [{
destination: 'tokens-flat.json',
format: 'json/flat',
}],
},
},
});
await sd.buildAllPlatforms();
// Generate TypeScript declarations for the JS token output
import { readFileSync, writeFileSync } from 'fs';
const jsPath = 'src/theme/generated/tokens.js';
const dtsPath = 'src/theme/generated/tokens.d.ts';
const jsContent = readFileSync(jsPath, 'utf-8')
.replace(/=\n\s+/g, '= '); // join continuation lines
const declarations = ['/**', ' * Do not edit directly, this file was auto-generated.', ' */'];
for (const line of jsContent.split('\n')) {
const m = line.match(/^export const (\w+)\s*=\s*(.+?)\s*;/);
if (!m) continue;
const [, name, val] = m;
const isNum = !val.startsWith('"') && !val.startsWith("'") && !isNaN(Number(val));
declarations.push(`export declare const ${name}: ${isNum ? 'number' : 'string'};`);
}
writeFileSync(dtsPath, declarations.join('\n') + '\n');
console.log(`✓ Generated ${declarations.length - 3} TypeScript declarations`);