Site Editor: Apply the user's admin color scheme#78397
Conversation
0fc11f7 to
231eebb
Compare
|
Size Change: +1.09 kB (+0.01%) Total Size: 7.97 MB 📦 View Changed
ℹ️ View Unchanged
|
|
Flaky tests detected in 231eebb. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/26037324025
|
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
There was a problem hiding this comment.
I'm not sure that "WordPress app" concerns (such as named theme presets) should live in the @wordpress/theme package, which is supposed to be focused on app-agnostic features and tokens.
There was a problem hiding this comment.
Interesting, I thought because admin color scheme is a core WP feature, it could belong in that package.
OK, I moved the logic to @wordpress/admin-ui instead via f733f13. I think that's a better place. What do you think?
There was a problem hiding this comment.
admin-ui feels like a better fit given current constraints (dependency graph), although I don't know if it is the correct choice in general terms.
@wordpress/theme is app-agnostic, and focuses on tokens + theming primitives
There was a problem hiding this comment.
I would say admin-ui is also not the best fit, since admin color schemes will be used in wider contexts (like post/page editors as well).
If we consider the future of the @wordpress/components package as a more higher-level package of things with explicit WordPress coupling, maybe @wordpress/components is actually a better place 😄
deb7ee6 to
ccce419
Compare
ccce419 to
f733f13
Compare
| height: 100%; | ||
| background: $gray-900; | ||
| color: $gray-400; | ||
| background: var(--wpds-color-bg-surface-neutral); |
There was a problem hiding this comment.
I think these backgrounds should use --wpds-color-bg-surface-neutral-weak.
There was a problem hiding this comment.
We should use interactive tokens for interactive elements like buttons.
There was a problem hiding this comment.
We should use interactive tokens instead of content tokens here too.
There was a problem hiding this comment.
More instances of replacing content tokens with interactive tokens :)
There was a problem hiding this comment.
More interactive tokens :)
| width: 100%; | ||
| .components-input-control__container { | ||
| background: $gray-800; | ||
| background: var(--wpds-color-bg-interactive-neutral-weak-active); |
There was a problem hiding this comment.
-active is reserved for states like hover, focus, active, etc.
There was a problem hiding this comment.
If we use InputControl from the ui package we should inherit theming automatically.
|
|
||
| .components-button { | ||
| color: $gray-200 !important; | ||
| color: var(--wpds-color-fg-content-neutral) !important; |
There was a problem hiding this comment.
Use interactive token.
| @@ -44,7 +44,7 @@ | |||
| &:hover, | |||
| &:focus, | |||
| &:active { | |||
| color: $gray-200; | |||
| color: var(--wpds-color-fg-content-neutral); | |||
There was a problem hiding this comment.
More instances where we should use interactive tokens.
| color: var(--wpds-color-fg-content-neutral); | ||
|
|
||
| &:hover, | ||
| &:active { | ||
| svg { | ||
| fill: $gray-100; | ||
| fill: var(--wpds-color-fg-content-neutral); | ||
| } |
There was a problem hiding this comment.
More interactive tokens :)
|
Was also about to share similar feedback to @jameskoster re. using the correct tokens. The |
| }; | ||
| } | ||
|
|
||
| export function UserThemeProvider( { |
There was a problem hiding this comment.
Maybe we should rename the provider to AdminColorThemeProvider ?
There was a problem hiding this comment.
I feel like exposing getAdminThemeColors() may be sufficient, rather than exporting a wrapper with ThemeProvider included. This kind of wrapper adds a lot of indirection overhead for discovery/documentation.
| [ 'light', '#e5e5e5' ], | ||
| ] ); | ||
|
|
||
| export function getAdminThemeColors() { |
There was a problem hiding this comment.
Should we also expose this function in case non-react consumers need to get the same theme colors info?
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 +
ThemeProviderrather than overriding in the experiment SCSS file.How?
UserThemeProviderfrom@wordpress/bootinto@wordpress/theme@wordpress-admin-ui, so both the Site Editor (@wordpress/edit-site) andbootcan share one implementation.UserThemeProvideris aThemeProviderpre-seeded from the user's admin color scheme. It now also pass thebgcolor toThemeProviderin addition toprimary. Previously,boothardcoded the sidebar background to#1d2327; it's now based on the admin color scheme.@wordpress/edit-sitenow wraps the layout in the sharedUserThemeProvider.edit-site's component SCSS files to WPDS tokens. I used trial-and-error with my AI agent until the token set looks good (check screenshot).Limitations
/wp-admin/admin.php?page=site-editor-v2) is EXCLUDED for now. The page does not add the color scheme to the<body>'sclass. I'm not sure if that's intended? It does work correctly on otherbootpages like Appearance -> Fonts.colors.bg) toThemeProvider, will generate slightly different background and text color than the corresponding pair in Core. For example, in Sunrise, the sidebar has black text but the admin bar has white text:I believe this is because this is what the theme package thinks the best combination a11y-wise based on the passed
primaryandbgcolor seed. Is this acceptable? I don't know what to do otherwise, since this whole thing is generated.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
bootpages such as Appearance -> Fonts.Screenshots
Appearance -> Fonts
(Check the right and bottom sides; they now follow the background color instead of black.)
Site Editor
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