Skip to content

feat(theme): add theme-local token support - #5844

Merged
rubyycheung merged 2 commits into
mainfrom
codex/theme-local-tokens-implementation
Sep 2, 2026
Merged

feat(theme): add theme-local token support#5844
rubyycheung merged 2 commits into
mainfrom
codex/theme-local-tokens-implementation

Conversation

@rubyycheung

Copy link
Copy Markdown
Contributor

Summary

  • implement the accepted AST-006 localTokens authoring contract from docs(knowledge): specify theme-local tokens #5801
  • preserve exact theme-local names through runtime CSS, static builds, inheritance, and generated built-theme metadata
  • validate enrolled declarations, references, namespaces, lineage, and cycles without changing legacy tokens behavior
  • document the API for theme authors and keep the generated theme template synchronized

Scope

This is infrastructure only. It does not adopt local tokens in Neutral or change any shipped theme colors or component styling. Neutral adoption remains separate from the cross-theme API review.

An inheritance-only descendant keeps its existing theme name, including legacy names that are not lower-kebab-case. The stricter name rule applies only when a theme explicitly supplies localTokens.

Validation

  • pnpm -F @astryxdesign/core build
  • pnpm -F @astryxdesign/core typecheck
  • focused Core/CLI/template tests: 129 passed
  • pnpm -F @astryxdesign/theme-neutral build
  • pnpm -F @astryxdesign/cli typecheck:strict
  • pnpm -F @astryxdesign/cli typecheck:authoring
  • pnpm -F @astryxdesign/cli typecheck:template-docs
  • pnpm check:sync
  • pnpm check:changesets
  • pnpm check:package-boundaries
  • repository pre-commit validation suite

Extracted from #5752 so the reusable API can be reviewed independently from Neutral's visual design decisions.

@vercel

vercel Bot commented Sep 1, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Sep 2, 2026 7:54am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Sep 1, 2026
@github-actions github-actions Bot added the needs:code-review High-risk change (new package/component/API) — needs human code review before merge label Sep 1, 2026
github-actions Bot added a commit that referenced this pull request Sep 1, 2026
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

No new or modified components detected.

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.8KB 1.2KB

Accessibility Audit

Status: No accessibility violations detected.

Visual Regression

Status: Skipped — Broad stable scope is deferred to the daily release gate. It covers 4332 trusted baseline shots instead of recapturing them for this PR. View the report


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@cixzhang cixzhang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Theme authors who opt into localTokens can currently receive invalid or contradictory output even though the build succeeds.

  • CSS_VAR_PATTERN only recognizes lowercase var(. Valid CSS such as VAR(--astryx-theme-foo-color-fill) bypasses undeclared-reference and cycle validation, so an enrolled static build can emit a broken reference. Please parse the function case-insensitively and add runtime/static undeclared + cycle regressions for uppercase/mixed-case spelling.
  • A key duplicated in legacy tokens and localTokens is accepted and emitted twice. CSS uses the later local declaration, while resolveThemeToken() reads the portable tokens value. Please reject cross-map duplicate names before output and test CSS/helper parity.
  • This is a settled implementation of AST-006, so the implementation PR also needs to update the canonical shipped records required by AST-006’s current-state impact and completion criteria: AST-006’s phase plus theme-authoring-contract, theme-compilation, and theme-tokens. The Neutral theme record is not involved because this PR adds infrastructure without an adopted Neutral local-token mapping.

@github-actions
github-actions Bot requested a review from cixzhang September 2, 2026 07:51
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Sep 2, 2026
@rubyycheung

Copy link
Copy Markdown
Contributor Author

Addressed the requested changes in 747d9c0b5:

  • made CSS var() detection case-insensitive while preserving the exact custom-property name, with runtime and static regressions for uppercase and mixed-case undeclared references and cycles
  • reject names duplicated across tokens and localTokens after inheritance/override resolution, before output; added legacy CSS/resolveThemeToken() parity coverage and static atomic-output coverage
  • moved AST-006 to shipped and updated theme-authoring-contract, theme-compilation, and theme-tokens to describe the shipped contract and cite the deciding spec decisions

Local validation passed: 218 focused tests, Core build/typecheck, CLI strict/authoring/template-doc typechecks, Neutral build, ESLint, and pnpm check:repo.

@cixzhang cixzhang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this addresses the validation and contract-sync issues from my prior review. No new concerns.

[Reviewed by Robohands]

@github-actions github-actions Bot removed needs:spec-owner-review Current knowledge records await owner approval needs:code-review High-risk change (new package/component/API) — needs human code review before merge labels Sep 2, 2026
@rubyycheung
rubyycheung merged commit 7418f0e into main Sep 2, 2026
28 checks passed
@github-actions
github-actions Bot deleted the codex/theme-local-tokens-implementation branch September 3, 2026 06:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants