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

Mobile menu: add vertical menu 'style' for navigation block #37

Merged
merged 5 commits into from
May 26, 2023

Conversation

laurelfulford
Copy link
Contributor

@laurelfulford laurelfulford commented May 25, 2023

All Submissions:

Changes proposed in this Pull Request:

This PR is largely a work around to a shortcoming to the navigation block/our work around for the mobile navigation:

By default, the navigation block has its own mobile version baked in. The limitation is that this mobile version only included the one menu -- and if you had multiple menus, each could display as its own hamburger menu on mobile.

As a work around, we're using a template part to act as the mobile menu, so it can be edited independently. This gives us a lot more flexibility with how the header and mobile nav can be structured.

Now the problem: the navigation block doesn't have a nice way to display for mobile when it's not using its own mobile settings. There is a 'click to open' option that I thought would work (it seemed really close!), but it turned each of the parent menu items into a button, and they no longer linked to the pages, just acted as a toggle for the submenus. This could work, but only with specific menu structures (and the toggle for the setting seemed to disappear randomly -- something I need to dig into!).

As something of a work-around, this PR adds a block style to the navigation block that "flattens" it when it's set to a vertical orientation. The result is similar to our mobile menus now: a set of nested lists that displays all the links in the menu without interaction.

At the moment, it's a little inelegant -- the option is available regardless of the menu's orientation -- but we should be able to refine that down the road so it's only available when the menu is vertical. In the meantime, the styles are only applied when the is-vertical CSS class is present.

See 1202263311415249-as-1204678201828709

How to test the changes in this Pull Request:

  1. Apply the PR, and confirm that none of your template parts have edits saved. This can be done by navigating to Appearance > Site Editor > Template Parts, and clicking 'Manage all template parts' at the bottom of the left hand list. Template parts that have been edited with include the note 'Customized', and can be reset using the ... menu:

image

  1. Navigate to Site Editor > Template Parts > Mobile Sidebar
  2. Make sure a menu is assigned to the menu block there -- you can pick an existing one using the ... dropdown in the menu panel in the right hand column:

image

  1. Under the styles tab, confirm you have a "Flatten Vertical Navigation" style option, and that it's enabled by default for this menu:

image

  1. Confirm that the menu is indeed flattened -- there's no dropdowns or anything in the preview:

image

  1. Toggle to the default and confirm that the menu collapses, and you get dropdowns:

image

  1. Switch the menu back to 'Flatten Vertical Navigation', and save your changes.
  2. View on the front-end; scale down your browser window until you see the menu toggle, and click it.
  3. Confirm that the menu in the mobile menu space is "flattened":

image

  1. You can also repeat the steps 7 - 10 for the menu in the Desktop Header template part, to confirm the styles aren't applied when the menu is set to use the horizontal orientation.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

Copy link
Member

@miguelpeixe miguelpeixe left a comment

Choose a reason for hiding this comment

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

The workaround works well when visualizing the menu in the editor! An issue I had is when I start editing the labels. When editing either the parent menu item or the sub-menu item, the sub-item gets relocated to the side of the parent item.

This also happens if I edit through the sidebar panel.

Gravacao.de.Tela.2023-05-25.as.19.26.37.mov

@laurelfulford
Copy link
Contributor Author

Oh awesome catch! 🙌 I have a pretty big menu that I was testing with, and editing it turned absolutely chaotic!

There was some block level styles resetting the width with ! important; I fixed them in b05de98 and also fixed a weird issue where the block appender + sign wasn't really visible (Adding it to my list of "weird things to look up"!)

Copy link
Member

@miguelpeixe miguelpeixe left a comment

Choose a reason for hiding this comment

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

Thank you for revising, renders correctly now! 🙌

@laurelfulford
Copy link
Contributor Author

Awesome, thanks @miguelpeixe! 🎉

@laurelfulford laurelfulford merged commit 7b00671 into master May 26, 2023
@laurelfulford laurelfulford deleted the feat/add-vertical-nav-styles branch May 26, 2023 18:06
matticbot pushed a commit that referenced this pull request May 31, 2023
# [1.2.0-alpha.2](v1.2.0-alpha.1...v1.2.0-alpha.2) (2023-05-31)

### Bug Fixes

* correct spacer block values ([#42](#42)) ([05980d9](05980d9))
* remove style.css from the theme repo ([#32](#32)) ([51d849f](51d849f))

### Features

* add block style to 'flatten' mobile nav ([#37](#37)) ([7b00671](7b00671))
* building out 404 page ([#43](#43)) ([514111e](514111e))
@matticbot
Copy link

🎉 This PR is included in version 1.2.0-alpha.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

matticbot pushed a commit that referenced this pull request Jun 5, 2023
# [1.2.0](v1.1.0...v1.2.0) (2023-06-05)

### Bug Fixes

* correct block formatting error in the mobile header ([#22](#22)) ([96e727b](96e727b))
* correct spacer block values ([#42](#42)) ([05980d9](05980d9))
* remove style that doesn't work from theme.json ([#31](#31)) ([0762bac](0762bac))
* remove style.css from the theme repo ([#32](#32)) ([51d849f](51d849f))
* remove unnecessary spacing from navigation menu ([#20](#20)) ([9e8fbdd](9e8fbdd))
* replace query with HPB in no-results view ([#39](#39)) ([c77aa29](c77aa29))

### Features

* add archive, author archive templates ([#35](#35)) ([927a982](927a982))
* add block style to 'flatten' mobile nav ([#37](#37)) ([7b00671](7b00671))
* add block styles; tweak nav styles ([#21](#21)) ([7e2c22a](7e2c22a))
* add content width and wide width, and apply the wide width to the header/footer ([#15](#15)) ([9d53a26](9d53a26))
* add copyright symbol to footer ([#34](#34)) ([7ce6f74](7ce6f74))
* add front page template ([#23](#23)) ([7f44cfe](7f44cfe))
* add greys from WordPress to custom variables ([#25](#25)) ([08f2d7b](08f2d7b))
* add initial search template ([#36](#36)) ([6c80dba](6c80dba))
* add spacing scale ([#19](#19)) ([8c7ae41](8c7ae41))
* add styles to homepage posts block, post carousel ([#38](#38)) ([6d5f871](6d5f871))
* adding desktop header MVP ([#17](#17)) ([f155af4](f155af4))
* building out 404 page ([#43](#43)) ([514111e](514111e))
* first pass at base fonts, colours ([#11](#11)) ([bf6b91b](bf6b91b))
* first pass at initial footer pattern ([#24](#24)) ([301852d](301852d))
* initial mobile header pattern ([#18](#18)) ([b088c54](b088c54))
* initial pass at comments styles ([#27](#27)) ([f04de4b](f04de4b))
* initial single post layout ([#26](#26)) ([603abb7](603abb7))
* update dropcap height and size, pullquotes, captions ([3d8c3f0](3d8c3f0))
@matticbot
Copy link

🎉 This PR is included in version 1.2.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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.

3 participants