Admin UI: ship shared WPDS design-tokens stylesheet on Jetpack admin pages#49345
Conversation
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! Jetpack plugin: No scheduled milestone found for this plugin. If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
Code Coverage SummaryCoverage changed in 2 files.
Full summary · PHP report · JS report If appropriate, add one of these labels to override the failing coverage check:
Covered by non-unit tests
|
8176aa6 to
b8de04a
Compare
…pages Register a single token-only stylesheet sourced from @wordpress/theme's design-tokens.css and enqueue it on every Jetpack admin page, so var(--wpds-*) values resolve at runtime instead of falling back to hand-written hex on the legacy _inc Dashboard, Settings, and Debugger pages. admin-ui owns and registers the handle (enqueued on its modernized dashboards); the Jetpack plugin enqueues the same handle on the is_jetpack_admin_page() gate to cover the wrap_ui pages that aren't registered through Admin_Menu. The handle is registered once and deduped, so it's a single source on both chokepoints.
b8de04a to
9b5828a
Compare
Remove the two legacy Hello Dolly rules now that WPDS design tokens load on every Jetpack admin page (#48750 build-time for the legacy _inc pages, #49345 runtime for modernized pages): - `.wp-admin #dolly` (admin-static.scss, static #87a6bc) - `.jetpack-pagestyles #dolly` (_main.scss, $gray ~= #a1a1a1) The central `.jetpack-admin-page #dolly` rule (token-based, resolves to #707070) now governs consistently. The legacy rules only competed with it at equal specificity. Their `position: relative` used all-zero offsets (visually identical to static), so removal causes no layout shift; Dolly converges to #707070 with hello.php's default padding, and the central rule's `@media (max-width: 659px) { display: none }` already covers the breakpoint the legacy rules handled. My Jetpack's `p#dolly { display: none }` and JITM adjacency are untouched. Verified live on the dev site: Dashboard #dolly computed color #707070, same top/left/width as baseline (no positioning regression). Part of #49285 (Phase 4).
Part of #49285 (Phase 2b).
Proposed changes
Give every Jetpack admin page a single, shared runtime source for WPDS design tokens (
--wpds-*) by registering one token-only stylesheet and enqueuing it at two chokepoints. This letsvar(--wpds-*)consumers resolve to the design-system value instead of their hand-written hex fallback, and replaces the per-package bundled token copies (the version-skew vector) with one versioned handle.projects/packages/admin-ui— adds@wordpress/themeas a build dependency, emits a token-onlybuild/design-tokens.css(sourced from@wordpress/theme/design-tokens.css, content-hash versioned viadesign-tokens.asset.php), and exposes a single reusable static API —Admin_Menu::enqueue_design_tokens()— that registers thejetpack-admin-ui-design-tokenshandle on first use (idempotent) and enqueues it.Admin_Menuis the natural owner: it's the repo-wide chokepoint every modernized Jetpack admin page registers through, so it's the only class that knows their hook suffixes (tracked in$page_hooks) and scopes the enqueue to them. A localsrc/design-tokens.cssre-export is used (rather than pointing the webpack entry straight at the package) so the import is inlined by css-loader instead of being externalized to a non-existentwp-theme/design-tokens.cssscript handle.projects/plugins/jetpack— admin-ui is a dependency of the Jetpack plugin, so the legacy/wrap_ui pages (Settings, Dashboard, Debugger) that aren't registered throughAdmin_Menusimply call the sameAdmin_Menu::enqueue_design_tokens()API from the centralis_jetpack_admin_page()gate (admin_enqueue_scripts).Both call sites keep only their own page-scoping gate and delegate the register+enqueue to the one shared API, so there is a single owner of the handle and no duplicated enqueue logic — one registered handle, one HTTP request, no per-plugin CSS duplication. Any future consumer can enqueue the tokens the same way.
The stylesheet is token-only: its only rules are
:root{--wpds-*}, the[data-wpds-theme-provider-id][data-wpds-density=*]token-override blocks, and a retina@mediawrapping:root. No component or class selectors, so there is no component-style bleed.What this does and doesn't do on the legacy
_incpagesThis is the subtle part, worth stating explicitly:
--wpds-*defined on:rootat runtime on the legacy pages — but it does not change the visible Hello Dolly color there. The legacy_incbuild runspostcss-custom-propertieswithpreserve:false, which inlinesvar(--wpds-*, #fallback)to a literal and strips thevar()at build time. So the_inc-compiled Dolly rule has no livevar()left to consume the runtime token. Hello Dolly on Dashboard/Settings/Debugger is colored by the companion build-time PR Jetpack: resolve WPDS design tokens in legacy dashboard CSS #48750, which inlines the token to#707070in the_incbuild itself.@wordpress/uicomponents (which ship livevar(--wpds-*), not stripped_incCSS), this runtime token source becomes load-bearing. Removing it now would just mean re-adding it mid-migration. It's a token-only, deduped, single-request stylesheet, so the cost of carrying it ahead of need is negligible.Out of scope (later phases)
.wp-admin #dolly/.jetpack-pagestyles #dollyrules (Phase 4, separate PR).Related product discussion/links
_incpages): Jetpack: resolve WPDS design tokens in legacy dashboard CSS #48750--wpds-*source on wrap_ui pages): Normalize Hello Dolly across Jetpack admin pages + consistent WPDS token loading #49285 (comment)Does this pull request change what data or activity we track or use?
No.
Testing instructions
In-browser probe on the dev site, run in the browser console on each page:
Expected: a non-empty
#707070(previously empty, so anyvar(--wpds-…, #87a6bc)consumer fell back to#87a6bc). Note: this confirms the custom property is now defined on:root— on the legacy_incpages that is the token source, not the Dolly color (see "What this does and doesn't do" above).Verified results:
--wpds-*defined on:rootadmin.php?page=jetpack#707070✅admin.php?page=jetpack#/settings#707070✅admin.php?page=jetpack-debugger#707070✅Source-of-token proof (Dashboard): disabling the enqueued
design-tokens.cssstylesheet makes the:rootcustom property go empty again, confirming this stylesheet is the sole runtime source of the property on the legacy page.Token-only proof: the emitted
build/design-tokens.csscontains only:root,[data-wpds-theme-provider-id][data-wpds-density=*], and a retina@media{:root}— no component/class selectors.design-tokens.asset.phphas'dependencies' => array()(nothing externalized).Gates run:
phpcs(both PHP files),stylelint(new CSS),eslint, dev + production webpack build withvalidate-es, admin-ui PHP unit tests — all pass.Screenshots: design tokens defined on the legacy Jetpack Dashboard
The visible
#87a6bc → #707070Hello Dolly shift is demonstrated/owned by #48750. The screenshots below show this PR's effect: with the stylesheet in place,--wpds-*resolves to the WPDS value on the legacy Dashboard (applying a live token-based#dollyrule for illustration).Before (no runtime token source — property empty):
After (token resolves to
#707070):