Skip to content

refactor!: drop the token mirror, leaving the stylesheet as the only copy - #8

Merged
YaelAnaya merged 1 commit into
simplify-0.3.0from
refactor/drop-token-mirror
Sep 21, 2026
Merged

YaelAnaya merged 1 commit into
simplify-0.3.0from
refactor/drop-token-mirror

Conversation

@YaelAnaya

Copy link
Copy Markdown
Contributor

Stacked on #7. Review that one first; this PR's diff is only the removal.

src/theme/tokens.ts held LIGHT_THEME, DARK_THEME, THEME and cssVar: a TypeScript copy of the values in styles.css, kept for a caller that could not read CSS, plus a test to hold the two in step.

Nothing in the package imported it. No consumer imported it either. A second copy of the palette is a second thing that can go stale, and ninety-seven hand-maintained lines plus a synchronisation test to protect a caller that never arrived.

What replaces it

A caller that genuinely needs a value as a string reads it from the document, which has the further advantage of answering for the theme the reader is in:

const ink = getComputedStyle(document.documentElement).getPropertyValue("--foreground");

Everywhere else, var(--role).

The test keeps the half that was never about the mirror

Every role declared in both themes and nothing else, the palette closed, one --color-<role> per role, the radius scale derived from --radius, dark mode keyed off the class, no focus geometry in the base layer.

The dark-theme check that compared against the mirror now asserts something the mirror could not: that the theme repoints its roles rather than restating the light values.

Before After
Token contract tests 15 13
Hand-maintained duplicate lines 97 0

Adding a token now touches one place fewer.

Breaking change

LIGHT_THEME, DARK_THEME, THEME and cssVar are no longer exported. docs/MIGRATION-0.3.md gains section 6 with the replacement; the "Unchanged" entry that promised they were kept is corrected.

Verification

pnpm verify passes: format, lint, 124 tests in 16 files, the build, the docs site, and the packed-consumer test.

…copy

`src/theme/tokens.ts` held `LIGHT_THEME`, `DARK_THEME`, `THEME` and `cssVar`: a
TypeScript copy of the values in `styles.css`, kept for a caller that could not
read CSS, and a test to hold the two in step. Nothing in the package imported
it, no consumer did either, and a second copy of the palette is a second thing
that can go stale.

The stylesheet is now the only copy. A caller that genuinely needs a value as a
string reads it from the document, which also answers for the theme the reader
is in; everywhere else `var(--role)` resolves it.

`tests/theme/tokens.test.ts` keeps the half that was never about the mirror:
every role declared in both themes and nothing else, the palette closed, one
`--color-<role>` per role, the radius scale derived from `--radius`, dark mode
keyed off the class, no focus geometry in the base layer. The dark-theme check
that compared against the mirror now asserts what the mirror could not — that
the theme repoints its roles rather than restating the light values.

BREAKING CHANGE: `LIGHT_THEME`, `DARK_THEME`, `THEME` and `cssVar` are no
longer exported. docs/MIGRATION-0.3.md section 6 has the replacement.
@YaelAnaya
YaelAnaya force-pushed the refactor/drop-token-mirror branch from b044463 to 9bc02ca Compare September 21, 2026 00:14
YaelAnaya added a commit that referenced this pull request Sep 21, 2026
El commit revertido fue un error mío: la red de seguridad del troceado se
commiteó en esta rama en lugar de en una aparte, y se empujó con ella. Su
contenido vive, ya separado por propósito, en las tres ramas que abren los
PR #6, #7 y #8. El árbol vuelve a ser exactamente el de ae7454b.
Base automatically changed from feat/docs-site-astro to simplify-0.3.0 September 21, 2026 00:30
@YaelAnaya
YaelAnaya merged commit 74cbe49 into simplify-0.3.0 Sep 21, 2026
1 check passed
@YaelAnaya
YaelAnaya deleted the refactor/drop-token-mirror branch September 21, 2026 00:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant