-
Notifications
You must be signed in to change notification settings - Fork 14
refactor(ui): token housekeeping + typography wiring + icon CSS (slice #02, issue #440) #448
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
47af3aa
refactor(ui): promote --surface-base-active to REGULATED token section
Astro-Han cc7778c
test(ui): add colors.txt ↔ colors.css generation consistency check
Astro-Han 57dbd6b
refactor(ui): remove shadow/blend tokens from Tailwind --color-* name…
Astro-Han 0cf651e
refactor(ui): replace inline font-size literals with font-size tokens
Astro-Han 5d1e088
refactor(ui): add icon color state selectors and document size tiers
Astro-Han 6e543ff
test(ui): align colors-generation parser with generator script
Astro-Han d1b5605
test(ui): add duplicate-token guard to colors-generation test
Astro-Han File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| /** | ||
| * colors-generation.test.ts | ||
| * | ||
| * Verifies that tailwind/colors.css is in sync with script/colors.txt. | ||
| * For every --X token defined in colors.txt there must be a corresponding | ||
| * --color-X: var(--X) entry in colors.css, and vice versa (no orphan entries). | ||
| * | ||
| * This catches stale artifacts: if colors.txt is updated but colors.css is not | ||
| * regenerated, a Tailwind utility like `bg-surface-base-active` would silently | ||
| * resolve to the wrong value. | ||
| */ | ||
|
|
||
| import { expect, test } from "bun:test" | ||
| import { readFileSync } from "fs" | ||
| import { join } from "path" | ||
|
|
||
| const ROOT = join(import.meta.dirname, "..") | ||
| const COLORS_TXT = readFileSync(join(ROOT, "script/colors.txt"), "utf-8") | ||
| const COLORS_CSS = readFileSync(join(ROOT, "src/styles/tailwind/colors.css"), "utf-8") | ||
|
|
||
| /** Extract token names from colors.txt (e.g. "--brand-primary: ..." → "brand-primary") */ | ||
| function parseTxtTokens(txt: string): string[] { | ||
| return txt | ||
| .split("\n") | ||
| .filter((l) => l.trim().startsWith("--")) | ||
| .map((l) => l.trim().split(":")[0].trim().substring(2)) | ||
| .filter(Boolean) | ||
| } | ||
|
|
||
| /** Extract token names from colors.css @theme block (e.g. "--color-brand-primary: var(--brand-primary)" → "brand-primary") */ | ||
| function parseCssTokens(css: string): string[] { | ||
| const entries: string[] = [] | ||
| const re = /--color-([^\s:]+)\s*:\s*var\(--\1\)/g | ||
| let m: RegExpExecArray | null | ||
| while ((m = re.exec(css)) !== null) { | ||
| entries.push(m[1]) | ||
| } | ||
| return entries | ||
| } | ||
|
|
||
| const txtTokens = parseTxtTokens(COLORS_TXT) | ||
| const cssTokens = parseCssTokens(COLORS_CSS) | ||
|
|
||
| test("colors.txt has no duplicate token names", () => { | ||
| const dupes = txtTokens.filter((t, i) => txtTokens.indexOf(t) !== i) | ||
| expect(dupes, `duplicate tokens in colors.txt: ${dupes.join(", ")}`).toEqual([]) | ||
| }) | ||
|
|
||
| test("colors.css has no duplicate token entries", () => { | ||
| const dupes = cssTokens.filter((t, i) => cssTokens.indexOf(t) !== i) | ||
| expect(dupes, `duplicate entries in colors.css: ${dupes.join(", ")}`).toEqual([]) | ||
| }) | ||
|
|
||
| test("every colors.txt token has a --color-X: var(--X) entry in colors.css", () => { | ||
| const cssSet = new Set(cssTokens) | ||
| const missing = txtTokens.filter((t) => !cssSet.has(t)) | ||
| expect( | ||
| missing, | ||
| `tokens in colors.txt missing from colors.css: ${missing.join(", ")}`, | ||
| ).toEqual([]) | ||
| }) | ||
|
|
||
| test("every colors.css entry has a corresponding token in colors.txt", () => { | ||
| const txtSet = new Set(txtTokens) | ||
| const orphan = cssTokens.filter((t) => !txtSet.has(t)) | ||
| expect( | ||
| orphan, | ||
| `tokens in colors.css not present in colors.txt: ${orphan.join(", ")}`, | ||
| ).toEqual([]) | ||
| }) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.