learning_ai_common_plat/packages/design-tokens/src/index.ts
saravanakumardb1 90b9cf93d8 fix(common): configure ESLint 9 and fix lint issues
- Added @eslint/js dependency
- Updated eslint.config.js for ESLint 9 compatibility
- Added required globals (crypto, localStorage, React, etc.)
- Fixed unused imports and variables
- Disabled sort-imports temporarily
- Formatted all files with Prettier
2026-02-12 16:37:30 -08:00

50 lines
1.5 KiB
TypeScript

/**
* Design tokens — programmatic access to the canonical token JSON.
* For generated platform files, see the `generated/` directory.
* For the canonical JSON source, see `tokens/bytelyst.tokens.json`.
*/
import { readFileSync } from 'node:fs';
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
const __dirname = dirname(fileURLToPath(import.meta.url));
export interface DesignTokens {
meta: { name: string; version: string; updatedAt: string; scale: string };
color: {
palette: Record<string, Record<string, string>>;
semantic: {
dark: Record<string, string>;
light: Record<string, string>;
};
brain: Record<string, { from: string; to: string }>;
};
typography: {
fontFamily: Record<string, string>;
fontWeight: Record<string, number>;
fontSize: Record<string, number>;
lineHeight: Record<string, number>;
letterSpacing: Record<string, number>;
};
spacing: Record<string, number>;
radius: Record<string, number>;
elevation: Record<string, string>;
motion: {
duration: Record<string, number>;
easing: Record<string, string>;
};
breakpoints: Record<string, number>;
layout: Record<string, number>;
}
let _cached: DesignTokens | null = null;
export function loadTokens(): DesignTokens {
if (_cached) return _cached;
const tokenPath = resolve(__dirname, '../tokens/bytelyst.tokens.json');
const raw = readFileSync(tokenPath, 'utf-8');
_cached = JSON.parse(raw) as DesignTokens;
return _cached;
}