Skip to content

Administration: Paint notices from design system tokens. - #16198

Open
jasmussen wants to merge 1 commit into
WordPress:trunkfrom
jasmussen:update/restyle-admin-notices-to-wpds-tokens
Open

jasmussen wants to merge 1 commit into
WordPress:trunkfrom
jasmussen:update/restyle-admin-notices-to-wpds-tokens

Conversation

@jasmussen

Copy link
Copy Markdown

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

Notices get a surface, a full hairline border, a corner radius and a text colour, in place of today's white box with a 4px coloured bar on one side. The paint comes from --wpds-* design system tokens, so a notice follows whatever theme the tokens resolve to.

Alternative to #16129 which tokenises all values based on the feedback shared there. That PR makes the same visual change with literal values and no new dependency; this one makes it with tokens, adds wp-theme where it is needed, and brings the login screen along.

What changed

src/wp-admin/css/common.css

  • the surface, border colour, border width, corner radius and text colour of .notice, div.updated and div.error, and of the four tones, come from var(--wpds-*)
  • the dismiss button takes the notice's tone through color: inherit, gets an outline focus ring instead of a box-shadow one so the ring survives forced-colors mode, and takes its corner radius from the small radius token

src/wp-admin/css/login.css

  • the same paint, from the same tokens, so the login screen's messages look like the admin's
  • .login .message takes the info tone, .login .success the success tone, and notice-error, notice-warning, notice-success and notice-info take theirs, which is the tone the markup already declares

src/wp-includes/script-loader.php

  • the common and login style handles now depend on wp-theme, the stylesheet that defines the tokens

src/wp-admin/css/themes.css and src/wp-admin/css/customize-controls.css

  • two contexts where a notice is a full-bleed band rather than a box of its own now set border-radius: 0. See "Audit" below.

Paint, not geometry

Typography is left for separate work, so font-size and line-height stay as literal values.

Tokens, per stylesheet

wp-theme is declared as a dependency of common and of login rather than of the wp-admin bundle. Those are the stylesheets that hold notice rules, so the tokens load wherever they load, including a plugin page that enqueues common on its own. customize-controls depends on wp-admin, which depends on common, so the Customizer picks the tokens up through that chain.

Which radius token

The design system documents the radius scale by the kind of element each step is for. --wpds-border-radius-lg is "cards, dialogs, notices, and other larger content containers", which is the notice box. --wpds-border-radius-sm is "standalone buttons, inputs, and compact controls", which is the dismiss button. Both resolve to the values used today, 8px and 2px.

Nothing moved

Computed styles were compared against the literal-value version of this change across 18 notice variants and four probes each: the box, its paragraph, the dismiss button and the notice title. Of 1102 properties compared, 1037 are identical and 65 differ. None of the differences is geometry: every radius, border width, padding, margin, font-size, line-height, box-shadow and outline value is unchanged.

All 65 come from five token values, where the token no longer resolves to the literal:

Role Token Literal Token resolves to Largest channel difference
Neutral surface --wpds-color-background-surface-neutral-weak #f3f3f3 #f4f4f4 1
Success border --wpds-color-stroke-surface-success #91d29c #92d39d 1
Warning border --wpds-color-stroke-surface-warning #e0bc7d #e1bd7c 1
Error border --wpds-color-stroke-surface-error #e1b1a9 #e0afa7 2
Info border --wpds-color-stroke-surface-info #acc5e2 #adc6e2 1

The other twelve values match their tokens exactly.

Contrast is unchanged for the four tones and marginally better for neutral, because only the surface moved and the text colours did not: neutral goes from 15.02:1 to 15.16:1; success stays at 15.23:1, warning at 15.65:1, error at 15.58:1 and info at 15.60:1. The login screen's five tones measure identically to the admin's.

The login screen

wp-login.php renders its messages through wp_admin_notice(), so the markup is already the admin's, but the login screen does not load common.css and so kept the old look. Leaving it out would have made it the one screen where a notice does not follow the design system, which is the opposite of the point, so it is in: login.css repeats the notice paint from the same tokens.

Its messages take the tone their markup declares. An instructional message is rendered as notice notice-info, so it is now info-toned instead of carrying a brand-blue bar, and an error is error-toned. login.css also carried a comment reading "Match border color from common.css", which is gone along with the literals it described.

Audit

Notices were checked in the places they appear, since a full border has more neighbours than a bar on one side does. Two contexts needed a fix, both because a notice there is a band pinned to a container's edges rather than a box of its own, and both fixed with border-radius: 0:

  • theme cards (.theme .notice), where the notice is absolutely positioned across the top of a card that clips at its own 8px radius. The card clips at a 7px inner curve while the band curved at 8px, which left the card's background showing in a sliver at each top corner, and rounded the band's bottom corners in mid-card.
  • the Customizer's notification area, panel and section containers, and per-control notifications, where notices measure the full width of their container with no inset and stack flush with 1px separators. An 8px radius turned the stack into a column of rounded pills.

Everywhere else the notice is already inset by a margin and reads correctly as a box: Site Health, Privacy, Settings, Profile, the Dashboard, the Media Library and the image editor in the media modal, plugin update and auto-update rows, Add Plugins cards including dependency notices, Nav Menus, Quick Edit and the filesystem credentials form. The block editor and the block-based widgets screen do not render admin_notices in their chrome.

Nothing in the audit needed a geometry change. Two gaps worth naming: the network admin was not rendered, because the test install is single-site, though no admin stylesheet contains a network-specific notice rule; and the media modal was reviewed from its CSS rather than rendered, because the install had no attachments.

Icons

Not in this patch yet, but worth doing. Let me know your preference, happy to open a separate patch, or include it here or in #16129.

Testing

  1. Visit any admin screen with a notice. Site Health shows several.
  2. Check each tone, the legacy div.updated and div.error classes, .notice-alt, .notice-large, .notice-title, .notice.inline, dismissible notices and multi-paragraph notices.
  3. Check the two audited contexts: a theme card with an update available, and the Customizer's notification area.
  4. Confirm the dismiss button still sits where it sits today and is still centred on the first line.
  5. Log out and back in, and check wp-login.php?loggedout=true, a failed login, and the lost-password flow.
  6. Set data-wpds-root-provider="true" and data-wpds-corner-radius="none" on the root element: notices and their dismiss buttons should square off in the admin and on the login screen, and nothing else should move.
  7. Below 782px, in RTL and in forced-colors mode.

Notices get a surface, a full hairline border, a corner radius and a text colour, in place of a white box with a 4px coloured bar on one side. The paint comes from `--wpds-*` tokens, so a notice follows the theme the tokens resolve to rather than freezing one revision of the colour algorithm.

Adds `wp-theme` as a dependency of the `common` and `login` style handles. The dependency is declared per stylesheet rather than on the `wp-admin` bundle, so the tokens also load on screens that enqueue those stylesheets on their own.

The login screen renders its messages through `wp_admin_notice()`, so its markup is already the admin's, but it does not load `common.css`. Its notice paint is repeated in `login.css` from the same tokens, and its messages now take the tone their markup declares.

Sets `border-radius: 0` on notices in theme cards and in the Customizer's notification containers, where a notice is a band pinned to its container's edges rather than a box of its own.

The dismiss button's corner radius comes from the small radius token, so it follows the theme along with the notice it sits in.

Padding, margins, font size and line height are unchanged, as are the dismiss button's position and size.

See #66777.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant