-
Notifications
You must be signed in to change notification settings - Fork 29
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
Local Navigation: Improve style and behavior across screen sizes #573
Conversation
From #535
I think we're missing this behaviour, for me the page name is visible in the local nav before scrolling local.nav.scroll.mp4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great 👍
Fixes the Docs bug for me and nails most of the new behaviour. I've left comments for things I've found but none are blockers imo.
I thought the animation of both the W and the page title was a little strange, so I'm waiting for some feedback on the main issue (see the comment here).
Could you bring that up on the main issue? #535 |
…s and spacing to match designs
…title would cause the text to wrap
On some sites (like Documentation), this is 24px, while it's 20px on Developer.
6f6e7eb
to
8e5458b
Compare
Fixed with bba3713
I've added a class to fade-in the page title, and updated developer to use it. It'll look like this: fade-in-page.mp4I think that addresses all the feedback here, but let me know if I missed something. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and looks good 👍
This PR implements the style & behavior changes described in #535. The biggest change is that the navigation will now switch to the collapsed (mobile) view if it does not have enough space to stay on one single line (fixes WordPress/wporg-documentation-2022#80).
I did that by dropping in a second menu automatically - a filter is added to any nav blocks with
wporg/local-navigation-bar
as a parent block. That filter (add_extra_navigation
) runs over the render_block HTML, so it can use all the same block attributes to create a secondwp:navigation
which is always in the collapsed (mobile) state. It's also given a special class name, so that it can be hidden/made visible by CSS. This ensures only one menu is visible/accessible at a time. In the javascript, a function is added to resize to check the available width against the section title & navigation items, and toggles the appropriate class based on what fits better.Using a second menu like this also avoids trying to work around the current navigation menu toggle code, which has changed dramatically in the past.
Since the "mobile" view now shows on non-mobile screen sizes, the design was also updated and the styles here switch to a dropdown style when this version is shown at >600px wide.
There are also style changes to update focus styles & minor spacing fixes.
Screenshots
Documentation, using the page from WordPress/wporg-documentation-2022#80:
The bottom border should only show when scrolling:
about-section-scroll.mp4
Here's an example of the menu collapsing when it would have wrapped (plus the "L3 header" variant updates):
https://github.com/WordPress/wporg-mu-plugins/assets/541093/71c069fd-9a7c-4c28-9e27-50c385faa286
Some long page titles still overflow the space available even with the collapsed nav menu. I've just set them to overflow:hidden, and at 550px wide, the page title is hidden.
To test
Check out this PR and use it with any site, it doesn't require any local changes.
I'll have a separate PR for Developer to implement the different page level header templates, which was used to capture some of these screenshots.