Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor and simplify navigation block CSS. #29465

Merged
merged 6 commits into from Mar 10, 2021
Merged

Conversation

jasmussen
Copy link
Contributor

Description

The purpose of this PR is to refactor, cleanup, simplify and reduce the CSS for the navigation block. Ultimately this should benefit further CSS tweaks and pattern creation.

How has this been tested?

So as to have as basic an experience as possible, and to not be too influenced by theme styles initially, I tested using "Empty Theme", which you can get here: https://github.com/WordPress/theme-experiments

But it should also be tested at least with TT1 blocks, and other themes that style the navigation block.

Please test page list, manual page items, the setup state for both the navigation block and the menu item, test submenus. Please test editor and frontend.

You should not see any visual difference between this branch and trunk.

Screenshots

Editor, empty theme:

Screenshot 2021-03-02 at 12 05 01

Frontend, empty theme:

Screenshot 2021-03-02 at 12 05 07

Editor, TT1 Blocks:

Screenshot 2021-03-02 at 12 07 17

Frontend, TT1 Blocks:

Screenshot 2021-03-02 at 12 07 21

It also fixes a rare issue where you manage to activate the sibling inserter, with a submenu open. Before:

before

After:

after

Types of changes

A number of changes:

  • Retired theme.scss. The styles in that file are structural enough that the block needs to rely on them being present.
  • Simplified and reduced the "reset" styles that target margins and paddings and list styles for ULs.
  • Rearranged chunks of code to be close to related styles, and did whitespace and comment cleanups.
  • Removed some CSS that appeared to be dead, from the old placeholder state using a custom dropdown.
  • Added a couple of @todos that we might be able to address in a review of this PR, relating to more seemingly dead CSS.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • I've tested my changes with keyboard and screen readers.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR.

@jasmussen jasmussen added the [Block] Navigation Affects the Navigation Block label Mar 2, 2021
@jasmussen jasmussen self-assigned this Mar 2, 2021
@@ -1,17 +1,23 @@
// Normalize Link and edit containers, to look mostly the same.
.wp-block-navigation-link__field .components-text-control__input.components-text-control__input,
.wp-block-navigation-link__field .components-text-control__input.components-text-control__input, // @todo: this selector doesn't appear to target anything.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could not find any instance of the wp-block-navigation-link__field except in this style.

Copy link
Contributor

Choose a reason for hiding this comment

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

Same here. Should we just remove it now?

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 for removing unused rules. If we're unsure we can maybe follow up in a second second PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 👍

// Make it the same height as the appender to prevent a jump. Maybe revisit this.
line-height: $button-size;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could potentially remove the "Maybe revisit this" comment, as this is now revisited. Submenus should be allowed to inherit line height rules from the theme, in editor and frontend, and it does not appear to cause issues to remove it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good to me. 👍

@@ -33,13 +39,13 @@
}
}

// Separator
// Separator. @todo: this appears unused.
.wp-block-navigation-link__separator {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could not find anything that used this class.

Copy link
Contributor

Choose a reason for hiding this comment

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

Like the one above, I suggest we just remove this. We can always add it back in if someone notices something we missed.

@@ -93,12 +97,11 @@
// NOTE TO DEVS - if refactoring this code, please double-check that
// submenus have a default background color, this feature has regressed
// several times, so care needs to be taken.
background-color: $white;
color: $gray-900;
background-color: #fff;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since this is the style.scss file, it should use plain hex colors, not the editor UI variables.

Copy link
Contributor

Choose a reason for hiding this comment

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

This make sense for now. For block-based themes though, I wonder if we can automatically pull this in from the default text/background colors as defined in theme.json. 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We definitely should. In the mean time, this was a teensy "while I'm here" change.

}
// These need extra specificity.
.editor-styles-wrapper .wp-block-navigation {
ul {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed the "ol" rule here, as it does not appear we use the ordered list for structure, anywhere in the code.

}

.wp-block-navigation__inserter-content {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Appeared unused.

@@ -61,6 +62,8 @@
}
}
}

// Show submenus on hover.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Has the context for the decision to show these on hover changed? We could potentially remove the sensitive hover/focus-within rules entirely, and rely on &.is-selected or &.has-child-selected to keep it open. This would open the menu not just on hover, but on select too, and keep it open until deselected. This seems like it could simplify both the CSS and the user experience, and avoid the IE polyfill that is noted as necessary.

Copy link
Contributor

Choose a reason for hiding this comment

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

I sm a fan of removing this on hover behavior and sticking to selection when editing. The only thing in my head to consider is that if the menu is indeed opening on hover when rendered, the user should be awayre that the edit behavior is different than the rendered behavior.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just in case there's any doubt, this PR doesn't change the behavior yet, just added a comment to describe the current behavior.

But yes, I think we can be opinionated about the edit behavior and keep it open on select. But we could also show it on hover, and keep that behavior. And we'd still be able to remove the need for the suggested polyfill.

Once this PR lands, I'll try this separately, we can see how it feels 👍

@@ -212,6 +164,21 @@ $color-control-label-height: 20px;
* Setup state
*/

// Ensure that an empty block has space around the appender.
// @todo: revisit this to allow thinner menus.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The min-height should ideally only be applied to the setup state showing the "skeleton indicators", otherwise we make it harder for themes to create small menus, like this one:

Screenshot 2021-03-02 at 12 19 46

But I'd like to do this separately.

ul li {
list-style: none;

// Overrides generic ".entry-content li" styles on the front end.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These styles were previously in the theme.scss stylesheet, but are structural so I moved them here.

I also simplified them and tweaked their specificity, which is still pretty low. I did verify they overrode generic .entry-content li margin rules a theme might add.

@github-actions
Copy link

github-actions bot commented Mar 2, 2021

Size Change: -1.14 kB (0%)

Total Size: 1.4 MB

Filename Size Change
build/block-library/blocks/navigation-link/editor-rtl.css 584 B -97 B (-14%) 👏
build/block-library/blocks/navigation-link/editor.css 586 B -97 B (-14%) 👏
build/block-library/blocks/navigation-link/style.css 691 B -1 B (0%)
build/block-library/blocks/navigation/editor-rtl.css 1.08 kB -273 B (-20%) 🎉
build/block-library/blocks/navigation/editor.css 1.08 kB -272 B (-20%) 🎉
build/block-library/blocks/navigation/style-rtl.css 227 B +14 B (+7%) 🔍
build/block-library/blocks/navigation/style.css 228 B +14 B (+7%) 🔍
build/block-library/editor-rtl.css 9.36 kB -191 B (-2%)
build/block-library/editor.css 9.35 kB -185 B (-2%)
build/block-library/style-rtl.css 8.84 kB +10 B (0%)
build/block-library/style.css 8.85 kB +10 B (0%)
build/block-library/theme-rtl.css 700 B -36 B (-5%)
build/block-library/theme.css 701 B -35 B (-5%)
ℹ️ View Unchanged
Filename Size Change
build/a11y/index.js 1.14 kB 0 B
build/annotations/index.js 3.78 kB 0 B
build/api-fetch/index.js 3.4 kB 0 B
build/autop/index.js 2.82 kB 0 B
build/blob/index.js 664 B 0 B
build/block-directory/index.js 8.63 kB 0 B
build/block-directory/style-rtl.css 1 kB 0 B
build/block-directory/style.css 1.01 kB 0 B
build/block-editor/index.js 125 kB 0 B
build/block-editor/style-rtl.css 12.1 kB 0 B
build/block-editor/style.css 12.1 kB 0 B
build/block-library/blocks/archives/editor-rtl.css 61 B 0 B
build/block-library/blocks/archives/editor.css 60 B 0 B
build/block-library/blocks/audio/editor-rtl.css 58 B 0 B
build/block-library/blocks/audio/editor.css 58 B 0 B
build/block-library/blocks/audio/style-rtl.css 112 B 0 B
build/block-library/blocks/audio/style.css 112 B 0 B
build/block-library/blocks/block/editor-rtl.css 161 B 0 B
build/block-library/blocks/block/editor.css 161 B 0 B
build/block-library/blocks/button/editor-rtl.css 475 B 0 B
build/block-library/blocks/button/editor.css 474 B 0 B
build/block-library/blocks/button/style-rtl.css 479 B 0 B
build/block-library/blocks/button/style.css 479 B 0 B
build/block-library/blocks/buttons/editor-rtl.css 315 B 0 B
build/block-library/blocks/buttons/editor.css 315 B 0 B
build/block-library/blocks/buttons/style-rtl.css 364 B 0 B
build/block-library/blocks/buttons/style.css 363 B 0 B
build/block-library/blocks/calendar/style-rtl.css 208 B 0 B
build/block-library/blocks/calendar/style.css 208 B 0 B
build/block-library/blocks/categories/editor-rtl.css 84 B 0 B
build/block-library/blocks/categories/editor.css 83 B 0 B
build/block-library/blocks/categories/style-rtl.css 79 B 0 B
build/block-library/blocks/categories/style.css 79 B 0 B
build/block-library/blocks/code/style-rtl.css 90 B 0 B
build/block-library/blocks/code/style.css 90 B 0 B
build/block-library/blocks/columns/editor-rtl.css 190 B 0 B
build/block-library/blocks/columns/editor.css 190 B 0 B
build/block-library/blocks/columns/style-rtl.css 421 B 0 B
build/block-library/blocks/columns/style.css 421 B 0 B
build/block-library/blocks/cover/editor-rtl.css 390 B 0 B
build/block-library/blocks/cover/editor.css 389 B 0 B
build/block-library/blocks/cover/style-rtl.css 1.24 kB 0 B
build/block-library/blocks/cover/style.css 1.24 kB 0 B
build/block-library/blocks/embed/editor-rtl.css 486 B 0 B
build/block-library/blocks/embed/editor.css 486 B 0 B
build/block-library/blocks/embed/style-rtl.css 401 B 0 B
build/block-library/blocks/embed/style.css 400 B 0 B
build/block-library/blocks/file/editor-rtl.css 199 B 0 B
build/block-library/blocks/file/editor.css 198 B 0 B
build/block-library/blocks/file/style-rtl.css 248 B 0 B
build/block-library/blocks/file/style.css 248 B 0 B
build/block-library/blocks/freeform/editor-rtl.css 2.45 kB 0 B
build/block-library/blocks/freeform/editor.css 2.45 kB 0 B
build/block-library/blocks/gallery/editor-rtl.css 689 B 0 B
build/block-library/blocks/gallery/editor.css 690 B 0 B
build/block-library/blocks/gallery/style-rtl.css 1.08 kB 0 B
build/block-library/blocks/gallery/style.css 1.07 kB 0 B
build/block-library/blocks/group/editor-rtl.css 318 B 0 B
build/block-library/blocks/group/editor.css 317 B 0 B
build/block-library/blocks/group/style-rtl.css 57 B 0 B
build/block-library/blocks/group/style.css 57 B 0 B
build/block-library/blocks/heading/editor-rtl.css 129 B 0 B
build/block-library/blocks/heading/editor.css 129 B 0 B
build/block-library/blocks/heading/style-rtl.css 76 B 0 B
build/block-library/blocks/heading/style.css 76 B 0 B
build/block-library/blocks/html/editor-rtl.css 281 B 0 B
build/block-library/blocks/html/editor.css 281 B 0 B
build/block-library/blocks/image/editor-rtl.css 717 B 0 B
build/block-library/blocks/image/editor.css 716 B 0 B
build/block-library/blocks/image/style-rtl.css 476 B 0 B
build/block-library/blocks/image/style.css 478 B 0 B
build/block-library/blocks/latest-comments/editor-rtl.css 159 B 0 B
build/block-library/blocks/latest-comments/editor.css 158 B 0 B
build/block-library/blocks/latest-comments/style-rtl.css 269 B 0 B
build/block-library/blocks/latest-comments/style.css 269 B 0 B
build/block-library/blocks/latest-posts/editor-rtl.css 137 B 0 B
build/block-library/blocks/latest-posts/editor.css 137 B 0 B
build/block-library/blocks/latest-posts/style-rtl.css 523 B 0 B
build/block-library/blocks/latest-posts/style.css 522 B 0 B
build/block-library/blocks/list/editor-rtl.css 65 B 0 B
build/block-library/blocks/list/editor.css 65 B 0 B
build/block-library/blocks/list/style-rtl.css 63 B 0 B
build/block-library/blocks/list/style.css 63 B 0 B
build/block-library/blocks/media-text/editor-rtl.css 191 B 0 B
build/block-library/blocks/media-text/editor.css 191 B 0 B
build/block-library/blocks/media-text/style-rtl.css 535 B 0 B
build/block-library/blocks/media-text/style.css 532 B 0 B
build/block-library/blocks/more/editor-rtl.css 434 B 0 B
build/block-library/blocks/more/editor.css 434 B 0 B
build/block-library/blocks/navigation-link/style-rtl.css 694 B 0 B
build/block-library/blocks/nextpage/editor-rtl.css 395 B 0 B
build/block-library/blocks/nextpage/editor.css 395 B 0 B
build/block-library/blocks/page-list/editor-rtl.css 215 B 0 B
build/block-library/blocks/page-list/editor.css 215 B 0 B
build/block-library/blocks/page-list/style-rtl.css 527 B 0 B
build/block-library/blocks/page-list/style.css 526 B 0 B
build/block-library/blocks/paragraph/editor-rtl.css 157 B 0 B
build/block-library/blocks/paragraph/editor.css 157 B 0 B
build/block-library/blocks/paragraph/style-rtl.css 288 B 0 B
build/block-library/blocks/paragraph/style.css 289 B 0 B
build/block-library/blocks/post-author/editor-rtl.css 209 B 0 B
build/block-library/blocks/post-author/editor.css 209 B 0 B
build/block-library/blocks/post-author/style-rtl.css 183 B 0 B
build/block-library/blocks/post-author/style.css 184 B 0 B
build/block-library/blocks/post-comments-form/style-rtl.css 250 B 0 B
build/block-library/blocks/post-comments-form/style.css 250 B 0 B
build/block-library/blocks/post-content/editor-rtl.css 139 B 0 B
build/block-library/blocks/post-content/editor.css 139 B 0 B
build/block-library/blocks/post-excerpt/editor-rtl.css 73 B 0 B
build/block-library/blocks/post-excerpt/editor.css 73 B 0 B
build/block-library/blocks/post-featured-image/editor-rtl.css 338 B 0 B
build/block-library/blocks/post-featured-image/editor.css 338 B 0 B
build/block-library/blocks/post-featured-image/style-rtl.css 100 B 0 B
build/block-library/blocks/post-featured-image/style.css 100 B 0 B
build/block-library/blocks/preformatted/style-rtl.css 63 B 0 B
build/block-library/blocks/preformatted/style.css 63 B 0 B
build/block-library/blocks/pullquote/editor-rtl.css 183 B 0 B
build/block-library/blocks/pullquote/editor.css 183 B 0 B
build/block-library/blocks/pullquote/style-rtl.css 318 B 0 B
build/block-library/blocks/pullquote/style.css 318 B 0 B
build/block-library/blocks/query-loop/editor-rtl.css 90 B 0 B
build/block-library/blocks/query-loop/editor.css 89 B 0 B
build/block-library/blocks/query-loop/style-rtl.css 315 B 0 B
build/block-library/blocks/query-loop/style.css 317 B 0 B
build/block-library/blocks/query-pagination-numbers/editor-rtl.css 122 B 0 B
build/block-library/blocks/query-pagination-numbers/editor.css 121 B 0 B
build/block-library/blocks/query-pagination/editor-rtl.css 270 B 0 B
build/block-library/blocks/query-pagination/editor.css 262 B 0 B
build/block-library/blocks/query-pagination/style-rtl.css 168 B 0 B
build/block-library/blocks/query-pagination/style.css 168 B 0 B
build/block-library/blocks/query/editor-rtl.css 814 B 0 B
build/block-library/blocks/query/editor.css 812 B 0 B
build/block-library/blocks/quote/editor-rtl.css 61 B 0 B
build/block-library/blocks/quote/editor.css 61 B 0 B
build/block-library/blocks/quote/style-rtl.css 169 B 0 B
build/block-library/blocks/quote/style.css 169 B 0 B
build/block-library/blocks/rss/editor-rtl.css 201 B 0 B
build/block-library/blocks/rss/editor.css 202 B 0 B
build/block-library/blocks/rss/style-rtl.css 290 B 0 B
build/block-library/blocks/rss/style.css 290 B 0 B
build/block-library/blocks/search/editor-rtl.css 165 B 0 B
build/block-library/blocks/search/editor.css 165 B 0 B
build/block-library/blocks/search/style-rtl.css 342 B 0 B
build/block-library/blocks/search/style.css 344 B 0 B
build/block-library/blocks/separator/editor-rtl.css 99 B 0 B
build/block-library/blocks/separator/editor.css 99 B 0 B
build/block-library/blocks/separator/style-rtl.css 236 B 0 B
build/block-library/blocks/separator/style.css 236 B 0 B
build/block-library/blocks/shortcode/editor-rtl.css 504 B 0 B
build/block-library/blocks/shortcode/editor.css 504 B 0 B
build/block-library/blocks/site-logo/editor-rtl.css 201 B 0 B
build/block-library/blocks/site-logo/editor.css 201 B 0 B
build/block-library/blocks/site-logo/style-rtl.css 115 B 0 B
build/block-library/blocks/site-logo/style.css 115 B 0 B
build/block-library/blocks/social-link/editor-rtl.css 164 B 0 B
build/block-library/blocks/social-link/editor.css 165 B 0 B
build/block-library/blocks/social-links/editor-rtl.css 696 B 0 B
build/block-library/blocks/social-links/editor.css 696 B 0 B
build/block-library/blocks/social-links/style-rtl.css 1.32 kB 0 B
build/block-library/blocks/social-links/style.css 1.32 kB 0 B
build/block-library/blocks/spacer/editor-rtl.css 317 B 0 B
build/block-library/blocks/spacer/editor.css 317 B 0 B
build/block-library/blocks/spacer/style-rtl.css 48 B 0 B
build/block-library/blocks/spacer/style.css 48 B 0 B
build/block-library/blocks/table/editor-rtl.css 478 B 0 B
build/block-library/blocks/table/editor.css 478 B 0 B
build/block-library/blocks/table/style-rtl.css 402 B 0 B
build/block-library/blocks/table/style.css 402 B 0 B
build/block-library/blocks/tag-cloud/editor-rtl.css 118 B 0 B
build/block-library/blocks/tag-cloud/editor.css 118 B 0 B
build/block-library/blocks/tag-cloud/style-rtl.css 94 B 0 B
build/block-library/blocks/tag-cloud/style.css 94 B 0 B
build/block-library/blocks/template-part/editor-rtl.css 557 B 0 B
build/block-library/blocks/template-part/editor.css 556 B 0 B
build/block-library/blocks/text-columns/editor-rtl.css 95 B 0 B
build/block-library/blocks/text-columns/editor.css 95 B 0 B
build/block-library/blocks/text-columns/style-rtl.css 166 B 0 B
build/block-library/blocks/text-columns/style.css 166 B 0 B
build/block-library/blocks/verse/editor-rtl.css 62 B 0 B
build/block-library/blocks/verse/editor.css 62 B 0 B
build/block-library/blocks/verse/style-rtl.css 87 B 0 B
build/block-library/blocks/verse/style.css 87 B 0 B
build/block-library/blocks/video/editor-rtl.css 504 B 0 B
build/block-library/blocks/video/editor.css 503 B 0 B
build/block-library/blocks/video/style-rtl.css 187 B 0 B
build/block-library/blocks/video/style.css 187 B 0 B
build/block-library/common-rtl.css 1.1 kB 0 B
build/block-library/common.css 1.1 kB 0 B
build/block-library/index.js 148 kB 0 B
build/block-serialization-default-parser/index.js 1.87 kB 0 B
build/block-serialization-spec-parser/index.js 3.06 kB 0 B
build/blocks/index.js 48.3 kB 0 B
build/components/index.js 283 kB 0 B
build/components/style-rtl.css 15.6 kB 0 B
build/components/style.css 15.6 kB 0 B
build/compose/index.js 11.1 kB 0 B
build/core-data/index.js 16.7 kB 0 B
build/customize-widgets/index.js 3.95 kB 0 B
build/customize-widgets/style-rtl.css 168 B 0 B
build/customize-widgets/style.css 168 B 0 B
build/data-controls/index.js 828 B 0 B
build/data/index.js 8.88 kB 0 B
build/date/index.js 31.8 kB 0 B
build/deprecated/index.js 769 B 0 B
build/dom-ready/index.js 577 B 0 B
build/dom/index.js 4.93 kB 0 B
build/edit-navigation/index.js 11.8 kB 0 B
build/edit-navigation/style-rtl.css 1.28 kB 0 B
build/edit-navigation/style.css 1.28 kB 0 B
build/edit-post/index.js 306 kB 0 B
build/edit-post/style-rtl.css 6.81 kB 0 B
build/edit-post/style.css 6.8 kB 0 B
build/edit-site/index.js 27.3 kB 0 B
build/edit-site/style-rtl.css 4.47 kB 0 B
build/edit-site/style.css 4.46 kB 0 B
build/edit-widgets/index.js 20.1 kB 0 B
build/edit-widgets/style-rtl.css 3.2 kB 0 B
build/edit-widgets/style.css 3.2 kB 0 B
build/editor/editor-styles-rtl.css 347 B 0 B
build/editor/editor-styles.css 347 B 0 B
build/editor/index.js 42.1 kB 0 B
build/editor/style-rtl.css 3.9 kB 0 B
build/editor/style.css 3.9 kB 0 B
build/element/index.js 4.61 kB 0 B
build/escape-html/index.js 735 B 0 B
build/format-library/index.js 6.75 kB 0 B
build/format-library/style-rtl.css 637 B 0 B
build/format-library/style.css 639 B 0 B
build/hooks/index.js 2.28 kB 0 B
build/html-entities/index.js 622 B 0 B
build/i18n/index.js 4.01 kB 0 B
build/is-shallow-equal/index.js 699 B 0 B
build/keyboard-shortcuts/index.js 2.53 kB 0 B
build/keycodes/index.js 1.95 kB 0 B
build/list-reusable-blocks/index.js 3.15 kB 0 B
build/list-reusable-blocks/style-rtl.css 629 B 0 B
build/list-reusable-blocks/style.css 628 B 0 B
build/media-utils/index.js 5.34 kB 0 B
build/notices/index.js 1.85 kB 0 B
build/nux/index.js 3.4 kB 0 B
build/nux/style-rtl.css 731 B 0 B
build/nux/style.css 727 B 0 B
build/plugins/index.js 2.9 kB 0 B
build/primitives/index.js 1.42 kB 0 B
build/priority-queue/index.js 791 B 0 B
build/react-i18n/index.js 1.46 kB 0 B
build/redux-routine/index.js 2.83 kB 0 B
build/reusable-blocks/index.js 3.78 kB 0 B
build/reusable-blocks/style-rtl.css 225 B 0 B
build/reusable-blocks/style.css 225 B 0 B
build/rich-text/index.js 13.4 kB 0 B
build/server-side-render/index.js 2.82 kB 0 B
build/shortcode/index.js 1.7 kB 0 B
build/token-list/index.js 1.27 kB 0 B
build/url/index.js 3.02 kB 0 B
build/viewport/index.js 1.86 kB 0 B
build/warning/index.js 1.14 kB 0 B
build/wordcount/index.js 1.22 kB 0 B

compressed-size-action

@jasmussen jasmussen force-pushed the update/improve-nav-css branch 2 times, most recently from cf6ac5e to e8d1ab3 Compare March 8, 2021 09:21
@jasmussen
Copy link
Contributor Author

Rebased and squashed to make it easier to rebase in the future.

@jasmussen jasmussen requested a review from a team March 8, 2021 09:21
@jasmussen
Copy link
Contributor Author

I'd be very grateful for reviews of this one.

Copy link
Contributor

@kjellr kjellr left a comment

Choose a reason for hiding this comment

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

I did some testing in TT1 Blocks, as well as a few non-block-based themes, and didn't notice any obvious regressions. I left some minor notes, but I think this seems fine to land either way.

@@ -1,17 +1,23 @@
// Normalize Link and edit containers, to look mostly the same.
.wp-block-navigation-link__field .components-text-control__input.components-text-control__input,
.wp-block-navigation-link__field .components-text-control__input.components-text-control__input, // @todo: this selector doesn't appear to target anything.
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here. Should we just remove it now?

// Make it the same height as the appender to prevent a jump. Maybe revisit this.
line-height: $button-size;
Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good to me. 👍

@@ -33,13 +39,13 @@
}
}

// Separator
// Separator. @todo: this appears unused.
.wp-block-navigation-link__separator {
Copy link
Contributor

Choose a reason for hiding this comment

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

Like the one above, I suggest we just remove this. We can always add it back in if someone notices something we missed.

.wp-block-navigation-link__separator {
margin: $grid-unit-10 0 $grid-unit-10;
border-top: $border-width solid $gray-300;
}

// Popover styles
// Popover styles. @todo: these all appear unused.
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is also unused (which it seems to be), it seems like a possible candidate for removal too.

@@ -93,12 +97,11 @@
// NOTE TO DEVS - if refactoring this code, please double-check that
// submenus have a default background color, this feature has regressed
// several times, so care needs to be taken.
background-color: $white;
color: $gray-900;
background-color: #fff;
Copy link
Contributor

Choose a reason for hiding this comment

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

This make sense for now. For block-based themes though, I wonder if we can automatically pull this in from the default text/background colors as defined in theme.json. 🤔

@jasmussen
Copy link
Contributor Author

Thanks so much for the review, Kjell!

I'll address your feedback, then land it sometime early tomorrow, so others can still chime in if they like.

@@ -41,6 +41,9 @@ $z-layers: (
".wp-block-cover__video-background": 0, // Video background inside cover block.
".wp-block-template-part__placeholder-preview-filter-input": 1,

// Navigation menu dropdown.
".has-child .wp-block-navigation-link__container": 28,
Copy link
Contributor

Choose a reason for hiding this comment

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

What value is the sibling inserter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Things like the block toolbar and the sibling inserter have been moved to "popovers", that is, children of the block-editor-block-list__insertion-point-popover element that sits outside the editing canvas and is then overlaid. That element has z-index 28 also:

Screenshot 2021-03-10 at 09 44 57

https://github.com/WordPress/gutenberg/blob/f8c841abc15f10b34123486baa32d4a752bdf460/packages/base-styles/_z-index.scss#L119

Copy link
Contributor

@gwwar gwwar left a comment

Choose a reason for hiding this comment

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

Thanks @jasmussen for simplifying styles. ✨

I did a bit of smoke testing, but wasn't able to spot differences. Another +1 review wouldn't hurt.

It may help other reviewers to rebase this PR to pickup the typing fix for navigation links. (Previously editing would break the block).

@jasmussen
Copy link
Contributor Author

Great point Kerry, freshly rebased! Thanks so much for the reviews.

I'll keep this one open and address the points brought up tomorrow, and re-request a review if the changes are substantial, and in the mean time, I'd welcome all the sanity checks you can afford.

Copy link
Contributor

@shaunandrews shaunandrews left a comment

Choose a reason for hiding this comment

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

All seems well. Skimming the code and all seems to make sense. Can't wait for further PR's that removes some of this, and reconsiders the decisions to show submenus on hover.

@jasmussen
Copy link
Contributor Author

I've addressed the feedback, rebased, and the changes were small. It still tests well for me, and as I've noticed that this PR also fixes a small issue that was introduced by #29590, I'm going to land it when the checks pass.

Thanks, all, for the reviews. I will of course address any followups.

@talldan
Copy link
Contributor

talldan commented Mar 10, 2021

@jasmussen Has this been tested in the Navigation Editor at all? It looks to me like there already a few styling regressions there in trunk.

@jasmussen
Copy link
Contributor Author

I did test the earlier version, yes, but I'll give it another spin now after the rebases and tweaks. Thank you.

@talldan
Copy link
Contributor

talldan commented Mar 10, 2021

I'm seeing the 'Add a link' button looks mis-sized and dropdown menus are back instead of accordions:
Screenshot 2021-03-10 at 5 20 47 pm

But I don't think they're caused by this PR, so you may be fine to carry on. I can make an issue.

@jasmussen
Copy link
Contributor Author

This is what I see in trunk:

trunk

This is what I see in this branch:

this branch

Lots of little things to tweak, I'll see if I can help with that. But from what I can see, the experience is mostly the same between trunk and this branch. I'm not really seeing what you were seeing, not quite sure how to reproduce.

@jasmussen
Copy link
Contributor Author

I just tested one last time with the menu item placeholders, that seems to have been what you were referring to. I'm seeing this, and it looks reasonably correct in both (with the exception of the nav screen needing menu item placeholder polish). Trunk:

trunk

This branch:

this branch

@jasmussen
Copy link
Contributor Author

I'm going to land this one and, again, follow up on any issues that come from it.

@jasmussen jasmussen merged commit 1c1db1e into trunk Mar 10, 2021
@jasmussen jasmussen deleted the update/improve-nav-css branch March 10, 2021 10:20
@github-actions github-actions bot added this to the Gutenberg 10.2 milestone Mar 10, 2021
@talldan
Copy link
Contributor

talldan commented Mar 10, 2021

@jasmussen The different styles you're seeing are because of this bug - #28874

If you try a different theme (e.g. normal TT1) you should see the same as me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Navigation Affects the Navigation Block
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants