Repository navigation
Boot: Migrate styles to CSS Modules - #81756
Conversation
10042bc to
3c73ea3
Compare
|
Size Change: +2.29 kB (+0.03%) Total Size: 7.74 MB 📦 View Changed
|
|
Flaky tests detected in 3c73ea3. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/32035765970 should open the inspector panel in
|
jsnajdr
left a comment
There was a problem hiding this comment.
This full migration is much better than the superficial :global one. Let's abandon the other PR and merge all the changes into this one, and base it on trunk.
| key={ index } | ||
| to={ item.to } | ||
| shouldShowPlaceholder={ false } | ||
| isNested |
There was a problem hiding this comment.
Is this really the best way how we can declare that NavigationItem children of DropdownItem have a smaller min-height, grid-unit-30 instead of the default grid-unit-40?
There was a problem hiding this comment.
Removed the isNested prop, moved those overrides to target directly :global(.components-item) when the item in inside the dropdown, ie. nested (since other item styles are already applied that way, anyway)
|
@jsnajdr the idea was to have a 2-phased migration for ease of reviewing, I definitely agree that this PR represents the end state we'd like to reach I'd like to test GitHub stacks, should we try to keep the two PRs separate (as now) but merge them the whole stack at once? |
|
Personally I'd prefer to review one all-in-one diff, but if you want to test stacks, why not, it's not a big deal 🙂 |
3c73ea3 to
7dd7d3d
Compare
|
@jsnajdr merged all changes in this PR. We can test stacks another time |
There was a problem hiding this comment.
cc @youknowriad to make sure this change is correct (I'm basically trying to remove the need for a global .boot-layout-container classname
There was a problem hiding this comment.
Moved to packages/boot/src/components/root/_view-transitions.module.scss
|
This is working well in my tests, can't spot issues. I think the biggest changes seems to be around menu navigation, I didn't try but maybe we should register some drill down menus to check. Regardless though, we have no use-case for this at the moment. |
jsnajdr
left a comment
There was a problem hiding this comment.
Looks good to me now 👍 Thanks for doing this migration so quickly and for addressing all feedback.
|
This PR causes the notification UI to be left-aligned and hidden.
gutenberg/packages/boot/src/components/root/_layout.module.scss Lines 37 to 39 in 8749590 The cause is that the @mixin snackbar-container() {
// ...
.components-snackbar {
margin-inline: auto;
}
}There are probably many ways to solve this, but what do you think about centering the Snackbar component itself? Perhaps we shouldn't have created this mixin in the first place. |
Opened #81995 with a quick fix. Re. centering the Snackbar, I don't have enough context on it to recommend the change. We should probably open a separate issue to discuss it and involve the folks with the most expertise on it |
| ); | ||
| ?> | ||
| </div> | ||
| <div id="{{PAGE_SLUG}}-wp-admin-app" class="boot-layout-container"></div> |
There was a problem hiding this comment.
Dropping boot-layout-container from the element also removed the only class Core's boot stylesheet uses to give the admin page viewport height. Now there's an odd gap below, which is a regression.
The ID-based :not() selector is fine on its own. The fix is either to keep the class on the div, or to move those height rules in @wordpress/boot to .boot-layout so they no longer depend on an ancestor class the template controls.
Screenshot

What?
Migrate all
@wordpress/bootstyles to CSS Modules and encapsulate Boot-owned DOM classes.Why?
This uses the supported
@wordpress/style-runtimeregistration path, prevents Boot's private shell styles from leaking, and makes the unsupported internal-class boundary explicit.How?
.module.scssand use local module mappings.@wordpress/style-runtimedependency and its TypeScript project reference.aria-current="page"anddata-status="active"state..components-itemselectors with private NavigationItem module classes.boot-layout-container.Testing Instructions
init()andinitSinglePage().Testing Instructions for Keyboard
Navigate the sidebar, dropdowns, drilldown screens, save controls, and modal using only Tab, Shift+Tab, Enter, Space, Escape, and arrow keys. Focus indicators, activation, and focus return should behave as before.
Removed global class audit
An exact-name search across the current Gutenberg source tree confirms that these 27 Boot-owned global class names have zero remaining usages:
boot-layout-container,boot-layout,boot-layout--single-page,boot-layout__canvas,boot-layout__inspector,boot-layout__mobile-sidebar-drawer,boot-layout__sidebar,boot-layout__sidebar-backdrop,boot-layout__stage,boot-layout__surfaces,boot-notices__snackbarboot-dropdown-item,boot-dropdown-item__chevron,boot-dropdown-item__children,boot-navigation-item,boot-navigation-screen,boot-navigation-screen__actions,boot-navigation-screen__description,boot-navigation-screen__title,boot-navigation-screen__title-iconboot-error-boundary,boot-save-button,boot-save-button__shortcut,boot-sidebar__back-button,boot-sidebar__content,boot-sidebar__footer,boot-sidebar__scrollableMost were replaced by private CSS Module classes. WP Build now identifies its generated mount by the existing page-specific ID.
boot-navigation-screen__descriptionhad no associated selector, so it needed no replacement.Other Boot styling hooks:
.active; active state uses existingaria-current="page"anddata-status="active"attributes..with-suffixand canvas.is-full-canvaswere removed.is-mobile,is-up,has-canvas,has-full-canvas, andhas-mobile-drawer) are now private CSS Module classes. These generic names can still occur elsewhere in Gutenberg, so they are not repository-wide removals.edit-site-save-panel__modalremains owned and used by Edit Site. This PR only removes Boot's dependency on it.These classes are internal implementation details rather than supported styling APIs. Repository search cannot verify whether third-party npm consumers rely on them.
Verification
Passed focused JavaScript and CSS linting, dependency and package validation,
npm run lint:tsconfig,npm run typecheck, the fullnpm run build, transformed CSS inspection, generated PHP syntax checks, the exact removed-class search, and commit hooks. Browser and iframe matrix testing remains manual.Use of AI Tools
Codex assisted with implementation, CI diagnosis, adversarial review, and local verification. The author reviewed and accepted the resulting changes.