Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/semantic-tokens/scripts/fluentOverrides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export type FluentOverrideValue =
rawValue: string;
};

export type FluentOverrides = Record<string, FluentOverrideValue>;
export type FluentOverrides = Record<string, FluentOverrideValue | null>;

export const fluentOverrides: FluentOverrides = {
ctrlFocusOuterStroke: {
Expand Down
12 changes: 8 additions & 4 deletions packages/semantic-tokens/scripts/legacyTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,21 @@ const generateLegacyTokens = () => {
console.log('Importing required fluent legacy tokens as flat export');

const semanticTokenFallbacks = Object.keys(fluentOverrides);
const exportedTokens: string[] = [];
const comment = '// THIS FILE IS GENERATED AS PART OF THE BUILD PROCESS. DO NOT MANUALLY MODIFY THIS FILE\n';

const generatedTokens = semanticTokenFallbacks.reduce((acc, t) => {
const fluent2Fallback = fluentOverrides[t].f2Token;
if (!fluent2Fallback) {
return '';
const tokenOverride = fluentOverrides[t];
Comment thread
Mitch-At-Work marked this conversation as resolved.
const fluent2Fallback = tokenOverride?.f2Token;
if (!tokenOverride || !fluent2Fallback || exportedTokens.includes(fluent2Fallback)) {
return acc;
}
// Add it to our list of exported tokens
exportedTokens.push(fluent2Fallback);
if (!Object.keys(tokensPackage.tokens).includes(fluent2Fallback)) {
// Token does not exist in F2 tokens
// This should never occur, but let's flag if a mistake was made in fallback token names
throw new Error(`Fluent token ${fluentOverrides[t].f2Token} not found in fluent tokens`);
throw new Error(`Fluent token ${tokenOverride.f2Token} not found in fluent tokens`);
}
const tokenValue = tokensPackage.tokens[fluent2Fallback as keyof typeof tokensPackage.tokens];
const token = `/**
Expand Down