From fd08766cd9103c9d85eba47bd546800bba687dcb Mon Sep 17 00:00:00 2001 From: Marco Ciampini Date: Mon, 30 Nov 2026 15:19:10 +0100 Subject: [PATCH 01/19] Admin UI: Update the Modern, Fresh, Midnight, and Ectoplasm scheme colors Since #86614 and #82542, the brand fill in the dark sidebar carries a dark label for every admin scheme: white cannot reach 4.5:1 on both the fill and its active state while the fills keep 3:1 against the neutral surfaces. Darken the Modern, Fresh, and Midnight backgrounds to the lightest seeds for which the ramp keeps a white label, and darken the Fresh and Midnight primary colors where the fill needs it. Return Ectoplasm to its original Core colors, with the background tuned so the sidebar matches #523f6d. Co-Authored-By: Claude Opus 5.5 --- .../wpds-admin/css/05-scheme-tokens.css | 121 ++++++++++-------- packages/admin-ui/CHANGELOG.md | 4 + .../admin-ui/src/admin-theme-colors/index.ts | 15 ++- .../test/index.jsdom.test.ts | 4 +- packages/base-styles/CHANGELOG.md | 1 + packages/base-styles/_mixins.scss | 4 +- .../admin-scheme-sidebar.browser.test.tsx | 33 ++++- .../stories/brand-fallbacks.story.tsx | 3 +- .../src/color-ramps/stories/index.story.tsx | 14 +- .../theme-example-application.story.tsx | 4 +- 10 files changed, 132 insertions(+), 71 deletions(-) diff --git a/lib/experimental/wpds-admin/css/05-scheme-tokens.css b/lib/experimental/wpds-admin/css/05-scheme-tokens.css index a28325d4f362d3..09ea6beec2345c 100644 --- a/lib/experimental/wpds-admin/css/05-scheme-tokens.css +++ b/lib/experimental/wpds-admin/css/05-scheme-tokens.css @@ -23,45 +23,44 @@ @layer wpds-overrides, wp-legacy, wpds; @layer wpds { - body.admin-color-fresh, - body.admin-color-light { - --wpds-color-background-indicator-brand: #0071ae; - --wpds-color-background-interactive-brand-strong: #007cba; - --wpds-color-background-interactive-brand-strong-active: #006ca9; - --wpds-color-background-interactive-brand-weak-active: #d9ecfa; - --wpds-color-background-surface-brand: #e3f2fd; - --wpds-color-background-thumb-brand: #0071ae; - --wpds-color-background-thumb-brand-active: #0071ae; - --wpds-color-background-thumb-brand-strong: #fff; - --wpds-color-foreground-interactive-brand: #0071ae; - --wpds-color-foreground-interactive-brand-active: #002041; - --wpds-color-foreground-interactive-brand-strong: #fff; - --wpds-color-foreground-interactive-brand-strong-active: #fff; - --wpds-color-stroke-focus: #0071ae; - --wpds-color-stroke-interactive-brand: #0071ae; - --wpds-color-stroke-interactive-brand-active: #00528b; - --wpds-color-stroke-surface-brand: #a5c7e1; - --wpds-color-stroke-surface-brand-strong: #0071ae; + body.admin-color-fresh { + --wpds-color-background-indicator-brand: #006daa; + --wpds-color-background-interactive-brand-strong: #006daa; + --wpds-color-background-interactive-brand-strong-active: #005e9a; + --wpds-color-background-interactive-brand-weak-active: #daebfa; + --wpds-color-background-surface-brand: #e4f1fd; + --wpds-color-background-thumb-brand: #006daa; + --wpds-color-background-thumb-brand-active: #006daa; + --wpds-color-background-thumb-brand-strong: #eef0f2; + --wpds-color-foreground-interactive-brand: #006daa; + --wpds-color-foreground-interactive-brand-active: #001f44; + --wpds-color-foreground-interactive-brand-strong: #eef0f2; + --wpds-color-foreground-interactive-brand-strong-active: #eef0f2; + --wpds-color-stroke-focus: #006daa; + --wpds-color-stroke-interactive-brand: #006daa; + --wpds-color-stroke-interactive-brand-active: #004e89; + --wpds-color-stroke-surface-brand: #a0c1dd; + --wpds-color-stroke-surface-brand-strong: #006daa; } body.admin-color-midnight { - --wpds-color-background-indicator-brand: #c43830; - --wpds-color-background-interactive-brand-strong: #cf4339; - --wpds-color-background-interactive-brand-strong-active: #be322a; + --wpds-color-background-indicator-brand: #bf332b; + --wpds-color-background-interactive-brand-strong: #bf332b; + --wpds-color-background-interactive-brand-strong-active: #ae201c; --wpds-color-background-interactive-brand-weak-active: #f8e4e1; - --wpds-color-background-surface-brand: #faece9; - --wpds-color-background-thumb-brand: #c43830; - --wpds-color-background-thumb-brand-active: #c43830; - --wpds-color-background-thumb-brand-strong: #fffefe; - --wpds-color-foreground-interactive-brand: #c43830; + --wpds-color-background-surface-brand: #fbebe9; + --wpds-color-background-thumb-brand: #bf332b; + --wpds-color-background-thumb-brand-active: #bf332b; + --wpds-color-background-thumb-brand-strong: #f2efef; + --wpds-color-foreground-interactive-brand: #bf332b; --wpds-color-foreground-interactive-brand-active: #470000; - --wpds-color-foreground-interactive-brand-strong: #fffefe; - --wpds-color-foreground-interactive-brand-strong-active: #fffefe; - --wpds-color-stroke-focus: #c43830; - --wpds-color-stroke-interactive-brand: #c43830; - --wpds-color-stroke-interactive-brand-active: #a10b0e; - --wpds-color-stroke-surface-brand: #e0b9b3; - --wpds-color-stroke-surface-brand-strong: #c43830; + --wpds-color-foreground-interactive-brand-strong: #f2efef; + --wpds-color-foreground-interactive-brand-strong-active: #f2efef; + --wpds-color-stroke-focus: #bf332b; + --wpds-color-stroke-interactive-brand: #bf332b; + --wpds-color-stroke-interactive-brand-active: #9c0007; + --wpds-color-stroke-surface-brand: #deb2ab; + --wpds-color-stroke-surface-brand-strong: #bf332b; } body.admin-color-coffee { @@ -125,23 +124,23 @@ } body.admin-color-ectoplasm { - --wpds-color-background-indicator-brand: #646c3e; - --wpds-color-background-interactive-brand-strong: #646c3e; - --wpds-color-background-interactive-brand-strong-active: #575e31; - --wpds-color-background-interactive-brand-weak-active: #e3f2a1; - --wpds-color-background-surface-brand: #e9f8a6; - --wpds-color-background-thumb-brand: #646c3e; - --wpds-color-background-thumb-brand-active: #646c3e; - --wpds-color-background-thumb-brand-strong: #eff2e3; - --wpds-color-foreground-interactive-brand: #646c3e; - --wpds-color-foreground-interactive-brand-active: #1c2100; - --wpds-color-foreground-interactive-brand-strong: #eff2e3; - --wpds-color-foreground-interactive-brand-strong-active: #eff2e3; - --wpds-color-stroke-focus: #646c3e; - --wpds-color-stroke-interactive-brand: #646c3e; - --wpds-color-stroke-interactive-brand-active: #495022; - --wpds-color-stroke-surface-brand: #b8c291; - --wpds-color-stroke-surface-brand-strong: #646c3e; + --wpds-color-background-indicator-brand: #637300; + --wpds-color-background-interactive-brand-strong: #7f9111; + --wpds-color-background-interactive-brand-strong-active: #708200; + --wpds-color-background-interactive-brand-weak-active: #dff391; + --wpds-color-background-surface-brand: #e5f996; + --wpds-color-background-thumb-brand: #637300; + --wpds-color-background-thumb-brand-active: #637300; + --wpds-color-background-thumb-brand-strong: #090907; + --wpds-color-foreground-interactive-brand: #637300; + --wpds-color-foreground-interactive-brand-active: #1b2200; + --wpds-color-foreground-interactive-brand-strong: #090907; + --wpds-color-foreground-interactive-brand-strong-active: #090907; + --wpds-color-stroke-focus: #637300; + --wpds-color-stroke-interactive-brand: #637300; + --wpds-color-stroke-interactive-brand-active: #485500; + --wpds-color-stroke-surface-brand: #bbc98c; + --wpds-color-stroke-surface-brand-strong: #637300; } body.admin-color-sunrise { @@ -163,4 +162,24 @@ --wpds-color-stroke-surface-brand: #e2b99b; --wpds-color-stroke-surface-brand-strong: #a1580c; } + + body.admin-color-light { + --wpds-color-background-indicator-brand: #0071ae; + --wpds-color-background-interactive-brand-strong: #007cba; + --wpds-color-background-interactive-brand-strong-active: #006ca9; + --wpds-color-background-interactive-brand-weak-active: #d9ecfa; + --wpds-color-background-surface-brand: #e3f2fd; + --wpds-color-background-thumb-brand: #0071ae; + --wpds-color-background-thumb-brand-active: #0071ae; + --wpds-color-background-thumb-brand-strong: #fff; + --wpds-color-foreground-interactive-brand: #0071ae; + --wpds-color-foreground-interactive-brand-active: #002041; + --wpds-color-foreground-interactive-brand-strong: #fff; + --wpds-color-foreground-interactive-brand-strong-active: #fff; + --wpds-color-stroke-focus: #0071ae; + --wpds-color-stroke-interactive-brand: #0071ae; + --wpds-color-stroke-interactive-brand-active: #00528b; + --wpds-color-stroke-surface-brand: #a5c7e1; + --wpds-color-stroke-surface-brand-strong: #0071ae; + } } diff --git a/packages/admin-ui/CHANGELOG.md b/packages/admin-ui/CHANGELOG.md index b4486e4b964196..6a997956d2f7c2 100644 --- a/packages/admin-ui/CHANGELOG.md +++ b/packages/admin-ui/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Enhancements + +- `getAdminThemeColors`: Darken the Modern, Fresh, and Midnight backgrounds, and the Fresh and Midnight primary colors, so the brand fill keeps a white label in the sidebar. Ectoplasm returns to its original Core colors, with a dark label ([#PRNUM](https://github.com/WordPress/gutenberg/pull/PRNUM)). + ### Bug Fixes - `getAdminThemeColors`: Adjust the Blue and Sunrise background colors so the admin sidebar matches the WordPress 7.1 Core color schemes again ([#87420](https://github.com/WordPress/gutenberg/pull/87420)). diff --git a/packages/admin-ui/src/admin-theme-colors/index.ts b/packages/admin-ui/src/admin-theme-colors/index.ts index c555fddf9d4bb1..cf24e93b152921 100644 --- a/packages/admin-ui/src/admin-theme-colors/index.ts +++ b/packages/admin-ui/src/admin-theme-colors/index.ts @@ -5,7 +5,7 @@ type AdminThemeColors = { const DEFAULT_THEME_COLORS: AdminThemeColors = { primary: '#3858e9', - background: '#222524', + background: '#121514', }; /* @@ -14,16 +14,21 @@ const DEFAULT_THEME_COLORS: AdminThemeColors = { * * The Blue and Sunrise background seeds are tuned so that the sidebar color * they derive (`--wpds-color-background-surface-neutral-weak`) stays close to - * Core's `$base-color` for those schemes. + * Core's `$base-color` for those schemes. The Ectoplasm seeds use Core's + * original colors, with the background tuned the same way. + * + * The Modern, Fresh and Midnight backgrounds are the lightest that let the + * brand fill keep a white label at the required contrast, on the fill and on + * its active state. Fresh and Midnight also need a slightly darker primary. */ export const ADMIN_THEME_COLORS = new Map< string, AdminThemeColors >( [ [ 'modern', DEFAULT_THEME_COLORS ], - [ 'fresh', { primary: '#007cba', background: '#25292b' } ], - [ 'midnight', { primary: '#cf4339', background: '#3d4042' } ], + [ 'fresh', { primary: '#006daa', background: '#121618' } ], + [ 'midnight', { primary: '#bf332b', background: '#111416' } ], [ 'coffee', { primary: '#916745', background: '#5b534d' } ], [ 'ocean', { primary: '#567958', background: '#5f787f' } ], [ 'blue', { primary: '#437aa8', background: '#24567e' } ], - [ 'ectoplasm', { primary: '#646c3e', background: '#4f386e' } ], + [ 'ectoplasm', { primary: '#a3b745', background: '#54456b' } ], [ 'sunrise', { primary: '#ad631e', background: '#933330' } ], [ 'light', { primary: '#007cba', background: '#eaeeed' } ], ] ); diff --git a/packages/admin-ui/src/admin-theme-colors/test/index.jsdom.test.ts b/packages/admin-ui/src/admin-theme-colors/test/index.jsdom.test.ts index 6b7f032ac60ef4..eba0302d5ae7c3 100644 --- a/packages/admin-ui/src/admin-theme-colors/test/index.jsdom.test.ts +++ b/packages/admin-ui/src/admin-theme-colors/test/index.jsdom.test.ts @@ -16,7 +16,7 @@ describe( 'getAdminThemeColors', () => { expect( getAdminThemeColors() ).toEqual( { primary: '#3858e9', - background: '#222524', + background: '#121514', } ); } ); @@ -25,7 +25,7 @@ describe( 'getAdminThemeColors', () => { expect( getAdminThemeColors() ).toEqual( { primary: '#3858e9', - background: '#222524', + background: '#121514', } ); } ); } ); diff --git a/packages/base-styles/CHANGELOG.md b/packages/base-styles/CHANGELOG.md index c8171cb9860c07..9cf0de4ec032d2 100644 --- a/packages/base-styles/CHANGELOG.md +++ b/packages/base-styles/CHANGELOG.md @@ -4,6 +4,7 @@ ### Enhancements +- The `wordpress-admin-schemes` mixin now uses `#006daa` for Fresh and `#bf332b` for Midnight, the primary colors of those schemes in `@wordpress/admin-ui` ([#PRNUM](https://github.com/WordPress/gutenberg/pull/PRNUM)). - The `input-control` and `editor-input-reset` mixins now use the `--wpds-typography-font-size-md` design token for their font size ([#86961](https://github.com/WordPress/gutenberg/pull/86961)). ## 15.1.0 (2026-11-18) diff --git a/packages/base-styles/_mixins.scss b/packages/base-styles/_mixins.scss index 4876c5d0199073..354d60ba1fe971 100644 --- a/packages/base-styles/_mixins.scss +++ b/packages/base-styles/_mixins.scss @@ -428,7 +428,7 @@ @mixin wordpress-admin-schemes() { body.admin-color-fresh { - @include admin-scheme(#007cba); + @include admin-scheme(#006daa); } body.admin-color-light { @@ -452,7 +452,7 @@ } body.admin-color-midnight { - @include admin-scheme(#cf4339); + @include admin-scheme(#bf332b); } body.admin-color-ocean { diff --git a/packages/boot/src/components/root/test/admin-scheme-sidebar.browser.test.tsx b/packages/boot/src/components/root/test/admin-scheme-sidebar.browser.test.tsx index f3ca0490d41856..00cacd19ad5d72 100644 --- a/packages/boot/src/components/root/test/admin-scheme-sidebar.browser.test.tsx +++ b/packages/boot/src/components/root/test/admin-scheme-sidebar.browser.test.tsx @@ -17,10 +17,11 @@ describe( 'admin color scheme sidebar', () => { } ); // The sidebar should stay close to the `$base-color` of the Core scheme in - // WordPress 7.1 and later. + // WordPress 7.1 and later. Ectoplasm follows its original Core colors. it.each( [ { scheme: 'blue', core: '#245278' }, { scheme: 'sunrise', core: '#8a312d' }, + { scheme: 'ectoplasm', core: '#523f6d' }, ] )( 'matches the Core sidebar color in the $scheme scheme', async ( { scheme, core } ) => { @@ -47,4 +48,34 @@ describe( 'admin color scheme sidebar', () => { } ); } ); + + it.each( [ 'modern', 'fresh', 'midnight' ] )( + 'keeps a white label on the brand fill in the %s scheme', + async ( scheme ) => { + document.body.className = `admin-color-${ scheme }`; + + const view = await render( + +
+ label +
+
+ ); + + const label = getComputedStyle( + view.getByText( 'label' ).element() + ) + .color.match( /\d+/g )! + .map( Number ); + + // A light label, close to white. + label.slice( 0, 3 ).forEach( ( channel ) => { + expect( channel ).toBeGreaterThanOrEqual( 230 ); + } ); + } + ); } ); diff --git a/packages/theme/src/color-ramps/stories/brand-fallbacks.story.tsx b/packages/theme/src/color-ramps/stories/brand-fallbacks.story.tsx index 71f22494f72abe..049235e47e29d2 100644 --- a/packages/theme/src/color-ramps/stories/brand-fallbacks.story.tsx +++ b/packages/theme/src/color-ramps/stories/brand-fallbacks.story.tsx @@ -52,11 +52,12 @@ const meta: Meta< typeof Verifier > = { type: 'color', presetColors: [ '#3858e9', // modern + '#006daa', // fresh '#007cba', // light '#437aa8', // blue '#916745', // coffee '#646c3e', // ectoplasm - '#cf4339', // midnight + '#bf332b', // midnight '#567958', // ocean '#ad631e', // sunrise ], diff --git a/packages/theme/src/color-ramps/stories/index.story.tsx b/packages/theme/src/color-ramps/stories/index.story.tsx index 568ec6b6b08eef..3ba5727524412b 100644 --- a/packages/theme/src/color-ramps/stories/index.story.tsx +++ b/packages/theme/src/color-ramps/stories/index.story.tsx @@ -200,7 +200,7 @@ const SAMPLE_COMBINATIONS = [ { label: 'Modern admin dark', source: 'WordPress admin', - background: '#222524', + background: '#121514', primary: '#3858e9', }, { @@ -218,8 +218,8 @@ const SAMPLE_COMBINATIONS = [ { label: 'Fresh', source: 'WordPress admin scheme', - background: '#25292b', - primary: '#3858e9', + background: '#121618', + primary: '#006daa', }, { label: 'Light', @@ -242,8 +242,8 @@ const SAMPLE_COMBINATIONS = [ { label: 'Ectoplasm', source: 'WordPress admin scheme', - background: '#4f386e', - primary: '#646c3e', + background: '#54456b', + primary: '#a3b745', }, { label: 'Ocean', @@ -254,8 +254,8 @@ const SAMPLE_COMBINATIONS = [ { label: 'Midnight', source: 'WordPress admin scheme', - background: '#3d4042', - primary: '#cf4339', + background: '#111416', + primary: '#bf332b', }, { label: 'Sunrise', diff --git a/storybook/stories/design-system/theme-example-application.story.tsx b/storybook/stories/design-system/theme-example-application.story.tsx index 19bb66fc16f7fd..32c5dca18939a9 100644 --- a/storybook/stories/design-system/theme-example-application.story.tsx +++ b/storybook/stories/design-system/theme-example-application.story.tsx @@ -25,7 +25,7 @@ const SIDEBAR_THEME_PRESETS = [ { id: 'fresh', title: 'Fresh', - colors: { primary: '#3858e9', background: '#25292b' }, + colors: { primary: '#006daa', background: '#121618' }, }, { id: 'blue', @@ -35,7 +35,7 @@ const SIDEBAR_THEME_PRESETS = [ { id: 'ectoplasm', title: 'Ectoplasm', - colors: { primary: '#646c3e', background: '#4f386e' }, + colors: { primary: '#a3b745', background: '#54456b' }, }, ] as const; From 80aee76886a9e39a90cf030877f5ad68868b26ff Mon Sep 17 00:00:00 2001 From: Marco Ciampini Date: Mon, 30 Nov 2026 15:21:02 +0100 Subject: [PATCH 02/19] Docs: Link the changelog entries Co-Authored-By: Claude Opus 5.5 --- packages/admin-ui/CHANGELOG.md | 2 +- packages/base-styles/CHANGELOG.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/admin-ui/CHANGELOG.md b/packages/admin-ui/CHANGELOG.md index 6a997956d2f7c2..a5356424f3d047 100644 --- a/packages/admin-ui/CHANGELOG.md +++ b/packages/admin-ui/CHANGELOG.md @@ -4,7 +4,7 @@ ### Enhancements -- `getAdminThemeColors`: Darken the Modern, Fresh, and Midnight backgrounds, and the Fresh and Midnight primary colors, so the brand fill keeps a white label in the sidebar. Ectoplasm returns to its original Core colors, with a dark label ([#PRNUM](https://github.com/WordPress/gutenberg/pull/PRNUM)). +- `getAdminThemeColors`: Darken the Modern, Fresh, and Midnight backgrounds, and the Fresh and Midnight primary colors, so the brand fill keeps a white label in the sidebar. Ectoplasm returns to its original Core colors, with a dark label ([#87673](https://github.com/WordPress/gutenberg/pull/87673)). ### Bug Fixes diff --git a/packages/base-styles/CHANGELOG.md b/packages/base-styles/CHANGELOG.md index 9cf0de4ec032d2..a0601f902e5602 100644 --- a/packages/base-styles/CHANGELOG.md +++ b/packages/base-styles/CHANGELOG.md @@ -4,7 +4,7 @@ ### Enhancements -- The `wordpress-admin-schemes` mixin now uses `#006daa` for Fresh and `#bf332b` for Midnight, the primary colors of those schemes in `@wordpress/admin-ui` ([#PRNUM](https://github.com/WordPress/gutenberg/pull/PRNUM)). +- The `wordpress-admin-schemes` mixin now uses `#006daa` for Fresh and `#bf332b` for Midnight, the primary colors of those schemes in `@wordpress/admin-ui` ([#87673](https://github.com/WordPress/gutenberg/pull/87673)). - The `input-control` and `editor-input-reset` mixins now use the `--wpds-typography-font-size-md` design token for their font size ([#86961](https://github.com/WordPress/gutenberg/pull/86961)). ## 15.1.0 (2026-11-18) From 255d1e99ff6dd538dec5baf9119f0da1eb531233 Mon Sep 17 00:00:00 2001 From: Marco Ciampini Date: Mon, 30 Nov 2026 15:28:09 +0100 Subject: [PATCH 03/19] Base Styles: Use the new Fresh primary in the default custom properties --- packages/base-styles/CHANGELOG.md | 2 +- packages/base-styles/_default-custom-properties.scss | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/base-styles/CHANGELOG.md b/packages/base-styles/CHANGELOG.md index a0601f902e5602..1a3dcec31dd88e 100644 --- a/packages/base-styles/CHANGELOG.md +++ b/packages/base-styles/CHANGELOG.md @@ -4,7 +4,7 @@ ### Enhancements -- The `wordpress-admin-schemes` mixin now uses `#006daa` for Fresh and `#bf332b` for Midnight, the primary colors of those schemes in `@wordpress/admin-ui` ([#87673](https://github.com/WordPress/gutenberg/pull/87673)). +- The `wordpress-admin-schemes` mixin and the default custom properties now use `#006daa` for Fresh, and the mixin uses `#bf332b` for Midnight, the primary colors of those schemes in `@wordpress/admin-ui` ([#87673](https://github.com/WordPress/gutenberg/pull/87673)). - The `input-control` and `editor-input-reset` mixins now use the `--wpds-typography-font-size-md` design token for their font size ([#86961](https://github.com/WordPress/gutenberg/pull/86961)). ## 15.1.0 (2026-11-18) diff --git a/packages/base-styles/_default-custom-properties.scss b/packages/base-styles/_default-custom-properties.scss index d1f657d1f0a955..8debc213b5f014 100644 --- a/packages/base-styles/_default-custom-properties.scss +++ b/packages/base-styles/_default-custom-properties.scss @@ -17,5 +17,5 @@ // Fresh has no rule in the admin-schemes.css shipped by older WordPress versions, so it would inherit the :root default above. Plugins bundle these defaults while WordPress supplies the scheme stylesheet, so the rule must travel with them. body.admin-color-fresh { - @include mixins.admin-scheme(#007cba); + @include mixins.admin-scheme(#006daa); } From 8eb99605c1465e55aecb20dedf0c8a9dfd172e63 Mon Sep 17 00:00:00 2001 From: Marco Ciampini Date: Mon, 30 Nov 2026 15:28:13 +0100 Subject: [PATCH 04/19] Boot: Require no color warnings in the white label scheme test --- .../root/test/admin-scheme-sidebar.browser.test.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/boot/src/components/root/test/admin-scheme-sidebar.browser.test.tsx b/packages/boot/src/components/root/test/admin-scheme-sidebar.browser.test.tsx index 00cacd19ad5d72..a84dd56a7e49b7 100644 --- a/packages/boot/src/components/root/test/admin-scheme-sidebar.browser.test.tsx +++ b/packages/boot/src/components/root/test/admin-scheme-sidebar.browser.test.tsx @@ -1,4 +1,4 @@ -import { afterEach, describe, expect, it } from 'vitest'; +import { afterEach, describe, expect, it, vi } from 'vitest'; import { render } from 'vitest-browser-react'; import { getAdminThemeColors } from '@wordpress/admin-ui'; import { ThemeProvider } from '@wordpress/theme'; @@ -53,9 +53,13 @@ describe( 'admin color scheme sidebar', () => { 'keeps a white label on the brand fill in the %s scheme', async ( scheme ) => { document.body.className = `admin-color-${ scheme }`; + const onColorWarnings = vi.fn(); const view = await render( - +
{ label.slice( 0, 3 ).forEach( ( channel ) => { expect( channel ).toBeGreaterThanOrEqual( 230 ); } ); + // The label meets its contrast targets on the fill and its active state. + expect( onColorWarnings ).toHaveBeenCalledWith( [] ); } ); } ); From 1f4e6df0f6e710cd08d0a2af0f85c68d83b8ca02 Mon Sep 17 00:00:00 2001 From: Marco Ciampini Date: Mon, 30 Nov 2026 15:28:19 +0100 Subject: [PATCH 05/19] Admin UI: Correct the scheme seed comment and changelog category --- packages/admin-ui/CHANGELOG.md | 5 +---- packages/admin-ui/src/admin-theme-colors/index.ts | 6 +++--- packages/theme/src/color-ramps/test/index.test.ts | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/packages/admin-ui/CHANGELOG.md b/packages/admin-ui/CHANGELOG.md index a5356424f3d047..ddad0b66b2c1ec 100644 --- a/packages/admin-ui/CHANGELOG.md +++ b/packages/admin-ui/CHANGELOG.md @@ -2,12 +2,9 @@ ## Unreleased -### Enhancements - -- `getAdminThemeColors`: Darken the Modern, Fresh, and Midnight backgrounds, and the Fresh and Midnight primary colors, so the brand fill keeps a white label in the sidebar. Ectoplasm returns to its original Core colors, with a dark label ([#87673](https://github.com/WordPress/gutenberg/pull/87673)). - ### Bug Fixes +- `getAdminThemeColors`: Darken the Modern, Fresh, and Midnight backgrounds, and the Fresh and Midnight primary colors, so the brand fill keeps a white label in the sidebar. Ectoplasm returns to its original Core colors, with a dark label ([#87673](https://github.com/WordPress/gutenberg/pull/87673)). - `getAdminThemeColors`: Adjust the Blue and Sunrise background colors so the admin sidebar matches the WordPress 7.1 Core color schemes again ([#87420](https://github.com/WordPress/gutenberg/pull/87420)). ### Internal diff --git a/packages/admin-ui/src/admin-theme-colors/index.ts b/packages/admin-ui/src/admin-theme-colors/index.ts index cf24e93b152921..bef6fdb2741aee 100644 --- a/packages/admin-ui/src/admin-theme-colors/index.ts +++ b/packages/admin-ui/src/admin-theme-colors/index.ts @@ -17,9 +17,9 @@ const DEFAULT_THEME_COLORS: AdminThemeColors = { * Core's `$base-color` for those schemes. The Ectoplasm seeds use Core's * original colors, with the background tuned the same way. * - * The Modern, Fresh and Midnight backgrounds are the lightest that let the - * brand fill keep a white label at the required contrast, on the fill and on - * its active state. Fresh and Midnight also need a slightly darker primary. + * The Modern, Fresh and Midnight backgrounds are dark enough for the brand + * fill to keep a white label at the required contrast, on the fill and on its + * active state. Fresh and Midnight also need a slightly darker primary. */ export const ADMIN_THEME_COLORS = new Map< string, AdminThemeColors >( [ [ 'modern', DEFAULT_THEME_COLORS ], diff --git a/packages/theme/src/color-ramps/test/index.test.ts b/packages/theme/src/color-ramps/test/index.test.ts index 907ffb5298e46a..01b92533214991 100644 --- a/packages/theme/src/color-ramps/test/index.test.ts +++ b/packages/theme/src/color-ramps/test/index.test.ts @@ -262,7 +262,7 @@ describe( 'buildRamps', () => { ); it.each( [ - // The "Modern" and "Light" admin backgrounds. + // The former "Modern" and the "Light" admin backgrounds. '#222524', '#eaeeed', // Near-white seeds whose tint is barely perceptible. From 63380ce6354b9bd4d3fe1a00151edea4d20ade63 Mon Sep 17 00:00:00 2001 From: Marco Ciampini Date: Mon, 30 Nov 2026 15:37:02 +0100 Subject: [PATCH 06/19] Theme: Keep the legacy admin accent visible on the provider surfaces `ThemeProvider` copied the primary seed into `--wp-admin-theme-color` unchanged. Legacy consumers draw that variable as a stroke or as text on the neutral surfaces, so a seed that is too light or too dark for the provider background left them below 3:1, for example the Ectoplasm lime on white or every admin scheme primary in a dark sidebar. Keep the seed when it reaches 3:1 against the three neutral surfaces. Otherwise use the primary ramp's brand text color, which meets 4.5:1 there. --- packages/theme/CHANGELOG.md | 1 + packages/theme/README.md | 2 +- .../src/test/theme-provider.browser.test.tsx | 4 +- .../use-theme-provider-styles.jsdom.test.tsx | 43 ++++++++++++++++--- .../theme/src/use-theme-provider-styles.ts | 36 +++++++++++++++- 5 files changed, 76 insertions(+), 10 deletions(-) diff --git a/packages/theme/CHANGELOG.md b/packages/theme/CHANGELOG.md index 98a6a949b409a7..4739ac0e5fe1d1 100644 --- a/packages/theme/CHANGELOG.md +++ b/packages/theme/CHANGELOG.md @@ -10,6 +10,7 @@ ### Bug Fixes +- `ThemeProvider`: The legacy `--wp-admin-theme-color` variable uses the brand text color when the primary seed has less than 3:1 contrast against the neutral surfaces, so legacy accents stay visible ([#87673](https://github.com/WordPress/gutenberg/pull/87673)). - Use the WCAG sRGB luminance coefficients when checking generated colors against contrast thresholds ([#87174](https://github.com/WordPress/gutenberg/pull/87174)). ### Internal diff --git a/packages/theme/README.md b/packages/theme/README.md index 7f696afe4e548a..2775f8f84b9bea 100644 --- a/packages/theme/README.md +++ b/packages/theme/README.md @@ -190,7 +190,7 @@ The callback reports failures from the generated ramp checks and a defined set o The contrast warnings also cover the focus-ring color and the resting and active strong brand fills against all three neutral surfaces and the brand surface at a 3:1 minimum. Menus can use a solid brand fill to indicate keyboard focus, so a contrasting ring color alone is not enough. The primary ramp adjusts its fills and focus ring when these constraints are not met, and moves its seed when the text on its fills or its active state still falls short. Brand text targets 4.5:1 on the three neutral surfaces and the brand surface. These checks use the final generated colors after these adjustments. Unresolved pairs still produce warnings. -For example, with the default primary `#3858e9` and background `#1e1e1e`, the primary fill adjusts to `#4367f9` so the brand fills and focus ring meet the checked 3:1 targets. The supplied primary seed remains available through the resolved provider settings and legacy admin color variables. +For example, with the default primary `#3858e9` and background `#1e1e1e`, the primary fill adjusts to `#4367f9` so the brand fills and focus ring meet the checked 3:1 targets. The supplied primary seed remains available through the resolved provider settings. The legacy `--wp-admin-theme-color` variable keeps the seed when it has at least 3:1 contrast against the three neutral surfaces. Otherwise, as in this example, it uses the brand text color (`--wpds-color-foreground-interactive-brand`). ### TypeScript props and warnings diff --git a/packages/theme/src/test/theme-provider.browser.test.tsx b/packages/theme/src/test/theme-provider.browser.test.tsx index acd0159e55e744..9306a16966a71b 100644 --- a/packages/theme/src/test/theme-provider.browser.test.tsx +++ b/packages/theme/src/test/theme-provider.browser.test.tsx @@ -98,7 +98,7 @@ describe( 'ThemeProvider', () => { it( 'keeps legacy accent text readable when the brand fill moves away from the seed', async () => { await render( Legacy accent @@ -106,7 +106,7 @@ describe( 'ThemeProvider', () => { const child = screen.getByText( 'Legacy accent' ); const accent = readProp( child, '--wp-components-color-accent' ); - expect( accent ).toBe( DEFAULT_PRIMARY ); + expect( accent ).toBe( '#d63638' ); expect( readProp( child, BRAND_BG ) ).not.toBe( accent ); expect( getContrast( diff --git a/packages/theme/src/test/use-theme-provider-styles.jsdom.test.tsx b/packages/theme/src/test/use-theme-provider-styles.jsdom.test.tsx index f97ec7c18230cc..67bdb1b62733b2 100644 --- a/packages/theme/src/test/use-theme-provider-styles.jsdom.test.tsx +++ b/packages/theme/src/test/use-theme-provider-styles.jsdom.test.tsx @@ -18,6 +18,7 @@ import { renderHook } from '@testing-library/react'; import { type ReactNode } from 'react'; import { ThemeProvider } from '../theme-provider'; import { useThemeProviderStyles } from '../use-theme-provider-styles'; +import { getContrast } from '../color-ramps/lib/color-utils'; import { DEFAULT_SEED_COLORS } from '../color-ramps'; describe( 'useThemeProviderStyles', () => { @@ -139,7 +140,7 @@ describe( 'useThemeProviderStyles', () => { it( 'keeps white legacy accent text when it fits the legacy accent', () => { const { result } = renderHook( () => useThemeProviderStyles( { - color: { primary: '#007cba', background: '#aaa' }, + color: { primary: '#d63638', background: '#222524' }, } ) ); const styles = result.current.themeProviderStyles; @@ -207,19 +208,51 @@ describe( 'useThemeProviderStyles', () => { describe( 'legacy wp-admin / wp-components bridge', () => { it( 'derives the wp-admin theme color from the primary seed', () => { const { result } = renderHook( () => - useThemeProviderStyles( { color: { primary: '#1e90ff' } } ) + useThemeProviderStyles( { color: { primary: '#1067cc' } } ) ); const styles = result.current.themeProviderStyles; - expect( styles[ '--wp-admin-theme-color' ] ).toBe( '#1e90ff' ); + expect( styles[ '--wp-admin-theme-color' ] ).toBe( '#1067cc' ); expect( styles[ '--wp-admin-theme-color--rgb' ] ).toBe( - '30, 144, 255' + '16, 103, 204' ); } ); + it.each( [ + // A light seed on a light background. + { primary: '#a3b745', background: DEFAULT_SEED_COLORS.background }, + // A mid-lightness seed on a dark background. + { primary: '#916745', background: '#5b534d' }, + ] )( + 'uses the brand text color when the seed $primary lacks contrast on $background', + ( { primary, background } ) => { + const { result } = renderHook( () => + useThemeProviderStyles( { color: { primary, background } } ) + ); + const styles = result.current.themeProviderStyles as Record< + string, + string + >; + const accent = styles[ '--wp-admin-theme-color' ]; + + expect( accent ).toBe( + styles[ '--wpds-color-foreground-interactive-brand' ] + ); + for ( const surface of [ + '--wpds-color-background-surface-neutral', + '--wpds-color-background-surface-neutral-strong', + '--wpds-color-background-surface-neutral-weak', + ] ) { + expect( + getContrast( accent, styles[ surface ] ) + ).toBeGreaterThanOrEqual( 3 ); + } + } + ); + it( 'aliases the wp-components colors onto the wp-admin and semantic tokens', () => { const { result } = renderHook( () => - useThemeProviderStyles( { color: { primary: '#1e90ff' } } ) + useThemeProviderStyles( { color: { primary: '#1067cc' } } ) ); const styles = result.current.themeProviderStyles; diff --git a/packages/theme/src/use-theme-provider-styles.ts b/packages/theme/src/use-theme-provider-styles.ts index 2325d6ca63a05a..4b427f998f8fbe 100644 --- a/packages/theme/src/use-theme-provider-styles.ts +++ b/packages/theme/src/use-theme-provider-styles.ts @@ -19,7 +19,11 @@ import { type RampResult, } from './color-ramps/index.ts'; import { getColorString, getContrast } from './color-ramps/lib/color-utils.ts'; -import { MINIMUM_TEXT_CONTRAST } from './semantic-color-contrast-pairs.ts'; +import { + MINIMUM_NON_TEXT_CONTRAST, + MINIMUM_TEXT_CONTRAST, + NEUTRAL_CONTRAST_SURFACES, +} from './semantic-color-contrast-pairs.ts'; import { DEFAULT_RAMPS } from './color-ramps/lib/default-ramps.ts'; import type { ThemeProviderProps } from './types.ts'; import { @@ -176,6 +180,30 @@ function colorTokensCSS( return entries; } +/** + * Returns the color for the legacy `--wp-admin-theme-color` variable. Its + * consumers draw it as a stroke or as text on the neutral surfaces, so a seed + * with less than 3:1 contrast on any of them is swapped for the brand text + * color, which meets the text target there. + * + * @param seed The primary seed. + * @param bgRamp The background ramp. + * @param primaryRamp The primary ramp. + * @return The legacy accent color. + */ +function getLegacyAccent( + seed: string, + bgRamp: RampResult, + primaryRamp: RampResult +): string { + const fitsSurfaces = Object.values( NEUTRAL_CONTRAST_SURFACES ).every( + ( step ) => + getContrast( seed, bgRamp.ramp[ step ] ) >= + MINIMUM_NON_TEXT_CONTRAST + ); + return fitsSurfaces ? seed : primaryRamp.ramp.fgSurface3; +} + function generateStyles( { primary, colorEntries, @@ -236,7 +264,11 @@ function generateThemeProviderColors( return { styles: generateStyles( { - primary: seeds.primary, + primary: getLegacyAccent( + seeds.primary, + bgRamp, + computedColorRamps.get( 'primary' )! + ), colorEntries, } ), warnings: collectThemeProviderColorWarnings( From 460bbb08abf8effe34a5754efa59cb3931433970 Mon Sep 17 00:00:00 2001 From: Marco Ciampini Date: Mon, 30 Nov 2026 15:37:09 +0100 Subject: [PATCH 07/19] Admin UI: Match the Ectoplasm sidebar to #523f6d exactly --- packages/admin-ui/src/admin-theme-colors/index.ts | 2 +- packages/theme/src/color-ramps/stories/index.story.tsx | 2 +- .../stories/design-system/theme-example-application.story.tsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/admin-ui/src/admin-theme-colors/index.ts b/packages/admin-ui/src/admin-theme-colors/index.ts index bef6fdb2741aee..9547c10929d126 100644 --- a/packages/admin-ui/src/admin-theme-colors/index.ts +++ b/packages/admin-ui/src/admin-theme-colors/index.ts @@ -28,7 +28,7 @@ export const ADMIN_THEME_COLORS = new Map< string, AdminThemeColors >( [ [ 'coffee', { primary: '#916745', background: '#5b534d' } ], [ 'ocean', { primary: '#567958', background: '#5f787f' } ], [ 'blue', { primary: '#437aa8', background: '#24567e' } ], - [ 'ectoplasm', { primary: '#a3b745', background: '#54456b' } ], + [ 'ectoplasm', { primary: '#a3b745', background: '#544769' } ], [ 'sunrise', { primary: '#ad631e', background: '#933330' } ], [ 'light', { primary: '#007cba', background: '#eaeeed' } ], ] ); diff --git a/packages/theme/src/color-ramps/stories/index.story.tsx b/packages/theme/src/color-ramps/stories/index.story.tsx index 3ba5727524412b..f6e8fb65e1e85c 100644 --- a/packages/theme/src/color-ramps/stories/index.story.tsx +++ b/packages/theme/src/color-ramps/stories/index.story.tsx @@ -242,7 +242,7 @@ const SAMPLE_COMBINATIONS = [ { label: 'Ectoplasm', source: 'WordPress admin scheme', - background: '#54456b', + background: '#544769', primary: '#a3b745', }, { diff --git a/storybook/stories/design-system/theme-example-application.story.tsx b/storybook/stories/design-system/theme-example-application.story.tsx index 32c5dca18939a9..e4b02d76f579c7 100644 --- a/storybook/stories/design-system/theme-example-application.story.tsx +++ b/storybook/stories/design-system/theme-example-application.story.tsx @@ -35,7 +35,7 @@ const SIDEBAR_THEME_PRESETS = [ { id: 'ectoplasm', title: 'Ectoplasm', - colors: { primary: '#a3b745', background: '#54456b' }, + colors: { primary: '#a3b745', background: '#544769' }, }, ] as const; From 56a2441856965a69f65011d1a4d04d9494978008 Mon Sep 17 00:00:00 2001 From: Marco Ciampini Date: Mon, 30 Nov 2026 15:48:40 +0100 Subject: [PATCH 08/19] Theme: Keep white text readable on the legacy admin accent Legacy consumers often draw `--wp-admin-theme-color` as a fill under white text. Swapping a low-contrast seed for the brand text color broke those fills on dark backgrounds, where that color is light. Instead, keep the seed when white text reaches 4.5:1 on it, and otherwise darken it, keeping its hue, until it does. A color that dark also stands out from light surfaces. Every bundled admin scheme except Ectoplasm keeps its seed. --- packages/theme/CHANGELOG.md | 2 +- packages/theme/README.md | 2 +- .../src/test/theme-provider.browser.test.tsx | 4 +- .../use-theme-provider-styles.jsdom.test.tsx | 34 ++++------ .../theme/src/use-theme-provider-styles.ts | 66 +++++++++++-------- 5 files changed, 55 insertions(+), 53 deletions(-) diff --git a/packages/theme/CHANGELOG.md b/packages/theme/CHANGELOG.md index 4739ac0e5fe1d1..8aa8e83627f2c5 100644 --- a/packages/theme/CHANGELOG.md +++ b/packages/theme/CHANGELOG.md @@ -10,7 +10,7 @@ ### Bug Fixes -- `ThemeProvider`: The legacy `--wp-admin-theme-color` variable uses the brand text color when the primary seed has less than 3:1 contrast against the neutral surfaces, so legacy accents stay visible ([#87673](https://github.com/WordPress/gutenberg/pull/87673)). +- `ThemeProvider`: Darken the legacy `--wp-admin-theme-color` variable when the primary seed is too light for white text at 4.5:1, since legacy consumers put white text on it ([#87673](https://github.com/WordPress/gutenberg/pull/87673)). - Use the WCAG sRGB luminance coefficients when checking generated colors against contrast thresholds ([#87174](https://github.com/WordPress/gutenberg/pull/87174)). ### Internal diff --git a/packages/theme/README.md b/packages/theme/README.md index 2775f8f84b9bea..9aa50872c9452a 100644 --- a/packages/theme/README.md +++ b/packages/theme/README.md @@ -190,7 +190,7 @@ The callback reports failures from the generated ramp checks and a defined set o The contrast warnings also cover the focus-ring color and the resting and active strong brand fills against all three neutral surfaces and the brand surface at a 3:1 minimum. Menus can use a solid brand fill to indicate keyboard focus, so a contrasting ring color alone is not enough. The primary ramp adjusts its fills and focus ring when these constraints are not met, and moves its seed when the text on its fills or its active state still falls short. Brand text targets 4.5:1 on the three neutral surfaces and the brand surface. These checks use the final generated colors after these adjustments. Unresolved pairs still produce warnings. -For example, with the default primary `#3858e9` and background `#1e1e1e`, the primary fill adjusts to `#4367f9` so the brand fills and focus ring meet the checked 3:1 targets. The supplied primary seed remains available through the resolved provider settings. The legacy `--wp-admin-theme-color` variable keeps the seed when it has at least 3:1 contrast against the three neutral surfaces. Otherwise, as in this example, it uses the brand text color (`--wpds-color-foreground-interactive-brand`). +For example, with the default primary `#3858e9` and background `#1e1e1e`, the primary fill adjusts to `#4367f9` so the brand fills and focus ring meet the checked 3:1 targets. The supplied primary seed remains available through the resolved provider settings and legacy admin color variables. Legacy consumers often put white text on `--wp-admin-theme-color`, so a seed too light for white text at 4.5:1 is darkened in that variable, keeping its hue, until white text meets 4.5:1. ### TypeScript props and warnings diff --git a/packages/theme/src/test/theme-provider.browser.test.tsx b/packages/theme/src/test/theme-provider.browser.test.tsx index 9306a16966a71b..acd0159e55e744 100644 --- a/packages/theme/src/test/theme-provider.browser.test.tsx +++ b/packages/theme/src/test/theme-provider.browser.test.tsx @@ -98,7 +98,7 @@ describe( 'ThemeProvider', () => { it( 'keeps legacy accent text readable when the brand fill moves away from the seed', async () => { await render( Legacy accent @@ -106,7 +106,7 @@ describe( 'ThemeProvider', () => { const child = screen.getByText( 'Legacy accent' ); const accent = readProp( child, '--wp-components-color-accent' ); - expect( accent ).toBe( '#d63638' ); + expect( accent ).toBe( DEFAULT_PRIMARY ); expect( readProp( child, BRAND_BG ) ).not.toBe( accent ); expect( getContrast( diff --git a/packages/theme/src/test/use-theme-provider-styles.jsdom.test.tsx b/packages/theme/src/test/use-theme-provider-styles.jsdom.test.tsx index 67bdb1b62733b2..cfba3cc33ab983 100644 --- a/packages/theme/src/test/use-theme-provider-styles.jsdom.test.tsx +++ b/packages/theme/src/test/use-theme-provider-styles.jsdom.test.tsx @@ -140,7 +140,7 @@ describe( 'useThemeProviderStyles', () => { it( 'keeps white legacy accent text when it fits the legacy accent', () => { const { result } = renderHook( () => useThemeProviderStyles( { - color: { primary: '#d63638', background: '#222524' }, + color: { primary: '#007cba', background: '#aaa' }, } ) ); const styles = result.current.themeProviderStyles; @@ -195,8 +195,7 @@ describe( 'useThemeProviderStyles', () => { background: '#222222', } ); expect( result.current.themeProviderStyles ).toHaveProperty( - '--wp-admin-theme-color', - '#abcdef' + '--wp-admin-theme-color' ); expect( result.current.themeProviderStyles ).toHaveProperty( '--wpds-color-background-interactive-brand-strong', @@ -219,15 +218,16 @@ describe( 'useThemeProviderStyles', () => { } ); it.each( [ - // A light seed on a light background. - { primary: '#a3b745', background: DEFAULT_SEED_COLORS.background }, - // A mid-lightness seed on a dark background. - { primary: '#916745', background: '#5b534d' }, + // Light and dark backgrounds. + DEFAULT_SEED_COLORS.background, + '#544769', ] )( - 'uses the brand text color when the seed $primary lacks contrast on $background', - ( { primary, background } ) => { + 'darkens a seed too light for white text on %s', + ( background ) => { const { result } = renderHook( () => - useThemeProviderStyles( { color: { primary, background } } ) + useThemeProviderStyles( { + color: { primary: '#a3b745', background }, + } ) ); const styles = result.current.themeProviderStyles as Record< string, @@ -235,18 +235,10 @@ describe( 'useThemeProviderStyles', () => { >; const accent = styles[ '--wp-admin-theme-color' ]; - expect( accent ).toBe( - styles[ '--wpds-color-foreground-interactive-brand' ] + expect( getContrast( accent, '#fff' ) ).toBeGreaterThanOrEqual( + 4.5 ); - for ( const surface of [ - '--wpds-color-background-surface-neutral', - '--wpds-color-background-surface-neutral-strong', - '--wpds-color-background-surface-neutral-weak', - ] ) { - expect( - getContrast( accent, styles[ surface ] ) - ).toBeGreaterThanOrEqual( 3 ); - } + expect( getContrast( accent, '#fff' ) ).toBeLessThan( 5 ); } ); diff --git a/packages/theme/src/use-theme-provider-styles.ts b/packages/theme/src/use-theme-provider-styles.ts index 4b427f998f8fbe..804ef6719b6649 100644 --- a/packages/theme/src/use-theme-provider-styles.ts +++ b/packages/theme/src/use-theme-provider-styles.ts @@ -2,10 +2,12 @@ import type { CSSProperties } from 'react'; import { ColorSpace, clone, + get, set, to, sRGB, HSL, + OKLCH, type PlainColorObject, } from 'colorjs.io/fn'; import memoize from 'memize'; @@ -18,12 +20,14 @@ import { DEFAULT_SEED_COLORS, type RampResult, } from './color-ramps/index.ts'; -import { getColorString, getContrast } from './color-ramps/lib/color-utils.ts'; import { - MINIMUM_NON_TEXT_CONTRAST, - MINIMUM_TEXT_CONTRAST, - NEUTRAL_CONTRAST_SURFACES, -} from './semantic-color-contrast-pairs.ts'; + clampToGamut, + getColorString, + getContrast, + parseSeedColor, +} from './color-ramps/lib/color-utils.ts'; +import { MAX_BISECTION_ITERATIONS } from './color-ramps/lib/constants.ts'; +import { MINIMUM_TEXT_CONTRAST } from './semantic-color-contrast-pairs.ts'; import { DEFAULT_RAMPS } from './color-ramps/lib/default-ramps.ts'; import type { ThemeProviderProps } from './types.ts'; import { @@ -181,27 +185,37 @@ function colorTokensCSS( } /** - * Returns the color for the legacy `--wp-admin-theme-color` variable. Its - * consumers draw it as a stroke or as text on the neutral surfaces, so a seed - * with less than 3:1 contrast on any of them is swapped for the brand text - * color, which meets the text target there. + * Returns the color for the legacy `--wp-admin-theme-color` variable. Many of + * its consumers draw it as a fill under white text, so a seed that is too + * light for white text is darkened, keeping its hue, until white text meets + * the text contrast target. Such a color also stands out from light surfaces. * - * @param seed The primary seed. - * @param bgRamp The background ramp. - * @param primaryRamp The primary ramp. + * @param seed The primary seed. * @return The legacy accent color. */ -function getLegacyAccent( - seed: string, - bgRamp: RampResult, - primaryRamp: RampResult -): string { - const fitsSurfaces = Object.values( NEUTRAL_CONTRAST_SURFACES ).every( - ( step ) => - getContrast( seed, bgRamp.ramp[ step ] ) >= - MINIMUM_NON_TEXT_CONTRAST - ); - return fitsSurfaces ? seed : primaryRamp.ramp.fgSurface3; +function getLegacyAccent( seed: string ): string { + if ( getContrast( seed, '#fff' ) >= MINIMUM_TEXT_CONTRAST ) { + return seed; + } + const parsed = clampToGamut( parseSeedColor( seed ) ); + const withLightness = ( l: number ) => + getColorString( + clampToGamut( set( clone( parsed ), [ OKLCH, 'l' ], l ) ) + ); + // Black always passes, the seed fails. + let passingL = 0; + let failingL = get( parsed, [ OKLCH, 'l' ] ) ?? 1; + for ( let i = 0; i < MAX_BISECTION_ITERATIONS; i++ ) { + const l = ( passingL + failingL ) / 2; + if ( + getContrast( withLightness( l ), '#fff' ) >= MINIMUM_TEXT_CONTRAST + ) { + passingL = l; + } else { + failingL = l; + } + } + return withLightness( passingL ); } function generateStyles( { @@ -264,11 +278,7 @@ function generateThemeProviderColors( return { styles: generateStyles( { - primary: getLegacyAccent( - seeds.primary, - bgRamp, - computedColorRamps.get( 'primary' )! - ), + primary: getLegacyAccent( seeds.primary ), colorEntries, } ), warnings: collectThemeProviderColorWarnings( From 7f30c124bea563b96a0147f4ee6e709351903f60 Mon Sep 17 00:00:00 2001 From: Marco Ciampini Date: Mon, 30 Nov 2026 15:48:46 +0100 Subject: [PATCH 09/19] Base Styles: Note why the Ectoplasm admin accent is not its primary --- packages/base-styles/_mixins.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/base-styles/_mixins.scss b/packages/base-styles/_mixins.scss index 354d60ba1fe971..90f5d895a661a8 100644 --- a/packages/base-styles/_mixins.scss +++ b/packages/base-styles/_mixins.scss @@ -447,6 +447,7 @@ @include admin-scheme(#916745); } + // Not Ectoplasm's `#a3b745` primary: legacy consumers put white text on this color. body.admin-color-ectoplasm { @include admin-scheme(#646c3e); } From 84c182dc7a7db94a1af4387c41b1369fa5aeeda0 Mon Sep 17 00:00:00 2001 From: Marco Ciampini Date: Mon, 30 Nov 2026 16:08:13 +0100 Subject: [PATCH 10/19] Revert "Base Styles: Note why the Ectoplasm admin accent is not its primary" This reverts commit 7f30c124bea563b96a0147f4ee6e709351903f60. --- packages/base-styles/_mixins.scss | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/base-styles/_mixins.scss b/packages/base-styles/_mixins.scss index 90f5d895a661a8..354d60ba1fe971 100644 --- a/packages/base-styles/_mixins.scss +++ b/packages/base-styles/_mixins.scss @@ -447,7 +447,6 @@ @include admin-scheme(#916745); } - // Not Ectoplasm's `#a3b745` primary: legacy consumers put white text on this color. body.admin-color-ectoplasm { @include admin-scheme(#646c3e); } From 0e29c06d71302e96f386ad746bfb8bf6f94a9bc1 Mon Sep 17 00:00:00 2001 From: Marco Ciampini Date: Mon, 30 Nov 2026 16:08:13 +0100 Subject: [PATCH 11/19] Revert "Theme: Keep white text readable on the legacy admin accent" This reverts commit 56a2441856965a69f65011d1a4d04d9494978008. --- packages/theme/CHANGELOG.md | 2 +- packages/theme/README.md | 2 +- .../src/test/theme-provider.browser.test.tsx | 4 +- .../use-theme-provider-styles.jsdom.test.tsx | 34 ++++++---- .../theme/src/use-theme-provider-styles.ts | 66 ++++++++----------- 5 files changed, 53 insertions(+), 55 deletions(-) diff --git a/packages/theme/CHANGELOG.md b/packages/theme/CHANGELOG.md index 8aa8e83627f2c5..4739ac0e5fe1d1 100644 --- a/packages/theme/CHANGELOG.md +++ b/packages/theme/CHANGELOG.md @@ -10,7 +10,7 @@ ### Bug Fixes -- `ThemeProvider`: Darken the legacy `--wp-admin-theme-color` variable when the primary seed is too light for white text at 4.5:1, since legacy consumers put white text on it ([#87673](https://github.com/WordPress/gutenberg/pull/87673)). +- `ThemeProvider`: The legacy `--wp-admin-theme-color` variable uses the brand text color when the primary seed has less than 3:1 contrast against the neutral surfaces, so legacy accents stay visible ([#87673](https://github.com/WordPress/gutenberg/pull/87673)). - Use the WCAG sRGB luminance coefficients when checking generated colors against contrast thresholds ([#87174](https://github.com/WordPress/gutenberg/pull/87174)). ### Internal diff --git a/packages/theme/README.md b/packages/theme/README.md index 9aa50872c9452a..2775f8f84b9bea 100644 --- a/packages/theme/README.md +++ b/packages/theme/README.md @@ -190,7 +190,7 @@ The callback reports failures from the generated ramp checks and a defined set o The contrast warnings also cover the focus-ring color and the resting and active strong brand fills against all three neutral surfaces and the brand surface at a 3:1 minimum. Menus can use a solid brand fill to indicate keyboard focus, so a contrasting ring color alone is not enough. The primary ramp adjusts its fills and focus ring when these constraints are not met, and moves its seed when the text on its fills or its active state still falls short. Brand text targets 4.5:1 on the three neutral surfaces and the brand surface. These checks use the final generated colors after these adjustments. Unresolved pairs still produce warnings. -For example, with the default primary `#3858e9` and background `#1e1e1e`, the primary fill adjusts to `#4367f9` so the brand fills and focus ring meet the checked 3:1 targets. The supplied primary seed remains available through the resolved provider settings and legacy admin color variables. Legacy consumers often put white text on `--wp-admin-theme-color`, so a seed too light for white text at 4.5:1 is darkened in that variable, keeping its hue, until white text meets 4.5:1. +For example, with the default primary `#3858e9` and background `#1e1e1e`, the primary fill adjusts to `#4367f9` so the brand fills and focus ring meet the checked 3:1 targets. The supplied primary seed remains available through the resolved provider settings. The legacy `--wp-admin-theme-color` variable keeps the seed when it has at least 3:1 contrast against the three neutral surfaces. Otherwise, as in this example, it uses the brand text color (`--wpds-color-foreground-interactive-brand`). ### TypeScript props and warnings diff --git a/packages/theme/src/test/theme-provider.browser.test.tsx b/packages/theme/src/test/theme-provider.browser.test.tsx index acd0159e55e744..9306a16966a71b 100644 --- a/packages/theme/src/test/theme-provider.browser.test.tsx +++ b/packages/theme/src/test/theme-provider.browser.test.tsx @@ -98,7 +98,7 @@ describe( 'ThemeProvider', () => { it( 'keeps legacy accent text readable when the brand fill moves away from the seed', async () => { await render( Legacy accent @@ -106,7 +106,7 @@ describe( 'ThemeProvider', () => { const child = screen.getByText( 'Legacy accent' ); const accent = readProp( child, '--wp-components-color-accent' ); - expect( accent ).toBe( DEFAULT_PRIMARY ); + expect( accent ).toBe( '#d63638' ); expect( readProp( child, BRAND_BG ) ).not.toBe( accent ); expect( getContrast( diff --git a/packages/theme/src/test/use-theme-provider-styles.jsdom.test.tsx b/packages/theme/src/test/use-theme-provider-styles.jsdom.test.tsx index cfba3cc33ab983..67bdb1b62733b2 100644 --- a/packages/theme/src/test/use-theme-provider-styles.jsdom.test.tsx +++ b/packages/theme/src/test/use-theme-provider-styles.jsdom.test.tsx @@ -140,7 +140,7 @@ describe( 'useThemeProviderStyles', () => { it( 'keeps white legacy accent text when it fits the legacy accent', () => { const { result } = renderHook( () => useThemeProviderStyles( { - color: { primary: '#007cba', background: '#aaa' }, + color: { primary: '#d63638', background: '#222524' }, } ) ); const styles = result.current.themeProviderStyles; @@ -195,7 +195,8 @@ describe( 'useThemeProviderStyles', () => { background: '#222222', } ); expect( result.current.themeProviderStyles ).toHaveProperty( - '--wp-admin-theme-color' + '--wp-admin-theme-color', + '#abcdef' ); expect( result.current.themeProviderStyles ).toHaveProperty( '--wpds-color-background-interactive-brand-strong', @@ -218,16 +219,15 @@ describe( 'useThemeProviderStyles', () => { } ); it.each( [ - // Light and dark backgrounds. - DEFAULT_SEED_COLORS.background, - '#544769', + // A light seed on a light background. + { primary: '#a3b745', background: DEFAULT_SEED_COLORS.background }, + // A mid-lightness seed on a dark background. + { primary: '#916745', background: '#5b534d' }, ] )( - 'darkens a seed too light for white text on %s', - ( background ) => { + 'uses the brand text color when the seed $primary lacks contrast on $background', + ( { primary, background } ) => { const { result } = renderHook( () => - useThemeProviderStyles( { - color: { primary: '#a3b745', background }, - } ) + useThemeProviderStyles( { color: { primary, background } } ) ); const styles = result.current.themeProviderStyles as Record< string, @@ -235,10 +235,18 @@ describe( 'useThemeProviderStyles', () => { >; const accent = styles[ '--wp-admin-theme-color' ]; - expect( getContrast( accent, '#fff' ) ).toBeGreaterThanOrEqual( - 4.5 + expect( accent ).toBe( + styles[ '--wpds-color-foreground-interactive-brand' ] ); - expect( getContrast( accent, '#fff' ) ).toBeLessThan( 5 ); + for ( const surface of [ + '--wpds-color-background-surface-neutral', + '--wpds-color-background-surface-neutral-strong', + '--wpds-color-background-surface-neutral-weak', + ] ) { + expect( + getContrast( accent, styles[ surface ] ) + ).toBeGreaterThanOrEqual( 3 ); + } } ); diff --git a/packages/theme/src/use-theme-provider-styles.ts b/packages/theme/src/use-theme-provider-styles.ts index 804ef6719b6649..4b427f998f8fbe 100644 --- a/packages/theme/src/use-theme-provider-styles.ts +++ b/packages/theme/src/use-theme-provider-styles.ts @@ -2,12 +2,10 @@ import type { CSSProperties } from 'react'; import { ColorSpace, clone, - get, set, to, sRGB, HSL, - OKLCH, type PlainColorObject, } from 'colorjs.io/fn'; import memoize from 'memize'; @@ -20,14 +18,12 @@ import { DEFAULT_SEED_COLORS, type RampResult, } from './color-ramps/index.ts'; +import { getColorString, getContrast } from './color-ramps/lib/color-utils.ts'; import { - clampToGamut, - getColorString, - getContrast, - parseSeedColor, -} from './color-ramps/lib/color-utils.ts'; -import { MAX_BISECTION_ITERATIONS } from './color-ramps/lib/constants.ts'; -import { MINIMUM_TEXT_CONTRAST } from './semantic-color-contrast-pairs.ts'; + MINIMUM_NON_TEXT_CONTRAST, + MINIMUM_TEXT_CONTRAST, + NEUTRAL_CONTRAST_SURFACES, +} from './semantic-color-contrast-pairs.ts'; import { DEFAULT_RAMPS } from './color-ramps/lib/default-ramps.ts'; import type { ThemeProviderProps } from './types.ts'; import { @@ -185,37 +181,27 @@ function colorTokensCSS( } /** - * Returns the color for the legacy `--wp-admin-theme-color` variable. Many of - * its consumers draw it as a fill under white text, so a seed that is too - * light for white text is darkened, keeping its hue, until white text meets - * the text contrast target. Such a color also stands out from light surfaces. + * Returns the color for the legacy `--wp-admin-theme-color` variable. Its + * consumers draw it as a stroke or as text on the neutral surfaces, so a seed + * with less than 3:1 contrast on any of them is swapped for the brand text + * color, which meets the text target there. * - * @param seed The primary seed. + * @param seed The primary seed. + * @param bgRamp The background ramp. + * @param primaryRamp The primary ramp. * @return The legacy accent color. */ -function getLegacyAccent( seed: string ): string { - if ( getContrast( seed, '#fff' ) >= MINIMUM_TEXT_CONTRAST ) { - return seed; - } - const parsed = clampToGamut( parseSeedColor( seed ) ); - const withLightness = ( l: number ) => - getColorString( - clampToGamut( set( clone( parsed ), [ OKLCH, 'l' ], l ) ) - ); - // Black always passes, the seed fails. - let passingL = 0; - let failingL = get( parsed, [ OKLCH, 'l' ] ) ?? 1; - for ( let i = 0; i < MAX_BISECTION_ITERATIONS; i++ ) { - const l = ( passingL + failingL ) / 2; - if ( - getContrast( withLightness( l ), '#fff' ) >= MINIMUM_TEXT_CONTRAST - ) { - passingL = l; - } else { - failingL = l; - } - } - return withLightness( passingL ); +function getLegacyAccent( + seed: string, + bgRamp: RampResult, + primaryRamp: RampResult +): string { + const fitsSurfaces = Object.values( NEUTRAL_CONTRAST_SURFACES ).every( + ( step ) => + getContrast( seed, bgRamp.ramp[ step ] ) >= + MINIMUM_NON_TEXT_CONTRAST + ); + return fitsSurfaces ? seed : primaryRamp.ramp.fgSurface3; } function generateStyles( { @@ -278,7 +264,11 @@ function generateThemeProviderColors( return { styles: generateStyles( { - primary: getLegacyAccent( seeds.primary ), + primary: getLegacyAccent( + seeds.primary, + bgRamp, + computedColorRamps.get( 'primary' )! + ), colorEntries, } ), warnings: collectThemeProviderColorWarnings( From 3e5abf74bbf7f86fb9abd33d2de32afd09fdd7fa Mon Sep 17 00:00:00 2001 From: Marco Ciampini Date: Mon, 30 Nov 2026 16:08:14 +0100 Subject: [PATCH 12/19] Revert "Theme: Keep the legacy admin accent visible on the provider surfaces" This reverts commit 63380ce6354b9bd4d3fe1a00151edea4d20ade63. --- packages/theme/CHANGELOG.md | 1 - packages/theme/README.md | 2 +- .../src/test/theme-provider.browser.test.tsx | 4 +- .../use-theme-provider-styles.jsdom.test.tsx | 43 +++---------------- .../theme/src/use-theme-provider-styles.ts | 36 +--------------- 5 files changed, 10 insertions(+), 76 deletions(-) diff --git a/packages/theme/CHANGELOG.md b/packages/theme/CHANGELOG.md index 4739ac0e5fe1d1..98a6a949b409a7 100644 --- a/packages/theme/CHANGELOG.md +++ b/packages/theme/CHANGELOG.md @@ -10,7 +10,6 @@ ### Bug Fixes -- `ThemeProvider`: The legacy `--wp-admin-theme-color` variable uses the brand text color when the primary seed has less than 3:1 contrast against the neutral surfaces, so legacy accents stay visible ([#87673](https://github.com/WordPress/gutenberg/pull/87673)). - Use the WCAG sRGB luminance coefficients when checking generated colors against contrast thresholds ([#87174](https://github.com/WordPress/gutenberg/pull/87174)). ### Internal diff --git a/packages/theme/README.md b/packages/theme/README.md index 2775f8f84b9bea..7f696afe4e548a 100644 --- a/packages/theme/README.md +++ b/packages/theme/README.md @@ -190,7 +190,7 @@ The callback reports failures from the generated ramp checks and a defined set o The contrast warnings also cover the focus-ring color and the resting and active strong brand fills against all three neutral surfaces and the brand surface at a 3:1 minimum. Menus can use a solid brand fill to indicate keyboard focus, so a contrasting ring color alone is not enough. The primary ramp adjusts its fills and focus ring when these constraints are not met, and moves its seed when the text on its fills or its active state still falls short. Brand text targets 4.5:1 on the three neutral surfaces and the brand surface. These checks use the final generated colors after these adjustments. Unresolved pairs still produce warnings. -For example, with the default primary `#3858e9` and background `#1e1e1e`, the primary fill adjusts to `#4367f9` so the brand fills and focus ring meet the checked 3:1 targets. The supplied primary seed remains available through the resolved provider settings. The legacy `--wp-admin-theme-color` variable keeps the seed when it has at least 3:1 contrast against the three neutral surfaces. Otherwise, as in this example, it uses the brand text color (`--wpds-color-foreground-interactive-brand`). +For example, with the default primary `#3858e9` and background `#1e1e1e`, the primary fill adjusts to `#4367f9` so the brand fills and focus ring meet the checked 3:1 targets. The supplied primary seed remains available through the resolved provider settings and legacy admin color variables. ### TypeScript props and warnings diff --git a/packages/theme/src/test/theme-provider.browser.test.tsx b/packages/theme/src/test/theme-provider.browser.test.tsx index 9306a16966a71b..acd0159e55e744 100644 --- a/packages/theme/src/test/theme-provider.browser.test.tsx +++ b/packages/theme/src/test/theme-provider.browser.test.tsx @@ -98,7 +98,7 @@ describe( 'ThemeProvider', () => { it( 'keeps legacy accent text readable when the brand fill moves away from the seed', async () => { await render( Legacy accent @@ -106,7 +106,7 @@ describe( 'ThemeProvider', () => { const child = screen.getByText( 'Legacy accent' ); const accent = readProp( child, '--wp-components-color-accent' ); - expect( accent ).toBe( '#d63638' ); + expect( accent ).toBe( DEFAULT_PRIMARY ); expect( readProp( child, BRAND_BG ) ).not.toBe( accent ); expect( getContrast( diff --git a/packages/theme/src/test/use-theme-provider-styles.jsdom.test.tsx b/packages/theme/src/test/use-theme-provider-styles.jsdom.test.tsx index 67bdb1b62733b2..f97ec7c18230cc 100644 --- a/packages/theme/src/test/use-theme-provider-styles.jsdom.test.tsx +++ b/packages/theme/src/test/use-theme-provider-styles.jsdom.test.tsx @@ -18,7 +18,6 @@ import { renderHook } from '@testing-library/react'; import { type ReactNode } from 'react'; import { ThemeProvider } from '../theme-provider'; import { useThemeProviderStyles } from '../use-theme-provider-styles'; -import { getContrast } from '../color-ramps/lib/color-utils'; import { DEFAULT_SEED_COLORS } from '../color-ramps'; describe( 'useThemeProviderStyles', () => { @@ -140,7 +139,7 @@ describe( 'useThemeProviderStyles', () => { it( 'keeps white legacy accent text when it fits the legacy accent', () => { const { result } = renderHook( () => useThemeProviderStyles( { - color: { primary: '#d63638', background: '#222524' }, + color: { primary: '#007cba', background: '#aaa' }, } ) ); const styles = result.current.themeProviderStyles; @@ -208,51 +207,19 @@ describe( 'useThemeProviderStyles', () => { describe( 'legacy wp-admin / wp-components bridge', () => { it( 'derives the wp-admin theme color from the primary seed', () => { const { result } = renderHook( () => - useThemeProviderStyles( { color: { primary: '#1067cc' } } ) + useThemeProviderStyles( { color: { primary: '#1e90ff' } } ) ); const styles = result.current.themeProviderStyles; - expect( styles[ '--wp-admin-theme-color' ] ).toBe( '#1067cc' ); + expect( styles[ '--wp-admin-theme-color' ] ).toBe( '#1e90ff' ); expect( styles[ '--wp-admin-theme-color--rgb' ] ).toBe( - '16, 103, 204' + '30, 144, 255' ); } ); - it.each( [ - // A light seed on a light background. - { primary: '#a3b745', background: DEFAULT_SEED_COLORS.background }, - // A mid-lightness seed on a dark background. - { primary: '#916745', background: '#5b534d' }, - ] )( - 'uses the brand text color when the seed $primary lacks contrast on $background', - ( { primary, background } ) => { - const { result } = renderHook( () => - useThemeProviderStyles( { color: { primary, background } } ) - ); - const styles = result.current.themeProviderStyles as Record< - string, - string - >; - const accent = styles[ '--wp-admin-theme-color' ]; - - expect( accent ).toBe( - styles[ '--wpds-color-foreground-interactive-brand' ] - ); - for ( const surface of [ - '--wpds-color-background-surface-neutral', - '--wpds-color-background-surface-neutral-strong', - '--wpds-color-background-surface-neutral-weak', - ] ) { - expect( - getContrast( accent, styles[ surface ] ) - ).toBeGreaterThanOrEqual( 3 ); - } - } - ); - it( 'aliases the wp-components colors onto the wp-admin and semantic tokens', () => { const { result } = renderHook( () => - useThemeProviderStyles( { color: { primary: '#1067cc' } } ) + useThemeProviderStyles( { color: { primary: '#1e90ff' } } ) ); const styles = result.current.themeProviderStyles; diff --git a/packages/theme/src/use-theme-provider-styles.ts b/packages/theme/src/use-theme-provider-styles.ts index 4b427f998f8fbe..2325d6ca63a05a 100644 --- a/packages/theme/src/use-theme-provider-styles.ts +++ b/packages/theme/src/use-theme-provider-styles.ts @@ -19,11 +19,7 @@ import { type RampResult, } from './color-ramps/index.ts'; import { getColorString, getContrast } from './color-ramps/lib/color-utils.ts'; -import { - MINIMUM_NON_TEXT_CONTRAST, - MINIMUM_TEXT_CONTRAST, - NEUTRAL_CONTRAST_SURFACES, -} from './semantic-color-contrast-pairs.ts'; +import { MINIMUM_TEXT_CONTRAST } from './semantic-color-contrast-pairs.ts'; import { DEFAULT_RAMPS } from './color-ramps/lib/default-ramps.ts'; import type { ThemeProviderProps } from './types.ts'; import { @@ -180,30 +176,6 @@ function colorTokensCSS( return entries; } -/** - * Returns the color for the legacy `--wp-admin-theme-color` variable. Its - * consumers draw it as a stroke or as text on the neutral surfaces, so a seed - * with less than 3:1 contrast on any of them is swapped for the brand text - * color, which meets the text target there. - * - * @param seed The primary seed. - * @param bgRamp The background ramp. - * @param primaryRamp The primary ramp. - * @return The legacy accent color. - */ -function getLegacyAccent( - seed: string, - bgRamp: RampResult, - primaryRamp: RampResult -): string { - const fitsSurfaces = Object.values( NEUTRAL_CONTRAST_SURFACES ).every( - ( step ) => - getContrast( seed, bgRamp.ramp[ step ] ) >= - MINIMUM_NON_TEXT_CONTRAST - ); - return fitsSurfaces ? seed : primaryRamp.ramp.fgSurface3; -} - function generateStyles( { primary, colorEntries, @@ -264,11 +236,7 @@ function generateThemeProviderColors( return { styles: generateStyles( { - primary: getLegacyAccent( - seeds.primary, - bgRamp, - computedColorRamps.get( 'primary' )! - ), + primary: seeds.primary, colorEntries, } ), warnings: collectThemeProviderColorWarnings( From c289284ac6cbde9d3e278d109d64796c5d9815e8 Mon Sep 17 00:00:00 2001 From: Marco Ciampini Date: Mon, 30 Nov 2026 16:09:24 +0100 Subject: [PATCH 13/19] Admin UI: Use a lime dark enough for white text as the Ectoplasm primary Core's original `#a3b745` lime is too light for the white text that legacy consumers put on `--wp-admin-theme-color`, which takes the primary unchanged. `#697900` keeps its hue at 4.8:1 against white, and the sidebar brand fill still comes out close to the original lime. --- .../wpds-admin/css/05-scheme-tokens.css | 16 +++--- packages/admin-ui/CHANGELOG.md | 2 +- .../admin-ui/src/admin-theme-colors/index.ts | 9 ++-- packages/base-styles/CHANGELOG.md | 2 +- packages/base-styles/_mixins.scss | 2 +- .../admin-scheme-sidebar.browser.test.tsx | 49 +++++++++++++++++++ .../stories/brand-fallbacks.story.tsx | 2 +- .../src/color-ramps/stories/index.story.tsx | 2 +- .../theme/src/color-ramps/test/index.test.ts | 2 +- .../theme-example-application.story.tsx | 2 +- 10 files changed, 70 insertions(+), 18 deletions(-) diff --git a/lib/experimental/wpds-admin/css/05-scheme-tokens.css b/lib/experimental/wpds-admin/css/05-scheme-tokens.css index 09ea6beec2345c..a69187b6879757 100644 --- a/lib/experimental/wpds-admin/css/05-scheme-tokens.css +++ b/lib/experimental/wpds-admin/css/05-scheme-tokens.css @@ -125,21 +125,21 @@ body.admin-color-ectoplasm { --wpds-color-background-indicator-brand: #637300; - --wpds-color-background-interactive-brand-strong: #7f9111; - --wpds-color-background-interactive-brand-strong-active: #708200; - --wpds-color-background-interactive-brand-weak-active: #dff391; - --wpds-color-background-surface-brand: #e5f996; + --wpds-color-background-interactive-brand-strong: #697900; + --wpds-color-background-interactive-brand-strong-active: #5b6b00; + --wpds-color-background-interactive-brand-weak-active: #ddf385; + --wpds-color-background-surface-brand: #e3fa89; --wpds-color-background-thumb-brand: #637300; --wpds-color-background-thumb-brand-active: #637300; - --wpds-color-background-thumb-brand-strong: #090907; + --wpds-color-background-thumb-brand-strong: #f8fbef; --wpds-color-foreground-interactive-brand: #637300; --wpds-color-foreground-interactive-brand-active: #1b2200; - --wpds-color-foreground-interactive-brand-strong: #090907; - --wpds-color-foreground-interactive-brand-strong-active: #090907; + --wpds-color-foreground-interactive-brand-strong: #f8fbef; + --wpds-color-foreground-interactive-brand-strong-active: #f8fbef; --wpds-color-stroke-focus: #637300; --wpds-color-stroke-interactive-brand: #637300; --wpds-color-stroke-interactive-brand-active: #485500; - --wpds-color-stroke-surface-brand: #bbc98c; + --wpds-color-stroke-surface-brand: #bac985; --wpds-color-stroke-surface-brand-strong: #637300; } diff --git a/packages/admin-ui/CHANGELOG.md b/packages/admin-ui/CHANGELOG.md index ddad0b66b2c1ec..87fa88682b64d5 100644 --- a/packages/admin-ui/CHANGELOG.md +++ b/packages/admin-ui/CHANGELOG.md @@ -4,7 +4,7 @@ ### Bug Fixes -- `getAdminThemeColors`: Darken the Modern, Fresh, and Midnight backgrounds, and the Fresh and Midnight primary colors, so the brand fill keeps a white label in the sidebar. Ectoplasm returns to its original Core colors, with a dark label ([#87673](https://github.com/WordPress/gutenberg/pull/87673)). +- `getAdminThemeColors`: Darken the Modern, Fresh, and Midnight backgrounds, and the Fresh and Midnight primary colors, so the brand fill keeps a white label in the sidebar. Ectoplasm returns to Core's original purple sidebar, with a lime primary dark enough for white text ([#87673](https://github.com/WordPress/gutenberg/pull/87673)). - `getAdminThemeColors`: Adjust the Blue and Sunrise background colors so the admin sidebar matches the WordPress 7.1 Core color schemes again ([#87420](https://github.com/WordPress/gutenberg/pull/87420)). ### Internal diff --git a/packages/admin-ui/src/admin-theme-colors/index.ts b/packages/admin-ui/src/admin-theme-colors/index.ts index 9547c10929d126..7d90b7511be51e 100644 --- a/packages/admin-ui/src/admin-theme-colors/index.ts +++ b/packages/admin-ui/src/admin-theme-colors/index.ts @@ -14,8 +14,11 @@ const DEFAULT_THEME_COLORS: AdminThemeColors = { * * The Blue and Sunrise background seeds are tuned so that the sidebar color * they derive (`--wpds-color-background-surface-neutral-weak`) stays close to - * Core's `$base-color` for those schemes. The Ectoplasm seeds use Core's - * original colors, with the background tuned the same way. + * Core's `$base-color` for those schemes. Ectoplasm's background is tuned the + * same way to Core's original `#523f6d`. Its primary keeps the hue of Core's + * original `#a3b745` lime, dark enough for white text: legacy consumers put + * white text on `--wp-admin-theme-color`, which takes the primary unchanged. + * The brand fill on the sidebar still comes out close to the original lime. * * The Modern, Fresh and Midnight backgrounds are dark enough for the brand * fill to keep a white label at the required contrast, on the fill and on its @@ -28,7 +31,7 @@ export const ADMIN_THEME_COLORS = new Map< string, AdminThemeColors >( [ [ 'coffee', { primary: '#916745', background: '#5b534d' } ], [ 'ocean', { primary: '#567958', background: '#5f787f' } ], [ 'blue', { primary: '#437aa8', background: '#24567e' } ], - [ 'ectoplasm', { primary: '#a3b745', background: '#544769' } ], + [ 'ectoplasm', { primary: '#697900', background: '#544769' } ], [ 'sunrise', { primary: '#ad631e', background: '#933330' } ], [ 'light', { primary: '#007cba', background: '#eaeeed' } ], ] ); diff --git a/packages/base-styles/CHANGELOG.md b/packages/base-styles/CHANGELOG.md index 1a3dcec31dd88e..557c2a53c09ca3 100644 --- a/packages/base-styles/CHANGELOG.md +++ b/packages/base-styles/CHANGELOG.md @@ -4,7 +4,7 @@ ### Enhancements -- The `wordpress-admin-schemes` mixin and the default custom properties now use `#006daa` for Fresh, and the mixin uses `#bf332b` for Midnight, the primary colors of those schemes in `@wordpress/admin-ui` ([#87673](https://github.com/WordPress/gutenberg/pull/87673)). +- The `wordpress-admin-schemes` mixin and the default custom properties now use `#006daa` for Fresh, and the mixin uses `#bf332b` for Midnight and `#697900` for Ectoplasm, the primary colors of those schemes in `@wordpress/admin-ui` ([#87673](https://github.com/WordPress/gutenberg/pull/87673)). - The `input-control` and `editor-input-reset` mixins now use the `--wpds-typography-font-size-md` design token for their font size ([#86961](https://github.com/WordPress/gutenberg/pull/86961)). ## 15.1.0 (2026-11-18) diff --git a/packages/base-styles/_mixins.scss b/packages/base-styles/_mixins.scss index 354d60ba1fe971..efef7dc038b244 100644 --- a/packages/base-styles/_mixins.scss +++ b/packages/base-styles/_mixins.scss @@ -448,7 +448,7 @@ } body.admin-color-ectoplasm { - @include admin-scheme(#646c3e); + @include admin-scheme(#697900); } body.admin-color-midnight { diff --git a/packages/boot/src/components/root/test/admin-scheme-sidebar.browser.test.tsx b/packages/boot/src/components/root/test/admin-scheme-sidebar.browser.test.tsx index a84dd56a7e49b7..4347e86b82d3d3 100644 --- a/packages/boot/src/components/root/test/admin-scheme-sidebar.browser.test.tsx +++ b/packages/boot/src/components/root/test/admin-scheme-sidebar.browser.test.tsx @@ -11,6 +11,15 @@ function hexToChannels( hex: string ) { return [ 1, 3, 5 ].map( ( i ) => parseInt( hex.slice( i, i + 2 ), 16 ) ); } +// WCAG contrast of white text on an `rgb( r, g, b )` color. +function getWhiteContrast( rgb: number[] ) { + const [ r, g, b ] = rgb.map( ( channel ) => { + const c = channel / 255; + return c <= 0.04045 ? c / 12.92 : ( ( c + 0.055 ) / 1.055 ) ** 2.4; + } ); + return 1.05 / ( 0.2126 * r + 0.7152 * g + 0.0722 * b + 0.05 ); +} + describe( 'admin color scheme sidebar', () => { afterEach( () => { document.body.className = ''; @@ -84,4 +93,44 @@ describe( 'admin color scheme sidebar', () => { expect( onColorWarnings ).toHaveBeenCalledWith( [] ); } ); + + // Legacy consumers put white text on `--wp-admin-theme-color`, which takes + // the scheme's primary color unchanged. + it.each( [ + 'modern', + 'fresh', + 'light', + 'blue', + 'coffee', + 'ectoplasm', + 'midnight', + 'ocean', + 'sunrise', + ] )( + 'keeps white text readable on the legacy accent in the %s scheme', + async ( scheme ) => { + document.body.className = `admin-color-${ scheme }`; + + const view = await render( + +
+ accent +
+
+ ); + + const accent = getComputedStyle( + view.getByText( 'accent' ).element() + ) + .color.match( /\d+/g )! + .map( Number ) + .slice( 0, 3 ); + + expect( getWhiteContrast( accent ) ).toBeGreaterThanOrEqual( 4.5 ); + } + ); } ); diff --git a/packages/theme/src/color-ramps/stories/brand-fallbacks.story.tsx b/packages/theme/src/color-ramps/stories/brand-fallbacks.story.tsx index 049235e47e29d2..17b404e24613ef 100644 --- a/packages/theme/src/color-ramps/stories/brand-fallbacks.story.tsx +++ b/packages/theme/src/color-ramps/stories/brand-fallbacks.story.tsx @@ -56,7 +56,7 @@ const meta: Meta< typeof Verifier > = { '#007cba', // light '#437aa8', // blue '#916745', // coffee - '#646c3e', // ectoplasm + '#697900', // ectoplasm '#bf332b', // midnight '#567958', // ocean '#ad631e', // sunrise diff --git a/packages/theme/src/color-ramps/stories/index.story.tsx b/packages/theme/src/color-ramps/stories/index.story.tsx index f6e8fb65e1e85c..8f84852e45248e 100644 --- a/packages/theme/src/color-ramps/stories/index.story.tsx +++ b/packages/theme/src/color-ramps/stories/index.story.tsx @@ -243,7 +243,7 @@ const SAMPLE_COMBINATIONS = [ label: 'Ectoplasm', source: 'WordPress admin scheme', background: '#544769', - primary: '#a3b745', + primary: '#697900', }, { label: 'Ocean', diff --git a/packages/theme/src/color-ramps/test/index.test.ts b/packages/theme/src/color-ramps/test/index.test.ts index 01b92533214991..5ea327e0d8ac63 100644 --- a/packages/theme/src/color-ramps/test/index.test.ts +++ b/packages/theme/src/color-ramps/test/index.test.ts @@ -35,7 +35,7 @@ const primaryColorGroups = [ colors: [ '#437aa8', // WP Admin "blue" theme accent '#916745', // WP Admin "coffee" theme accent - '#646c3e', // WP Admin "ectoplasm" theme accent + '#646c3e', // Former WP Admin "ectoplasm" theme accent '#ad631e', // WP Admin "sunrise" theme accent ], }, diff --git a/storybook/stories/design-system/theme-example-application.story.tsx b/storybook/stories/design-system/theme-example-application.story.tsx index e4b02d76f579c7..132ab593d26e71 100644 --- a/storybook/stories/design-system/theme-example-application.story.tsx +++ b/storybook/stories/design-system/theme-example-application.story.tsx @@ -35,7 +35,7 @@ const SIDEBAR_THEME_PRESETS = [ { id: 'ectoplasm', title: 'Ectoplasm', - colors: { primary: '#a3b745', background: '#544769' }, + colors: { primary: '#697900', background: '#544769' }, }, ] as const; From 28ab7b06f11ffe1c5188c20dbbbf800d9a20a0cb Mon Sep 17 00:00:00 2001 From: Marco Ciampini Date: Mon, 30 Nov 2026 16:14:05 +0100 Subject: [PATCH 14/19] Admin UI: Test Ectoplasm's lime fill and every scheme's legacy accent --- .../test/index.jsdom.test.ts | 22 ++++- .../admin-scheme-sidebar.browser.test.tsx | 80 ++++++++----------- 2 files changed, 54 insertions(+), 48 deletions(-) diff --git a/packages/admin-ui/src/admin-theme-colors/test/index.jsdom.test.ts b/packages/admin-ui/src/admin-theme-colors/test/index.jsdom.test.ts index eba0302d5ae7c3..9922466e9db92e 100644 --- a/packages/admin-ui/src/admin-theme-colors/test/index.jsdom.test.ts +++ b/packages/admin-ui/src/admin-theme-colors/test/index.jsdom.test.ts @@ -1,5 +1,25 @@ import { describe, expect, it } from 'vitest'; -import { getAdminThemeColors } from '../index'; +import { ADMIN_THEME_COLORS, getAdminThemeColors } from '../index'; + +// WCAG contrast of white text on a `#rrggbb` color. +function getWhiteContrast( hex: string ) { + const [ r, g, b ] = [ 1, 3, 5 ].map( ( i ) => { + const c = parseInt( hex.slice( i, i + 2 ), 16 ) / 255; + return c <= 0.04045 ? c / 12.92 : ( ( c + 0.055 ) / 1.055 ) ** 2.4; + } ); + return 1.05 / ( 0.2126 * r + 0.7152 * g + 0.0722 * b + 0.05 ); +} + +// Legacy consumers put white text on `--wp-admin-theme-color`, which +// `ThemeProvider` sets to the scheme's primary color unchanged. +describe( 'ADMIN_THEME_COLORS', () => { + it.each( [ ...ADMIN_THEME_COLORS ] )( + 'keeps white text readable on the %s primary color', + ( _scheme, { primary } ) => { + expect( getWhiteContrast( primary ) ).toBeGreaterThanOrEqual( 4.5 ); + } + ); +} ); describe( 'getAdminThemeColors', () => { it( 'should return the colors for the admin theme from the body class', () => { diff --git a/packages/boot/src/components/root/test/admin-scheme-sidebar.browser.test.tsx b/packages/boot/src/components/root/test/admin-scheme-sidebar.browser.test.tsx index 4347e86b82d3d3..d9a84273b55134 100644 --- a/packages/boot/src/components/root/test/admin-scheme-sidebar.browser.test.tsx +++ b/packages/boot/src/components/root/test/admin-scheme-sidebar.browser.test.tsx @@ -11,15 +11,6 @@ function hexToChannels( hex: string ) { return [ 1, 3, 5 ].map( ( i ) => parseInt( hex.slice( i, i + 2 ), 16 ) ); } -// WCAG contrast of white text on an `rgb( r, g, b )` color. -function getWhiteContrast( rgb: number[] ) { - const [ r, g, b ] = rgb.map( ( channel ) => { - const c = channel / 255; - return c <= 0.04045 ? c / 12.92 : ( ( c + 0.055 ) / 1.055 ) ** 2.4; - } ); - return 1.05 / ( 0.2126 * r + 0.7152 * g + 0.0722 * b + 0.05 ); -} - describe( 'admin color scheme sidebar', () => { afterEach( () => { document.body.className = ''; @@ -94,43 +85,38 @@ describe( 'admin color scheme sidebar', () => { } ); - // Legacy consumers put white text on `--wp-admin-theme-color`, which takes - // the scheme's primary color unchanged. - it.each( [ - 'modern', - 'fresh', - 'light', - 'blue', - 'coffee', - 'ectoplasm', - 'midnight', - 'ocean', - 'sunrise', - ] )( - 'keeps white text readable on the legacy accent in the %s scheme', - async ( scheme ) => { - document.body.className = `admin-color-${ scheme }`; - - const view = await render( - -
- accent -
-
+ // Ectoplasm's brand fill should stay close to Core's original lime. + it( 'keeps the Ectoplasm brand fill close to Core lime with a dark label', async () => { + document.body.className = 'admin-color-ectoplasm'; + + const view = await render( + +
+ button +
+
+ ); + + const { backgroundColor, color } = getComputedStyle( + view.getByText( 'button' ).element() + ); + const fill = backgroundColor.match( /\d+/g )!.map( Number ); + const label = color.match( /\d+/g )!.map( Number ); + + hexToChannels( '#a3b745' ).forEach( ( channel, index ) => { + expect( Math.abs( channel - fill[ index ] ) ).toBeLessThanOrEqual( + 16 ); - - const accent = getComputedStyle( - view.getByText( 'accent' ).element() - ) - .color.match( /\d+/g )! - .map( Number ) - .slice( 0, 3 ); - - expect( getWhiteContrast( accent ) ).toBeGreaterThanOrEqual( 4.5 ); - } - ); + } ); + // A dark label, close to black. + label.slice( 0, 3 ).forEach( ( channel ) => { + expect( channel ).toBeLessThanOrEqual( 40 ); + } ); + } ); } ); From 07df14ca8f86ea6d381ac85c3e4d9464cb75a3f4 Mon Sep 17 00:00:00 2001 From: Marco Ciampini Date: Mon, 30 Nov 2026 16:20:01 +0100 Subject: [PATCH 15/19] Admin UI: Keep the Ectoplasm primary at least as dark as before The Global Styles shadow controls draw `--wp-admin-theme-color` as text on `#f0f0f0`, where `#697900` fell to 4.25:1 from 4.91:1. `#606e00` keeps the lime hue at 4.94:1 there and 5.63:1 with white text, and the sidebar brand fill stays close to Core's original lime. --- .../wpds-admin/css/05-scheme-tokens.css | 32 +++++++++---------- .../admin-ui/src/admin-theme-colors/index.ts | 9 +++--- .../test/index.jsdom.test.ts | 30 +++++++++++++---- packages/base-styles/CHANGELOG.md | 2 +- packages/base-styles/_mixins.scss | 2 +- .../stories/brand-fallbacks.story.tsx | 2 +- .../src/color-ramps/stories/index.story.tsx | 2 +- .../theme-example-application.story.tsx | 2 +- 8 files changed, 49 insertions(+), 32 deletions(-) diff --git a/lib/experimental/wpds-admin/css/05-scheme-tokens.css b/lib/experimental/wpds-admin/css/05-scheme-tokens.css index a69187b6879757..be07da3d287be9 100644 --- a/lib/experimental/wpds-admin/css/05-scheme-tokens.css +++ b/lib/experimental/wpds-admin/css/05-scheme-tokens.css @@ -124,23 +124,23 @@ } body.admin-color-ectoplasm { - --wpds-color-background-indicator-brand: #637300; - --wpds-color-background-interactive-brand-strong: #697900; - --wpds-color-background-interactive-brand-strong-active: #5b6b00; - --wpds-color-background-interactive-brand-weak-active: #ddf385; - --wpds-color-background-surface-brand: #e3fa89; - --wpds-color-background-thumb-brand: #637300; - --wpds-color-background-thumb-brand-active: #637300; - --wpds-color-background-thumb-brand-strong: #f8fbef; - --wpds-color-foreground-interactive-brand: #637300; + --wpds-color-background-indicator-brand: #606e00; + --wpds-color-background-interactive-brand-strong: #606e00; + --wpds-color-background-interactive-brand-strong-active: #536000; + --wpds-color-background-interactive-brand-weak-active: #def385; + --wpds-color-background-surface-brand: #e4f989; + --wpds-color-background-thumb-brand: #606e00; + --wpds-color-background-thumb-brand-active: #606e00; + --wpds-color-background-thumb-brand-strong: #eef3df; + --wpds-color-foreground-interactive-brand: #606e00; --wpds-color-foreground-interactive-brand-active: #1b2200; - --wpds-color-foreground-interactive-brand-strong: #f8fbef; - --wpds-color-foreground-interactive-brand-strong-active: #f8fbef; - --wpds-color-stroke-focus: #637300; - --wpds-color-stroke-interactive-brand: #637300; - --wpds-color-stroke-interactive-brand-active: #485500; - --wpds-color-stroke-surface-brand: #bac985; - --wpds-color-stroke-surface-brand-strong: #637300; + --wpds-color-foreground-interactive-brand-strong: #eef3df; + --wpds-color-foreground-interactive-brand-strong-active: #eef3df; + --wpds-color-stroke-focus: #606e00; + --wpds-color-stroke-interactive-brand: #606e00; + --wpds-color-stroke-interactive-brand-active: #455100; + --wpds-color-stroke-surface-brand: #b5c381; + --wpds-color-stroke-surface-brand-strong: #606e00; } body.admin-color-sunrise { diff --git a/packages/admin-ui/src/admin-theme-colors/index.ts b/packages/admin-ui/src/admin-theme-colors/index.ts index 7d90b7511be51e..7ca5691413a3b0 100644 --- a/packages/admin-ui/src/admin-theme-colors/index.ts +++ b/packages/admin-ui/src/admin-theme-colors/index.ts @@ -16,9 +16,10 @@ const DEFAULT_THEME_COLORS: AdminThemeColors = { * they derive (`--wpds-color-background-surface-neutral-weak`) stays close to * Core's `$base-color` for those schemes. Ectoplasm's background is tuned the * same way to Core's original `#523f6d`. Its primary keeps the hue of Core's - * original `#a3b745` lime, dark enough for white text: legacy consumers put - * white text on `--wp-admin-theme-color`, which takes the primary unchanged. - * The brand fill on the sidebar still comes out close to the original lime. + * original `#a3b745` lime, but is at least as dark as the previous `#646c3e`: + * legacy consumers draw `--wp-admin-theme-color`, which takes the primary + * unchanged, under white text and as text on light surfaces. The brand fill on + * the sidebar still comes out close to the original lime. * * The Modern, Fresh and Midnight backgrounds are dark enough for the brand * fill to keep a white label at the required contrast, on the fill and on its @@ -31,7 +32,7 @@ export const ADMIN_THEME_COLORS = new Map< string, AdminThemeColors >( [ [ 'coffee', { primary: '#916745', background: '#5b534d' } ], [ 'ocean', { primary: '#567958', background: '#5f787f' } ], [ 'blue', { primary: '#437aa8', background: '#24567e' } ], - [ 'ectoplasm', { primary: '#697900', background: '#544769' } ], + [ 'ectoplasm', { primary: '#606e00', background: '#544769' } ], [ 'sunrise', { primary: '#ad631e', background: '#933330' } ], [ 'light', { primary: '#007cba', background: '#eaeeed' } ], ] ); diff --git a/packages/admin-ui/src/admin-theme-colors/test/index.jsdom.test.ts b/packages/admin-ui/src/admin-theme-colors/test/index.jsdom.test.ts index 9922466e9db92e..aa5c41081ade3c 100644 --- a/packages/admin-ui/src/admin-theme-colors/test/index.jsdom.test.ts +++ b/packages/admin-ui/src/admin-theme-colors/test/index.jsdom.test.ts @@ -1,13 +1,16 @@ import { describe, expect, it } from 'vitest'; import { ADMIN_THEME_COLORS, getAdminThemeColors } from '../index'; -// WCAG contrast of white text on a `#rrggbb` color. -function getWhiteContrast( hex: string ) { - const [ r, g, b ] = [ 1, 3, 5 ].map( ( i ) => { - const c = parseInt( hex.slice( i, i + 2 ), 16 ) / 255; - return c <= 0.04045 ? c / 12.92 : ( ( c + 0.055 ) / 1.055 ) ** 2.4; +// WCAG contrast between two `#rrggbb` colors. +function getContrast( a: string, b: string ) { + const [ la, lb ] = [ a, b ].map( ( hex ) => { + const [ r, g, c ] = [ 1, 3, 5 ].map( ( i ) => { + const v = parseInt( hex.slice( i, i + 2 ), 16 ) / 255; + return v <= 0.04045 ? v / 12.92 : ( ( v + 0.055 ) / 1.055 ) ** 2.4; + } ); + return 0.2126 * r + 0.7152 * g + 0.0722 * c; } ); - return 1.05 / ( 0.2126 * r + 0.7152 * g + 0.0722 * b + 0.05 ); + return ( Math.max( la, lb ) + 0.05 ) / ( Math.min( la, lb ) + 0.05 ); } // Legacy consumers put white text on `--wp-admin-theme-color`, which @@ -16,9 +19,22 @@ describe( 'ADMIN_THEME_COLORS', () => { it.each( [ ...ADMIN_THEME_COLORS ] )( 'keeps white text readable on the %s primary color', ( _scheme, { primary } ) => { - expect( getWhiteContrast( primary ) ).toBeGreaterThanOrEqual( 4.5 ); + expect( getContrast( primary, '#ffffff' ) ).toBeGreaterThanOrEqual( + 4.5 + ); } ); + + // The Global Styles shadow controls draw it as text on `#f0f0f0`. The + // Ectoplasm primary should not read worse there than the former `#646c3e`. + it( 'keeps the Ectoplasm primary readable as text on the panel background', () => { + expect( + getContrast( + ADMIN_THEME_COLORS.get( 'ectoplasm' )!.primary, + '#f0f0f0' + ) + ).toBeGreaterThanOrEqual( getContrast( '#646c3e', '#f0f0f0' ) ); + } ); } ); describe( 'getAdminThemeColors', () => { diff --git a/packages/base-styles/CHANGELOG.md b/packages/base-styles/CHANGELOG.md index 557c2a53c09ca3..667564f37729dc 100644 --- a/packages/base-styles/CHANGELOG.md +++ b/packages/base-styles/CHANGELOG.md @@ -4,7 +4,7 @@ ### Enhancements -- The `wordpress-admin-schemes` mixin and the default custom properties now use `#006daa` for Fresh, and the mixin uses `#bf332b` for Midnight and `#697900` for Ectoplasm, the primary colors of those schemes in `@wordpress/admin-ui` ([#87673](https://github.com/WordPress/gutenberg/pull/87673)). +- The `wordpress-admin-schemes` mixin and the default custom properties now use `#006daa` for Fresh, and the mixin uses `#bf332b` for Midnight and `#606e00` for Ectoplasm, the primary colors of those schemes in `@wordpress/admin-ui` ([#87673](https://github.com/WordPress/gutenberg/pull/87673)). - The `input-control` and `editor-input-reset` mixins now use the `--wpds-typography-font-size-md` design token for their font size ([#86961](https://github.com/WordPress/gutenberg/pull/86961)). ## 15.1.0 (2026-11-18) diff --git a/packages/base-styles/_mixins.scss b/packages/base-styles/_mixins.scss index efef7dc038b244..3983e0533f5018 100644 --- a/packages/base-styles/_mixins.scss +++ b/packages/base-styles/_mixins.scss @@ -448,7 +448,7 @@ } body.admin-color-ectoplasm { - @include admin-scheme(#697900); + @include admin-scheme(#606e00); } body.admin-color-midnight { diff --git a/packages/theme/src/color-ramps/stories/brand-fallbacks.story.tsx b/packages/theme/src/color-ramps/stories/brand-fallbacks.story.tsx index 17b404e24613ef..52a2e8ac4cf3b6 100644 --- a/packages/theme/src/color-ramps/stories/brand-fallbacks.story.tsx +++ b/packages/theme/src/color-ramps/stories/brand-fallbacks.story.tsx @@ -56,7 +56,7 @@ const meta: Meta< typeof Verifier > = { '#007cba', // light '#437aa8', // blue '#916745', // coffee - '#697900', // ectoplasm + '#606e00', // ectoplasm '#bf332b', // midnight '#567958', // ocean '#ad631e', // sunrise diff --git a/packages/theme/src/color-ramps/stories/index.story.tsx b/packages/theme/src/color-ramps/stories/index.story.tsx index 8f84852e45248e..c2d1b37aa43c23 100644 --- a/packages/theme/src/color-ramps/stories/index.story.tsx +++ b/packages/theme/src/color-ramps/stories/index.story.tsx @@ -243,7 +243,7 @@ const SAMPLE_COMBINATIONS = [ label: 'Ectoplasm', source: 'WordPress admin scheme', background: '#544769', - primary: '#697900', + primary: '#606e00', }, { label: 'Ocean', diff --git a/storybook/stories/design-system/theme-example-application.story.tsx b/storybook/stories/design-system/theme-example-application.story.tsx index 132ab593d26e71..84fd372990ba4d 100644 --- a/storybook/stories/design-system/theme-example-application.story.tsx +++ b/storybook/stories/design-system/theme-example-application.story.tsx @@ -35,7 +35,7 @@ const SIDEBAR_THEME_PRESETS = [ { id: 'ectoplasm', title: 'Ectoplasm', - colors: { primary: '#697900', background: '#544769' }, + colors: { primary: '#606e00', background: '#544769' }, }, ] as const; From 90886ad72157e40a032fa4417a8772a8457b6c2c Mon Sep 17 00:00:00 2001 From: Marco Ciampini Date: Mon, 30 Nov 2026 16:31:12 +0100 Subject: [PATCH 16/19] E2E Tests: Compare the drop indicator with the scheme's accent color --- .../editor/various/draggable-blocks.spec.js | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/test/e2e/specs/editor/various/draggable-blocks.spec.js b/test/e2e/specs/editor/various/draggable-blocks.spec.js index 267b326bbc505e..bf087182a5fab9 100644 --- a/test/e2e/specs/editor/various/draggable-blocks.spec.js +++ b/test/e2e/specs/editor/various/draggable-blocks.spec.js @@ -380,6 +380,18 @@ test.describe( 'Draggable block', () => { const testImageName = '10x10_e2e_test_image_z9T8jK.png'; const testImagePath = `./assets/${ testImageName }`; + // The drop indicator uses the admin color scheme's accent color. + const getThemeColor = ( locator ) => + locator.evaluate( ( element ) => { + const probe = element.ownerDocument.createElement( 'div' ); + probe.style.backgroundColor = 'var(--wp-admin-theme-color)'; + element.parentElement.append( probe ); + const { backgroundColor } = + element.ownerDocument.defaultView.getComputedStyle( probe ); + probe.remove(); + return backgroundColor; + } ); + { const { dragOver, drop } = await pageUtils.dragFiles( testImagePath ); @@ -391,16 +403,16 @@ test.describe( 'Draggable block', () => { name: 'Add block', } ); + const accent = await getThemeColor( rowAppender ); + expect( accent ).not.toBe( 'rgba(0, 0, 0, 0)' ); + await dragOver( rowAppender ); // Expect to show the drop indicator blue background. // This is technically an implementation detail but easier to test in this case. await expect( rowAppender, 'Dragging over the button block appender should show the blue background' - ).toHaveCSS( - 'background-color', - /rgb\(0, 124, 186\)|rgb\(56, 88, 233\)/ - ); + ).toHaveCSS( 'background-color', accent ); const { width: rowWidth } = await rowBlock.boundingBox(); await dragOver( rowBlock, { position: { x: rowWidth - 10 } } ); @@ -409,10 +421,7 @@ test.describe( 'Draggable block', () => { await expect( rowAppender, 'Dragging over the empty group block but outside the appender should still show the blue background' - ).toHaveCSS( - 'background-color', - /rgb\(0, 124, 186\)|rgb\(56, 88, 233\)/ - ); + ).toHaveCSS( 'background-color', accent ); await drop(); await expect( rowAppender ).toBeHidden(); @@ -438,12 +447,15 @@ test.describe( 'Draggable block', () => { includeHidden: true, } ); + const accent = await getThemeColor( columnAppender ); + expect( accent ).not.toBe( 'rgba(0, 0, 0, 0)' ); + await dragOver( columnAppender ); // Expect to show the drop indicator blue background. // This is technically an implementation detail but easier to test in this case. await expect( columnAppender ).toHaveCSS( 'background-color', - /rgb\(0, 124, 186\)|rgb\(56, 88, 233\)/ + accent ); await drop(); From 4e9fff8687b6b09ba557ba6eedcccf62825e2b8d Mon Sep 17 00:00:00 2001 From: Marco Ciampini Date: Mon, 30 Nov 2026 16:31:19 +0100 Subject: [PATCH 17/19] Boot: Require the exact Core sidebar color for Ectoplasm --- .../test/admin-scheme-sidebar.browser.test.tsx | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/packages/boot/src/components/root/test/admin-scheme-sidebar.browser.test.tsx b/packages/boot/src/components/root/test/admin-scheme-sidebar.browser.test.tsx index d9a84273b55134..ddf84778cacac6 100644 --- a/packages/boot/src/components/root/test/admin-scheme-sidebar.browser.test.tsx +++ b/packages/boot/src/components/root/test/admin-scheme-sidebar.browser.test.tsx @@ -4,9 +4,6 @@ import { getAdminThemeColors } from '@wordpress/admin-ui'; import { ThemeProvider } from '@wordpress/theme'; import styles from '../style.module.scss'; -// Largest difference allowed in each sRGB channel, out of 255. -const TOLERANCE = 4; - function hexToChannels( hex: string ) { return [ 1, 3, 5 ].map( ( i ) => parseInt( hex.slice( i, i + 2 ), 16 ) ); } @@ -17,14 +14,15 @@ describe( 'admin color scheme sidebar', () => { } ); // The sidebar should stay close to the `$base-color` of the Core scheme in - // WordPress 7.1 and later. Ectoplasm follows its original Core colors. + // WordPress 7.1 and later. Ectoplasm matches its original Core color. + // `tolerance` is the largest difference allowed in each sRGB channel. it.each( [ - { scheme: 'blue', core: '#245278' }, - { scheme: 'sunrise', core: '#8a312d' }, - { scheme: 'ectoplasm', core: '#523f6d' }, + { scheme: 'blue', core: '#245278', tolerance: 4 }, + { scheme: 'sunrise', core: '#8a312d', tolerance: 4 }, + { scheme: 'ectoplasm', core: '#523f6d', tolerance: 0 }, ] )( 'matches the Core sidebar color in the $scheme scheme', - async ( { scheme, core } ) => { + async ( { scheme, core, tolerance } ) => { document.body.className = `admin-color-${ scheme }`; const view = await render( @@ -44,7 +42,7 @@ describe( 'admin color scheme sidebar', () => { hexToChannels( core ).forEach( ( channel, index ) => { expect( Math.abs( channel - actual[ index ] ) - ).toBeLessThanOrEqual( TOLERANCE ); + ).toBeLessThanOrEqual( tolerance ); } ); } ); From 37fdc5a5d7218e946c73ceb7f4348065fa71047c Mon Sep 17 00:00:00 2001 From: Marco Ciampini Date: Mon, 30 Nov 2026 16:38:51 +0100 Subject: [PATCH 18/19] Admin UI: Test every scheme's primary against its WordPress 7.1 value --- .../test/index.jsdom.test.ts | 36 +++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/packages/admin-ui/src/admin-theme-colors/test/index.jsdom.test.ts b/packages/admin-ui/src/admin-theme-colors/test/index.jsdom.test.ts index aa5c41081ade3c..2d5b164bb17a29 100644 --- a/packages/admin-ui/src/admin-theme-colors/test/index.jsdom.test.ts +++ b/packages/admin-ui/src/admin-theme-colors/test/index.jsdom.test.ts @@ -25,16 +25,32 @@ describe( 'ADMIN_THEME_COLORS', () => { } ); - // The Global Styles shadow controls draw it as text on `#f0f0f0`. The - // Ectoplasm primary should not read worse there than the former `#646c3e`. - it( 'keeps the Ectoplasm primary readable as text on the panel background', () => { - expect( - getContrast( - ADMIN_THEME_COLORS.get( 'ectoplasm' )!.primary, - '#f0f0f0' - ) - ).toBeGreaterThanOrEqual( getContrast( '#646c3e', '#f0f0f0' ) ); - } ); + // Legacy consumers also draw it as text on light surfaces, such as the + // Global Styles shadow controls on `#f0f0f0`. No primary should read worse + // there than its WordPress 7.1 value. + const WORDPRESS_7_1_PRIMARIES: Record< string, string > = { + modern: '#3858e9', + fresh: '#007cba', + midnight: '#cf4339', + coffee: '#916745', + ocean: '#567958', + blue: '#437aa8', + ectoplasm: '#646c3e', + sunrise: '#ad631e', + light: '#007cba', + }; + + it.each( [ ...ADMIN_THEME_COLORS ] )( + 'keeps the %s primary color readable as text on light surfaces', + ( scheme, { primary } ) => { + const former = WORDPRESS_7_1_PRIMARIES[ scheme ]; + + expect( former ).toBeDefined(); + expect( getContrast( primary, '#f0f0f0' ) ).toBeGreaterThanOrEqual( + getContrast( former, '#f0f0f0' ) + ); + } + ); } ); describe( 'getAdminThemeColors', () => { From 9c3eb9671bc0aea3317738b8c0a6fcd331a0ce00 Mon Sep 17 00:00:00 2001 From: Marco Ciampini Date: Mon, 30 Nov 2026 16:43:43 +0100 Subject: [PATCH 19/19] Admin UI: Fail the baseline test when a bundled scheme goes missing --- .../src/admin-theme-colors/test/index.jsdom.test.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/admin-ui/src/admin-theme-colors/test/index.jsdom.test.ts b/packages/admin-ui/src/admin-theme-colors/test/index.jsdom.test.ts index 2d5b164bb17a29..3872329ff021ed 100644 --- a/packages/admin-ui/src/admin-theme-colors/test/index.jsdom.test.ts +++ b/packages/admin-ui/src/admin-theme-colors/test/index.jsdom.test.ts @@ -40,13 +40,13 @@ describe( 'ADMIN_THEME_COLORS', () => { light: '#007cba', }; - it.each( [ ...ADMIN_THEME_COLORS ] )( + it.each( Object.entries( WORDPRESS_7_1_PRIMARIES ) )( 'keeps the %s primary color readable as text on light surfaces', - ( scheme, { primary } ) => { - const former = WORDPRESS_7_1_PRIMARIES[ scheme ]; + ( scheme, former ) => { + const primary = ADMIN_THEME_COLORS.get( scheme )?.primary; - expect( former ).toBeDefined(); - expect( getContrast( primary, '#f0f0f0' ) ).toBeGreaterThanOrEqual( + expect( primary ).toBeDefined(); + expect( getContrast( primary!, '#f0f0f0' ) ).toBeGreaterThanOrEqual( getContrast( former, '#f0f0f0' ) ); }