diff --git a/lib/experimental/wpds-admin/css/05-scheme-tokens.css b/lib/experimental/wpds-admin/css/05-scheme-tokens.css index a28325d4f362d3..be07da3d287be9 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: #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: #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 { @@ -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..87fa88682b64d5 100644 --- a/packages/admin-ui/CHANGELOG.md +++ b/packages/admin-ui/CHANGELOG.md @@ -4,6 +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 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 c555fddf9d4bb1..7ca5691413a3b0 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,25 @@ 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. Ectoplasm's background is tuned the + * same way to Core's original `#523f6d`. Its primary keeps the hue of Core's + * 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 + * 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: '#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 6b7f032ac60ef4..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 @@ -1,5 +1,57 @@ import { describe, expect, it } from 'vitest'; -import { getAdminThemeColors } from '../index'; +import { ADMIN_THEME_COLORS, getAdminThemeColors } from '../index'; + +// 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 ( Math.max( la, lb ) + 0.05 ) / ( Math.min( la, lb ) + 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( getContrast( primary, '#ffffff' ) ).toBeGreaterThanOrEqual( + 4.5 + ); + } + ); + + // 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( Object.entries( WORDPRESS_7_1_PRIMARIES ) )( + 'keeps the %s primary color readable as text on light surfaces', + ( scheme, former ) => { + const primary = ADMIN_THEME_COLORS.get( scheme )?.primary; + + expect( primary ).toBeDefined(); + expect( getContrast( primary!, '#f0f0f0' ) ).toBeGreaterThanOrEqual( + getContrast( former, '#f0f0f0' ) + ); + } + ); +} ); describe( 'getAdminThemeColors', () => { it( 'should return the colors for the admin theme from the body class', () => { @@ -16,7 +68,7 @@ describe( 'getAdminThemeColors', () => { expect( getAdminThemeColors() ).toEqual( { primary: '#3858e9', - background: '#222524', + background: '#121514', } ); } ); @@ -25,7 +77,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..667564f37729dc 100644 --- a/packages/base-styles/CHANGELOG.md +++ b/packages/base-styles/CHANGELOG.md @@ -4,6 +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 `#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/_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); } diff --git a/packages/base-styles/_mixins.scss b/packages/base-styles/_mixins.scss index 4876c5d0199073..3983e0533f5018 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 { @@ -448,11 +448,11 @@ } body.admin-color-ectoplasm { - @include admin-scheme(#646c3e); + @include admin-scheme(#606e00); } 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..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 @@ -1,12 +1,9 @@ -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'; 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,13 +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. + // 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: '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( @@ -43,8 +42,79 @@ describe( 'admin color scheme sidebar', () => { hexToChannels( core ).forEach( ( channel, index ) => { expect( Math.abs( channel - actual[ index ] ) - ).toBeLessThanOrEqual( TOLERANCE ); + ).toBeLessThanOrEqual( tolerance ); + } ); + } + ); + + 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 onColorWarnings = vi.fn(); + + 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 ); } ); + // The label meets its contrast targets on the fill and its active state. + expect( onColorWarnings ).toHaveBeenCalledWith( [] ); } ); + + // 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 + ); + } ); + // A dark label, close to black. + label.slice( 0, 3 ).forEach( ( channel ) => { + expect( channel ).toBeLessThanOrEqual( 40 ); + } ); + } ); } ); 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..52a2e8ac4cf3b6 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 + '#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 568ec6b6b08eef..c2d1b37aa43c23 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: '#544769', + primary: '#606e00', }, { 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/packages/theme/src/color-ramps/test/index.test.ts b/packages/theme/src/color-ramps/test/index.test.ts index 907ffb5298e46a..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 ], }, @@ -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. diff --git a/storybook/stories/design-system/theme-example-application.story.tsx b/storybook/stories/design-system/theme-example-application.story.tsx index 19bb66fc16f7fd..84fd372990ba4d 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: '#606e00', background: '#544769' }, }, ] as const; 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();