Skip to content

Site Editor: Apply the user's admin color scheme#78397

Merged
fushar merged 31 commits into
trunkfrom
admin-bar-in-editor-color-4
Jun 8, 2026
Merged

Site Editor: Apply the user's admin color scheme#78397
fushar merged 31 commits into
trunkfrom
admin-bar-in-editor-color-4

Conversation

@fushar

@fushar fushar commented May 18, 2026

Copy link
Copy Markdown
Contributor

What?

Makes the Site Editor's sidebar and page shell (chrome) to follow the user's WordPress admin color scheme instead of always rendering a fixed dark barkground.

Why?

This is a continuation of #78331, as per the suggestion I made the changes directly via WPDS tokens + ThemeProvider rather than overriding in the experiment SCSS file.

How?

Firstly the editor chrome color is produced by the WPDS ramp algorithm, which only emits colors in specific luminance bands and cannot produce arbitrary colors. So, I had to come up with new a color set for the existing schemes, and updated Core's to match them: https://core.trac.wordpress.org/changeset/62454.

Then, we extract getAdminThemeColors from @wordpress/boot to@wordpress/admin-ui, so both the Site Editor (@wordpress/edit-site) and boot can share one implementation. It now also includes the bg color in addition to primary. Previously, boot hardcoded the sidebar background to #1d2327; it's now based on the admin color scheme. @wordpress/edit-site now passes theme colors to ThemeProvider. Finally, we convert the hardcoded colors in edit-site's component SCSS files to the correct WPDS tokens semantically.

There's also a bit complication. Sidebar area should be rendered with themed background color, while content area should be rendered with white (#fff) background. On desktop, this is not a problem because we define sidebar, content, and preview areas, so we can wrap each of them with the correct background color via <ThemeProvider>. However, for mobile viewport, we only define mobile area. So, we split it into two: mobileSidebar and mobileContent, mirroring existing areas. On canvas=edit on mobile, we render preview, matching desktop.

Limitations

Site Editor v2 (/wp-admin/admin.php?page=site-editor-v2) is EXCLUDED for now. The page does not add the color scheme to the <body>'s class. I'm not sure if that's intended? It does work correctly on other boot pages like Appearance -> Fonts.

Testing Instructions

Test the Site Editor (v1) with various admin color schemes (set via Users -> Profile). Also test on various screen widths to test mobile behavior.

Test also boot pages such as Appearance -> Fonts.

Screenshots

Appearance -> Fonts

(Check the right and bottom sides; they now follow the background color instead of black.)

Before After
image image

Site Editor

BEFORE (on Modern)

site-editor-modern-before
Modern

site-editor-modern
Fresh (Default)

site-editor-fresh
Blue

site-editor-blue
Coffee

site-editor-coffee
Ectoplasm

site-editor-ectoplasm
Light

site-editor-light
Midnight

site-editor-midnight
Ocean

site-editor-ocean
Sunrise

site-editor-sunrise

Use of AI Tools

I used Claude Code with Opus 4.7 to help replace the hardcoded colors with appropriate WPDS token variables.

cc: @lucasmendes-design

@github-actions github-actions Bot added [Package] Edit Site /packages/edit-site [Package] Theme /packages/theme labels May 18, 2026
@fushar fushar force-pushed the admin-bar-in-editor-color-4 branch from 0fc11f7 to 231eebb Compare May 18, 2026 13:42
@github-actions

github-actions Bot commented May 18, 2026

Copy link
Copy Markdown

Size Change: +1.18 kB (+0.01%)

Total Size: 8.44 MB

📦 View Changed
Filename Size Change
build/modules/boot/index.min.js 52.6 kB +81 B (+0.15%)
build/scripts/edit-site/index.min.js 296 kB +114 B (+0.04%)
build/styles/base-styles/admin-schemes-rtl.css 1.69 kB -26 B (-1.52%)
build/styles/base-styles/admin-schemes-rtl.min.css 750 B -25 B (-3.23%)
build/styles/base-styles/admin-schemes.css 1.69 kB -26 B (-1.52%)
build/styles/base-styles/admin-schemes.min.css 750 B -25 B (-3.23%)
build/styles/edit-site/experimental-admin-bar-in-editor-rtl.css 521 B +19 B (+3.78%)
build/styles/edit-site/experimental-admin-bar-in-editor-rtl.min.css 491 B +14 B (+2.94%)
build/styles/edit-site/experimental-admin-bar-in-editor.css 521 B +19 B (+3.78%)
build/styles/edit-site/experimental-admin-bar-in-editor.min.css 491 B +14 B (+2.94%)
build/styles/edit-site/style-rtl.css 22.1 kB +257 B (+1.18%)
build/styles/edit-site/style-rtl.min.css 18.2 kB +253 B (+1.41%)
build/styles/edit-site/style.css 22.1 kB +259 B (+1.19%)
build/styles/edit-site/style.min.css 18.2 kB +254 B (+1.42%)

compressed-size-action

@github-actions

github-actions Bot commented May 18, 2026

Copy link
Copy Markdown

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

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

@fushar fushar requested a review from tyxla May 18, 2026 14:16
@fushar fushar requested review from aduth and youknowriad May 18, 2026 14:16
@fushar fushar requested review from jameskoster and jasmussen May 18, 2026 14:16
@fushar fushar marked this pull request as ready for review May 18, 2026 14:17
@fushar fushar requested a review from a team as a code owner May 18, 2026 14:17
@github-actions

github-actions Bot commented May 18, 2026

Copy link
Copy Markdown

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

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @lucasmendes-design.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

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

Unlinked contributors: lucasmendes-design.

Co-authored-by: fushar <fushar@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: jameskoster <jameskoster@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: aduth <aduth@git.wordpress.org>
Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>

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

@fushar fushar requested a review from t-hamano May 18, 2026 14:19
@fushar fushar added [Type] Feature New feature to highlight in changelogs. [Type] Enhancement A suggestion for improvement. and removed [Type] Feature New feature to highlight in changelogs. labels May 18, 2026
Comment thread packages/admin-ui/src/admin-theme-colors/index.ts
@github-actions github-actions Bot removed the [Package] Theme /packages/theme label May 18, 2026
@fushar fushar force-pushed the admin-bar-in-editor-color-4 branch 4 times, most recently from ccce419 to f733f13 Compare May 18, 2026 15:34
Comment thread packages/edit-site/src/components/layout/style.scss Outdated
Comment thread packages/edit-site/src/components/sidebar-button/style.scss
Comment thread packages/edit-site/src/components/sidebar-navigation-screen/style.scss Outdated
Comment thread packages/edit-site/src/components/sidebar-navigation-screen/style.scss Outdated
Comment thread packages/edit-site/src/components/site-hub/style.scss Outdated
Comment thread packages/edit-site/src/components/site-hub/style.scss Outdated
@ciampo

ciampo commented May 18, 2026

Copy link
Copy Markdown
Contributor

Was also about to share similar feedback to @jameskoster re. using the correct tokens. The tokens.md document should include some guidance on what scope each token has. You can also take inspiration from comopnents in the @wordpress/ui package

Comment thread packages/admin-ui/src/user-theme-provider/index.tsx Outdated
Comment thread packages/admin-ui/src/admin-theme-colors/index.ts Outdated
@fushar fushar force-pushed the admin-bar-in-editor-color-4 branch from 9c6817c to 32d2f18 Compare May 19, 2026 04:32
@t-hamano t-hamano linked an issue Jun 4, 2026 that may be closed by this pull request
@fushar

fushar commented Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

All right, I've tested this PR hundreds of times :) I think this is good. Here's a series of screenshots from desktop and mobile resolutions to showcase the changes (and to make sure the mobile refactor still works):

Desktop

Design to Styles, unsaved Styles
Navigation (editing) Patterns (category)

Mobile

Home
Home
Styles
Styles
Navigation
Navigation
Navigation (editing)
Navigation (editing)
Identity
Identity
Pages
Pages
Page (editor)
Page (editor)
Templates
Templates
Patterns (nav)
Patterns (nav)
Patterns (category)
Patterns (category)

@t-hamano

t-hamano commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Thanks for working on this. I believe this PR will ultimately close #53430. I may not fully understand this PR, but one concern I have is backward compatibility.

This PR works well with the latest WordPress trunk, meaning the core version including changeset 62454. However, the Gutenberg plugin also supports older WP versions. Therefore, if I test this PR with WordPress 6.9 or 7.0, I see a difference in background color on boot-based pages.

background

To resolve this, we could implement changes similar to changeset 62454 in Gutenberg, but this would likely require extensive modifications. As an alternative approach, if the WordPress version is 7.0 or lower, we might consider reverting only the background color of the boot page to its previous setting.

For example, somthing like this:

Details
diff --git a/lib/compat/wordpress-7.1/admin-color-schemes.php b/lib/compat/wordpress-7.1/admin-color-schemes.php
new file mode 100644
index 00000000000..0296d20b6e7
--- /dev/null
+++ b/lib/compat/wordpress-7.1/admin-color-schemes.php
@@ -0,0 +1,31 @@
+<?php
+/**
+ * WordPress 7.1 compatibility functions for the Gutenberg
+ * editor plugin changes related to admin color schemes.
+ *
+ * @package gutenberg
+ */
+
+/**
+ * Prints a background fallback for the boot-based admin screens.
+ *
+ * The admin on WordPress < 7.1 still uses the legacy color schemes, which no
+ * longer match the boot pages' updated background colors. Apply the legacy
+ * colors to the boot pages' background only so the two stay consistent.
+ */
+function gutenberg_print_legacy_admin_colors_styles() {
+	if ( version_compare( get_bloginfo( 'version' ), '7.1.0', '>=' ) ) {
+		return;
+	}
+	?>
+	<style id="gutenberg-legacy-admin-colors">
+		.admin-color-blue .boot-layout { background: #52accc; }
+		.admin-color-coffee .boot-layout { background: #59524c; }
+		.admin-color-midnight .boot-layout { background: #363b3f; }
+		.admin-color-ectoplasm .boot-layout { background: #523f6d; }
+		.admin-color-ocean .boot-layout { background: #738e96; }
+		.admin-color-sunrise .boot-layout { background: #cf4944; }
+	</style>
+	<?php
+}
+add_action( 'admin_print_styles', 'gutenberg_print_legacy_admin_colors_styles' );
diff --git a/lib/load.php b/lib/load.php
index 2173e9e35c8..26e010d4deb 100644
--- a/lib/load.php
+++ b/lib/load.php
@@ -130,6 +130,7 @@ if ( class_exists( '\WordPress\AiClient\AiClient' ) ) {
 
 // WordPress 7.1 compat.
 require __DIR__ . '/compat/wordpress-7.1/classic-block.php';
+require __DIR__ . '/compat/wordpress-7.1/admin-color-schemes.php';
 
 // Experimental features.
 require __DIR__ . '/experimental/admin-bar-in-editor/load.php';

@fushar

fushar commented Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

@t-hamano Thanks for checking!

Therefore, if I test this PR with WordPress 6.9 or 7.0, I see a difference in background color on boot-based pages.
As an alternative approach, if the WordPress version is 7.0 or lower, we might consider reverting only the background color of the boot page to its previous setting.

Hmm don't think this counts a regression for WP < 7.1 because on those versions, we will already see different background, which is (always) black because it's not themed:

image

Does this really count as regression which needs backcompat? I'm pretty new to this so I might be wrong 😄

@t-hamano

t-hamano commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Hmm don't think this counts a regression for WP < 7.1 because on those versions, we will already see different background, which is (always) black because it's not themed:

You're right, inconsistencies in background color can already occur in trunk 😅 This pull request does not introduce any regressions and, in fact, includes improvements.

Comment on lines +64 to +65
const hasMobileAreas =
areas.mobileSidebar || areas.mobileContent || areas.preview;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that mobile got split into mobileSidebar + mobileContent.

Just to confirm: the item routes (template-item, page-item, pattern-item, template-part-item) no longer define any mobile* area, so on mobile they rely entirely on areas.preview being rendered in the canvas === 'edit' branch.

That leaves two edges that I'm not able to confirm if they are covered:

  1. canvas !== 'edit' on an item route: mobileContent and mobileSidebar are both undefined, so SidebarContent renders empty. Is canvas guaranteed to be 'edit' for these routes on mobile? Previously, the mobile area rendered the Editor/Unsupported screen unconditionally.
  2. Loading state: hasMobileAreas = areas.mobileSidebar || areas.mobileContent || areas.preview. For item routes, areas.preview resolves to null until siteData loads, so hasMobileAreas is falsy and the entire mobile block (site hub included) renders nothing during load. Routes that return <></> from mobileSidebar keep the hub visible in the same window.

If both paths are genuinely unreachable, could we add a short comment on the item routes (e.g. "mobile is handled via preview in edit canvas only") so this contract is explicit and we don't regress it later?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is canvas guaranteed to be 'edit' for these routes on mobile?

Yep, I checked and those "item routes" are only reachable on mobile at canvas=edit. For example:

page-item:

history.navigate( `/${ postType }/${ id }?canvas=edit` );

template-item:

`/${ item.type }/${ item.id }?canvas=edit`

pattern-item / template-part-item:

I added comments to clarify things: cd48d10.

Loading state

Returning null and <></> is equivalent here in this case fortunately, as in these canvas=edit routes, we don't render the mobile site hub component. So I believe we're good here!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmm, this "soft contract" about how routes define their areas and canvas modes feels particularly fragile, but I suppose that fragility already existed. It seems like there's a high risk to mistakenly cause blank rendering if someone doesn't specify canvas=edit in a route that doesn't define mobileContent or mobileSidebar. And it's the sort of issue that would be really easy to miss since most people probably aren't testing regularly on mobile. No amount of inline comments on the routes themselves would help this, it should be the responsibility of the Layout.

But at least as far as I understand, it's always worked this way, and hasn't gotten any worse with the changes here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmm, this "soft contract" about how routes define their areas and canvas modes feels particularly fragile, but I suppose that fragility already existed.

Yes, that's my impression as well 😅 there's nothing stopping us to provide the wrong areas, and some areas are overlapping across viewports, even before this change.

This PR does not try to solve the strictness as it seems to be much bigger refactor.

Comment thread packages/edit-site/src/components/layout/index.js Outdated

@ciampo ciampo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably update the PR description to mention https://core.trac.wordpress.org/changeset/62454 and a little bit more explanation about the change overall.

Comment thread packages/edit-site/src/components/layout/index.js Outdated

@fushar fushar left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably update the PR description to mention https://core.trac.wordpress.org/changeset/62454 and a little bit more explanation about the change overall.

Yep, I updated the PR description, thanks for the reminder!

Comment thread packages/edit-site/src/components/layout/index.js Outdated
Comment thread packages/edit-site/src/components/layout/index.js Outdated
Comment on lines +64 to +65
const hasMobileAreas =
areas.mobileSidebar || areas.mobileContent || areas.preview;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is canvas guaranteed to be 'edit' for these routes on mobile?

Yep, I checked and those "item routes" are only reachable on mobile at canvas=edit. For example:

page-item:

history.navigate( `/${ postType }/${ id }?canvas=edit` );

template-item:

`/${ item.type }/${ item.id }?canvas=edit`

pattern-item / template-part-item:

I added comments to clarify things: cd48d10.

Loading state

Returning null and <></> is equivalent here in this case fortunately, as in these canvas=edit routes, we don't render the mobile site hub component. So I believe we're good here!

Comment on lines -189 to +196
color: $white;
color: var(--wpds-color-fg-interactive-neutral-active);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, are there any more references that haven't been refactored yet?

To the best of my knowledge, now I think I've fixed them all!

@aduth aduth left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to preemptively approve this since this is looking to be in good shape overall and has gone through quite a few iterations. I left a few more comments that would be good to consider, and it sounds like we might have some more work to do on the color tokens side of things. If we're considering those as out of scope, can we at least track that effort somewhere?

Comment thread packages/edit-site/src/components/layout/index.js Outdated
Comment thread packages/edit-site/src/components/site-editor-routes/identity.js
Comment on lines +64 to +65
const hasMobileAreas =
areas.mobileSidebar || areas.mobileContent || areas.preview;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmm, this "soft contract" about how routes define their areas and canvas modes feels particularly fragile, but I suppose that fragility already existed. It seems like there's a high risk to mistakenly cause blank rendering if someone doesn't specify canvas=edit in a route that doesn't define mobileContent or mobileSidebar. And it's the sort of issue that would be really easy to miss since most people probably aren't testing regularly on mobile. No amount of inline comments on the routes themselves would help this, it should be the responsibility of the Layout.

But at least as far as I understand, it's always worked this way, and hasn't gotten any worse with the changes here.

@fushar fushar left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to preemptively approve this since this is looking to be in good shape overall and has gone through quite a few iterations.

Thanks for all your comments patience (and other reviewers)! I am going to merge this soon. I believe it's in a good shape now.

I left a few more comments that would be good to consider, and it sounds like we might have some more work to do on the color tokens side of things. If we're considering those as out of scope, can we at least track that effort somewhere?

Yeah, I created a new issue as noted here: https://github.com/WordPress/gutenberg/pull/78397/changes/BASE..87c14037c5d98141b3274f34ea4952dc5c17cb06#r3370732998

Comment thread packages/edit-site/src/components/site-editor-routes/identity.js
Comment thread packages/edit-site/src/components/layout/index.js Outdated
Comment on lines -189 to +196
color: $white;
color: var(--wpds-color-fg-interactive-neutral-active);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created a separate issue instead to track this: #79001

Comment on lines +64 to +65
const hasMobileAreas =
areas.mobileSidebar || areas.mobileContent || areas.preview;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmm, this "soft contract" about how routes define their areas and canvas modes feels particularly fragile, but I suppose that fragility already existed.

Yes, that's my impression as well 😅 there's nothing stopping us to provide the wrong areas, and some areas are overlapping across viewports, even before this change.

This PR does not try to solve the strictness as it seems to be much bigger refactor.

@fushar fushar merged commit d18be22 into trunk Jun 8, 2026
41 of 42 checks passed
@fushar fushar deleted the admin-bar-in-editor-color-4 branch June 8, 2026 04:20
@github-actions github-actions Bot added this to the Gutenberg 23.4 milestone Jun 8, 2026
@ciampo

ciampo commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

@fushar Thank you for taking this to the finishing line!

There are a couple more follow-up tasks / PRs that we discussed, just to make sure they're not left behind:

Do you mind creating issues for it ? Would you also have time to work on follow-ups personally?

@fushar

fushar commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

There are a couple more follow-up tasks / PRs that we discussed, just to make sure they're not left behind:

@ciampo: I'll answer below:

fixing the bg color leaking under the global styles panel (#78397 (comment))

Yeah, I totally missed that! Fixed in #79056.

improving the untyped / uncheck "soft contrast" about how routers define their areas and canvas mode (#78397 (comment))

Hmm I'm not sure if I have any better idea for this. As explained in #78397 (comment), this PR does not really make things worse; it's the inherent limitation from the beginning. I think it's out of scope and I don't have bandwidth to try to "fix" this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Base styles /packages/base-styles [Package] Edit Site /packages/edit-site [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proposal: Apply the Theme component to the sidebar of the Site Editor

10 participants