From 1190a9826506922a98aa13f1edf0eaf97f022dcf Mon Sep 17 00:00:00 2001 From: Josh Knapp Date: Sun, 1 Nov 2026 09:51:32 -0800 Subject: [PATCH] tokens: isTokenRef accepts brand token names (digits) Co-Authored-By: Claude Sonnet 5.5 --- craft/src/utils/swatches.test.ts | 8 ++++++++ craft/src/utils/tokens.ts | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/craft/src/utils/swatches.test.ts b/craft/src/utils/swatches.test.ts index 260e671..9b8d2aa 100644 --- a/craft/src/utils/swatches.test.ts +++ b/craft/src/utils/swatches.test.ts @@ -111,3 +111,11 @@ describe('list operations', () => { expect(findSwatchByHex(l, '#000')).toBeUndefined(); }); }); + +describe('isTokenRef accepts brand refs (digits in the name)', () => { + test('brand refs are token refs but not fixed-slot keys', async () => { + const { isTokenRef, tokenKeyOf } = await import('./tokens'); + expect(isTokenRef('var(--wsb-brand-2)')).toBe(true); + expect(tokenKeyOf('var(--wsb-brand-2)')).toBeNull(); + }); +}); diff --git a/craft/src/utils/tokens.ts b/craft/src/utils/tokens.ts index 4947d67..2e17474 100644 --- a/craft/src/utils/tokens.ts +++ b/craft/src/utils/tokens.ts @@ -64,7 +64,7 @@ export const COLOR_TOKENS: ReadonlyArray<{ key: TokenKey; label: string }> = [ { key: 'error', label: 'Error' }, ]; -const TOKEN_REF_RE = /^var\(--wsb-([a-z-]+)\)$/; +const TOKEN_REF_RE = /^var\(--wsb-([a-z0-9-]+)\)$/; // TokenKey -> SiteDesign key, derived from TOKEN_VARS so there is one source. const DESIGN_KEY_BY_TOKEN = new Map(