Make WordPress Core

Opened 4 hours ago

Last modified 2 hours ago

#65382 new enhancement

Admin color schemes: improve contrast to make sidebar compatible with Gutenberg editor chrome

Reported by: fushar's profile fushar Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Administration Keywords: has-patch
Focuses: ui, accessibility, css Cc:

Description

We want the block editor and Site Editor to follow the user's admin color scheme (see https://github.com/WordPress/gutenberg/pull/78397). With that, the editor chrome will use the color scheme, instead of being always black. However, as also discussed in the linked PR, this has a few problems with the current color schemes:

  1. The editor chrome's background color is generated from a seed, through the WPDS ramp algorithm buildBgRamp()(https://github.com/WordPress/gutenberg/blob/35487a041c6569399988a96d5956b92cd3da0a71/packages/theme/src/color-ramps/index.ts#L18). This function emits surface colors within a specific luminance bands, and cannot reproduce arbitrary colors. Most of the current scheme sidebars are outside the bands, so the editor chrome will NEVER match them regardless of the seed.
  2. The primary button may appear in the editor chrome, e.g. as Review X changes... button. So, the background color should be distinct enough from the sidebar. Currently several schemes have similar colors (e.g. the purple Ectoplasm).

Proposed change

Update the admin color schemes so that they:

  • Use sidebar colors that the editor's ramp can reproduce, so the editor chrome can match the wp-admin sidebar
  • Use primary button colors that are distinct from the sidebar colors.
  • While doing that, improve the contrast for better legibility.

Change History (3)

This ticket was mentioned in PR #12026 on WordPress/wordpress-develop by @fushar.


4 hours ago
#1

  • Keywords has-patch added

Trac ticket: https://core.trac.wordpress.org/ticket/65382

## Summary

The block editor and Site Editor are moving toward applying the user's admin color scheme (see https://github.com/WordPress/gutenberg/pull/78397). With that, the editor chrome will use the color scheme, instead of being always black. However, as also discussed in the linked PR, this has a few problems with the current color schemes:

  1. The editor chrome's background color is generated from a seed, through the WPDS ramp algorithm (buildBgRamp()). This function emits surface colors within a specific luminance bands, and cannot reproduce arbitrary colors. Most of the current scheme sidebars are outside the bands, so the editor chrome will NEVER match them regardless of the seed.
  2. The primary button may appear in the editor chrome, e.g. as Review X changes... button. So, the background color should be distinct enough from the sidebar. Currently several schemes have similar colors (e.g. the purple Ectoplasm).

This PR updates the core admin color schemes to satisfy both, while maintaining each scheme's characteristics.

Several notes:

  • With this PR I also try to reduce the number of distinct colors in each scheme. Except for the Light scheme, the primary button's background color is made equal to the currently selected sidebar menu's background color. This simplifies the color schemes.
  • I believe some color schemes currently being low-contrast is expected. However, the buildBgRamp() function CANNOT produce low-contrast colors. So, for each such schemes (like Coffee, Ocean) I tried to produce the color with the lowest contrast possible while still being similar to the original color.
  • This PR: https://github.com/WordPress/gutenberg/pull/23048 changed the primary button color to be the sidebar color, for several schemes (such as Ectoplasm). This PR reverts that behavior due to the reason mentioned before.

[!WARNING]
The linked Gutenberg PR must also be backported, because the primary colors are also being updated in base-styles.

### Sidebar contrast (white/black text vs sidebar background)

And whether they pass WCAG 2.x AA (it requires > 4.5:1 for normal text)

Scheme Before After
Modern 16.67 ✅ *unchanged*
Fresh 15.89 ✅ *unchanged*
Light 10.03 ✅ 10.03 ✅
Blue 2.58 ❌ 8.23 ✅
Coffee 7.68 ✅ 8.19 ✅
Ectoplasm 9.17 ✅ 10.67 ✅
Midnight 11.33 ✅ 11.26 ✅
Ocean 3.48 ❌ 8.21 ✅
Sunrise 4.48 ❌ 8.21 ✅

### Primary button contrast (white text vs button background)

Note that except for Light scheme, this primary button background color is now equal to that of the currently selected menu item.

Scheme Before After
Modern 5.61 ✅ *unchanged*
Fresh 5.17 ✅ *unchanged*
Light 4.15 ❌ 4.57 ✅
Blue 6.63 ✅ 4.58 ✅
Coffee 10.2 ✅ 4.96 ✅
Ectoplasm 9.17 ✅ 5.59 ✅
Midnight 3.93 ❌ 4.65 ✅
Ocean 4.44 ❌ 4.92 ✅
Sunrise 2.86 ❌ 4.58 ✅

### Screenshots

Before After
Blue<br>https://github.com/user-attachments/assets/fbf99386-0584-4228-8b86-88b811ea96bd Blue<br>https://github.com/user-attachments/assets/a5b2777d-8f7b-4a71-9506-8bb923424cc5
Coffee<br>https://github.com/user-attachments/assets/7f8aa683-644c-43f2-976a-a4d446d9091b Coffee<br>https://github.com/user-attachments/assets/847e04bc-5b06-4eb2-85c3-97278f4c7c8e
Ectoplasm<br>https://github.com/user-attachments/assets/a92ce2a2-f25c-48bf-b844-4ac45a1285ec Ectoplasm<br>https://github.com/user-attachments/assets/488b6d3c-e87e-4166-a36b-cfa8d0ff8738
Light<br>https://github.com/user-attachments/assets/c52f744e-bc41-4f7b-912e-2abe3303b41d Light<br>https://github.com/user-attachments/assets/77746ac4-6e26-4435-b6e0-1bef2a916c7c
Midnight<br>https://github.com/user-attachments/assets/159ecebd-666f-4ca7-befe-732f42b92ddf Midnight<br>https://github.com/user-attachments/assets/4410d0ef-c264-48d5-91fc-5272d058b5fe
Ocean<br>https://github.com/user-attachments/assets/cdc3a3d2-7617-4fbb-8bf0-676c64244dcc Ocean<br>https://github.com/user-attachments/assets/70baa458-587b-4b03-97ed-7c4a0077d26d
Sunrise<br>https://github.com/user-attachments/assets/84ab785a-44af-4765-bd8d-a110abfa33e0 Sunrise<br>https://github.com/user-attachments/assets/41571b45-f20d-40b3-a33a-16643bcbc7d9

## Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Opus 4.7-4.8
Used for: iterating the color gradients

@simison commented on PR #12026:


3 hours ago
#2

I didn't test yet but adding a note to test non-site-editor pages built with WP Build; Fonts, Connectors, etc.
Similarly also plugins building pages with WP Build; a good check would be core AI plugin's settings page.

@fushar commented on PR #12026:


2 hours ago
#3

I didn't test yet but adding a note to test non-site-editor pages built with WP Build

Yep, this is addressed in the Gutenberg PR https://github.com/WordPress/gutenberg/pull/78397. Together with that PR, this PR even fixes an existing bug with "disconnected" black chrome surrounding such pages. Copying here for easy reference:

Appearance -> Fonts

(see the gutter/border at bottom-left)

BeforeAfter
https://github.com/user-attachments/assets/3e182a20-3263-4492-a8bf-3096f77b9ca5https://github.com/user-attachments/assets/bb2f7eff-ec53-4279-8615-6b24a391bd9c
Note: See TracTickets for help on using tickets.