Skip to content

Theme: Expose legacy color alias defaults in design token CSS - #79772

Closed
ciampo wants to merge 7 commits into
trunkfrom
codex/theme-legacy-css-vars
Closed

ciampo wants to merge 7 commits into
trunkfrom
codex/theme-legacy-css-vars

Conversation

@ciampo

@ciampo ciampo commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor

What?

Follow up to #77462.

Adds default legacy --wp-components-* color aliases to the generated @wordpress/theme design token CSS.

These aliases are compatibility defaults for consumers that still reference the old @wordpress/components color variables directly. ThemeProvider keeps emitting the same provider-scoped legacy aliases as before, using the same shared alias definitions as the static CSS generation.

Why?

The design token stylesheet is the static baseline for WordPress Design System tokens. Without these aliases, bare legacy references such as var(--wp-components-color-accent) only resolve when a runtime provider or another legacy theme layer defines them.

Adding low-specificity defaults to design-tokens.css fills that static compatibility gap without making the aliases new design tokens.

Keeping the runtime provider bridge unchanged avoids adding custom-color tracking or cascade-sensitive runtime behavior just to support the static defaults.

How?

  • Defines the legacy alias list once for both runtime and generated CSS use.
  • Appends default legacy --wp-components-* aliases during the design token build.
  • Derives static fallbacks for --wpds-* alias targets from the generated design token fallback map.
  • Keeps explicit fallbacks only for legacy --wp-admin-theme-color* targets.
  • Emits the defaults under :where(:root) so they stay low specificity.
  • Keeps the existing ThemeProvider runtime legacy aliases in place for scoped theming.
  • Documents the legacy alias compatibility behavior in the README delivery model.

Testing Instructions

  • npm run --workspace @wordpress/theme build:tokens
  • npm run --workspace @wordpress/theme postbuild
  • npm run test:unit -- packages/theme/src/test/use-theme-provider-styles.test.tsx
  • npm run lint:js -- packages/theme/bin/build-design-tokens/index.ts packages/theme/src/legacy-color-aliases.ts packages/theme/src/test/use-theme-provider-styles.test.tsx
  • npx tsgo --build packages/theme/tsconfig.json
  • git diff --check

Known existing docs-lint noise: npm run lint:md:docs -- packages/theme/README.md packages/theme/CHANGELOG.md still reports pre-existing MD033 in the README and MD041/MD024 in the changelog.

Testing Instructions for Keyboard

No UI behavior changed.

Screenshots or screencast

Not applicable.

Use of AI Tools

Codex was used to help implement, test, and prepare this PR.

@github-actions github-actions Bot added the [Package] Theme /packages/theme label Jul 1, 2026
@github-actions

github-actions Bot commented Jul 1, 2026 •

Copy link
Copy Markdown

Size Change: +1.07 kB (+0.01%)

Total Size: 7.67 MB

📦 View Changed
Filename Size Change
build/modules/boot/index.min.js 51.5 kB +182 B (+0.35%)
build/scripts/theme/index.min.js 22.6 kB +19 B (+0.08%)
build/styles/theme/design-tokens-rtl.css 3.62 kB +240 B (+7.11%) 🔍
build/styles/theme/design-tokens-rtl.min.css 1.81 kB +195 B (+12.1%) ⚠️
build/styles/theme/design-tokens.css 3.62 kB +240 B (+7.11%) 🔍
build/styles/theme/design-tokens.min.css 1.81 kB +195 B (+12.1%) ⚠️

compressed-size-action

@ciampo
ciampo force-pushed the codex/theme-legacy-css-vars branch from 39a4605 to 393f893 Compare July 6, 2026 21:25
@ciampo ciampo self-assigned this Jul 6, 2026
@ciampo ciampo added the [Type] Developer Documentation Documentation for developers label Jul 6, 2026
@ciampo ciampo changed the title Theme: Move legacy color aliases to generated CSS Theme: Move default legacy color aliases to generated CSS Jul 6, 2026
@github-actions

github-actions Bot commented Jul 6, 2026 •

Copy link
Copy Markdown

Flaky tests detected in ad403cc.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/28850935121
📝 Reported issues:

@ciampo ciampo changed the title Theme: Move default legacy color aliases to generated CSS Theme: Expose legacy color alias defaults in design token CSS Jul 7, 2026
@ciampo
ciampo marked this pull request as ready for review July 7, 2026 07:20
@ciampo
ciampo requested a review from a team as a code owner July 7, 2026 07:20
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: ciampo <mciampini@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@ciampo

ciampo commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

On second thought, I think this PR can be closed.

The fallback values for the --wp-components variables were already added in #78664 directly in the @wordpress/components package. We shouldn't promote legacy components internals into the theme package’s static contract.

@ciampo ciampo closed this Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Theme /packages/theme [Type] Developer Documentation Documentation for developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant