made tiny updates

This commit is contained in:
SinachPat
2026-05-04 12:30:56 +01:00
parent 3f029e15c2
commit 5b2d918c13
47 changed files with 2597 additions and 521 deletions
+7 -6
View File
@@ -6,15 +6,16 @@ import type { DesignLanguageFileBody } from './schema.js';
export type FluentTokenMap = Record<string, string>;
/** Extract color token overrides from a DLF as a Fluent 2 token map. */
/**
* Extract color tokens from a DLF as a Fluent 2 token map.
* Tokens are flat strings (spec Layer 5.1: tokens.colors is Record<string,string>),
* so each key becomes a CSS custom property name and the value is the CSS value.
*/
export function extractColorTokens(dlf: DesignLanguageFileBody): FluentTokenMap {
const out: FluentTokenMap = {};
const colors = dlf.tokens?.colors ?? {};
for (const [, token] of Object.entries(colors)) {
if (!token) continue;
if (token.fluentToken) {
out[token.fluentToken] = token.value;
}
for (const [name, value] of Object.entries(colors)) {
if (value) out[name] = value;
}
return out;
}