From 338420f9277370b8ba19736f6774304f60e23bb8 Mon Sep 17 00:00:00 2001 From: Marco Ciampini Date: Fri, 12 Jun 2026 16:03:34 +0200 Subject: [PATCH 1/5] ThemeProvider: forward cornerRadius preset to :root for root providers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Restore the `:root:has([data-wpds-root-provider="true"][data-wpds-corner-radius="…"])` selectors for each corner-radius preset mode in the Terrazzo config (and the generated prebuilt CSS) so a root `ThemeProvider` applies the `--wpds-border-radius-*` tokens to the document element, consistent with how `color` and `cursor` tokens already behave. Follow-up to https://github.com/WordPress/gutenberg/pull/78816#discussion_r3381983801 --- packages/theme/CHANGELOG.md | 4 +++ .../theme/src/prebuilt/css/design-tokens.css | 18 +++++++++--- packages/theme/terrazzo.config.ts | 29 ++++++++++++++++--- 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/packages/theme/CHANGELOG.md b/packages/theme/CHANGELOG.md index 73150d640d73d9..43e2bbccb78f41 100644 --- a/packages/theme/CHANGELOG.md +++ b/packages/theme/CHANGELOG.md @@ -7,6 +7,10 @@ - Add `--wpds-border-radius-xl` for page and app shell surfaces so nested cards and notices can stay on `--wpds-border-radius-lg` without matching the parent radius ([#78913](https://github.com/WordPress/gutenberg/pull/78913)). - Add `cornerRadius` prop to `ThemeProvider` for configuring the border-radius preset (`none`, `subtle`, `moderate`, `pronounced`) via prebuilt design token modes. [#78816](https://github.com/WordPress/gutenberg/pull/78816). +### Enhancements + +- `ThemeProvider`: forward the `cornerRadius` preset to the document element when `isRoot` is set, so the `--wpds-border-radius-*` tokens also apply to ``, matching the existing behavior for `color` and `cursor` tokens. [#PR_NUMBER](https://github.com/WordPress/gutenberg/pull/PR_NUMBER). + ### Breaking Changes - Rename the `bg` and `fg` design token groups to `background` and `foreground`. All `--wpds-color-bg-*` custom properties are now `--wpds-color-background-*`, and all `--wpds-color-fg-*` custom properties are now `--wpds-color-foreground-*` ([#79098](https://github.com/WordPress/gutenberg/pull/79098)). diff --git a/packages/theme/src/prebuilt/css/design-tokens.css b/packages/theme/src/prebuilt/css/design-tokens.css index 695197af9b80e4..bbf40879c5432f 100644 --- a/packages/theme/src/prebuilt/css/design-tokens.css +++ b/packages/theme/src/prebuilt/css/design-tokens.css @@ -334,7 +334,8 @@ } } -[data-wpds-corner-radius='none'] { +[data-wpds-corner-radius='none'], +:root:has( [data-wpds-root-provider='true'][data-wpds-corner-radius='none'] ) { /* Buttons and other elements nested inside controls. */ --wpds-border-radius-xs: 0; /* Standalone buttons, inputs, and compact controls. */ @@ -347,7 +348,10 @@ --wpds-border-radius-xl: 0; } -[data-wpds-corner-radius='subtle'] { +[data-wpds-corner-radius='subtle'], +:root:has( + [data-wpds-root-provider='true'][data-wpds-corner-radius='subtle'] + ) { /* Buttons and other elements nested inside controls. */ --wpds-border-radius-xs: 1px; /* Standalone buttons, inputs, and compact controls. */ @@ -360,7 +364,10 @@ --wpds-border-radius-xl: 12px; } -[data-wpds-corner-radius='moderate'] { +[data-wpds-corner-radius='moderate'], +:root:has( + [data-wpds-root-provider='true'][data-wpds-corner-radius='moderate'] + ) { /* Buttons and other elements nested inside controls. */ --wpds-border-radius-xs: 6px; /* Standalone buttons, inputs, and compact controls. */ @@ -373,7 +380,10 @@ --wpds-border-radius-xl: 20px; } -[data-wpds-corner-radius='pronounced'] { +[data-wpds-corner-radius='pronounced'], +:root:has( + [data-wpds-root-provider='true'][data-wpds-corner-radius='pronounced'] + ) { /* Buttons and other elements nested inside controls. */ --wpds-border-radius-xs: 18px; /* Standalone buttons, inputs, and compact controls. */ diff --git a/packages/theme/terrazzo.config.ts b/packages/theme/terrazzo.config.ts index 44b8f8612b767c..cd92c93e8ebebd 100644 --- a/packages/theme/terrazzo.config.ts +++ b/packages/theme/terrazzo.config.ts @@ -69,21 +69,42 @@ const config: Config = { '@media ( -webkit-min-device-pixel-ratio: 2 ), ( min-resolution: 192dpi )', ], }, + // Each corner-radius preset is applied via the + // `data-wpds-corner-radius` attribute that `ThemeProvider` + // sets on its scoping element. The additional + // `:root:has([data-wpds-root-provider="true"]…)` selector lets + // a root `ThemeProvider` forward its preset to the document + // element, matching how `color` and `cursor` tokens already + // behave so the whole token surface stays consistent on + // `` (e.g. for PHP-rendered admin UI outside the React + // app). { mode: 'corner-radius-none', - selectors: [ '[data-wpds-corner-radius="none"]' ], + selectors: [ + '[data-wpds-corner-radius="none"]', + ':root:has([data-wpds-root-provider="true"][data-wpds-corner-radius="none"])', + ], }, { mode: 'corner-radius-subtle', - selectors: [ '[data-wpds-corner-radius="subtle"]' ], + selectors: [ + '[data-wpds-corner-radius="subtle"]', + ':root:has([data-wpds-root-provider="true"][data-wpds-corner-radius="subtle"])', + ], }, { mode: 'corner-radius-moderate', - selectors: [ '[data-wpds-corner-radius="moderate"]' ], + selectors: [ + '[data-wpds-corner-radius="moderate"]', + ':root:has([data-wpds-root-provider="true"][data-wpds-corner-radius="moderate"])', + ], }, { mode: 'corner-radius-pronounced', - selectors: [ '[data-wpds-corner-radius="pronounced"]' ], + selectors: [ + '[data-wpds-corner-radius="pronounced"]', + ':root:has([data-wpds-root-provider="true"][data-wpds-corner-radius="pronounced"])', + ], }, ], legacyHex: true, From 7f0fa3bf1edded8075daade91cb670b23af47706 Mon Sep 17 00:00:00 2001 From: Marco Ciampini Date: Fri, 12 Jun 2026 16:04:26 +0200 Subject: [PATCH 2/5] Update CHANGELOG with PR number --- packages/theme/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/theme/CHANGELOG.md b/packages/theme/CHANGELOG.md index 43e2bbccb78f41..9e9445857601b2 100644 --- a/packages/theme/CHANGELOG.md +++ b/packages/theme/CHANGELOG.md @@ -9,7 +9,7 @@ ### Enhancements -- `ThemeProvider`: forward the `cornerRadius` preset to the document element when `isRoot` is set, so the `--wpds-border-radius-*` tokens also apply to ``, matching the existing behavior for `color` and `cursor` tokens. [#PR_NUMBER](https://github.com/WordPress/gutenberg/pull/PR_NUMBER). +- `ThemeProvider`: forward the `cornerRadius` preset to the document element when `isRoot` is set, so the `--wpds-border-radius-*` tokens also apply to ``, matching the existing behavior for `color` and `cursor` tokens. [#79153](https://github.com/WordPress/gutenberg/pull/79153). ### Breaking Changes From 89743f062b5bdd1bd349949a8fbbdc72288597b1 Mon Sep 17 00:00:00 2001 From: Marco Ciampini Date: Fri, 12 Jun 2026 16:17:10 +0200 Subject: [PATCH 3/5] Shorten CHANGELOG entry --- packages/theme/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/theme/CHANGELOG.md b/packages/theme/CHANGELOG.md index 9e9445857601b2..a91c82413277c8 100644 --- a/packages/theme/CHANGELOG.md +++ b/packages/theme/CHANGELOG.md @@ -9,7 +9,7 @@ ### Enhancements -- `ThemeProvider`: forward the `cornerRadius` preset to the document element when `isRoot` is set, so the `--wpds-border-radius-*` tokens also apply to ``, matching the existing behavior for `color` and `cursor` tokens. [#79153](https://github.com/WordPress/gutenberg/pull/79153). +- `ThemeProvider`: forward the `cornerRadius` preset to the document element when `isRoot` is set, matching `color` and `cursor`. [#79153](https://github.com/WordPress/gutenberg/pull/79153). ### Breaking Changes From 415e57d99ca80977ce0929473d60a14a885cfd3e Mon Sep 17 00:00:00 2001 From: Marco Ciampini Date: Mon, 15 Jun 2026 17:35:36 +0200 Subject: [PATCH 4/5] ThemeProvider: test cornerRadius forwarding to the document root MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add coverage for the prebuilt `:root:has( [data-wpds-root-provider='true']… )` rule: a root provider forwards its corner-radius preset to the document element, while a non-root provider does not. Loads the prebuilt design-token CSS (where the border-radius preset values live) to exercise the cascade. --- .../theme/src/test/theme-provider.test.tsx | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/packages/theme/src/test/theme-provider.test.tsx b/packages/theme/src/test/theme-provider.test.tsx index 37e410d717494b..7374726e0e40b4 100644 --- a/packages/theme/src/test/theme-provider.test.tsx +++ b/packages/theme/src/test/theme-provider.test.tsx @@ -3,6 +3,8 @@ // is asserted on the provider's own scoping element (where the property is // defined and from which real children would inherit) and on the document root. +import { readFileSync } from 'fs'; +import { join } from 'path'; import { render, screen } from '@testing-library/react'; import { ThemeProvider } from '../theme-provider'; @@ -127,6 +129,71 @@ describe( 'ThemeProvider', () => { expect( readProp( document.documentElement, BRAND_BG ) ).toBe( '' ); } ); + + // Unlike color/cursor (emitted at runtime in the provider's own + // `