-
Notifications
You must be signed in to change notification settings - Fork 3
Varya: Add mobile navigation treatment (Alternate) #56
Conversation
…when the mobile menu is still open.
I haven't yet tested with WooCommerce — I think I'll need to add a little extra styling to get that working too. |
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.
Looks and behaves as expected!
varya/assets/js/main-navigation.js
Outdated
*/ | ||
|
||
( function() { | ||
document.getElementById( "toggle-menu" ).onclick = function() { |
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 might be overkill, but I think this will cause a TypeError if for some reason the page loads without an element of id toggle-menu
.
We could do something like:
document.getElementById( "toggle-menu" ) ?
document.getElementById( "toggle-menu" ).onclick = function() { ... } : null;
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.
Alternatively or maybe in addition to this, we should add a conditional here that only enqueues this script when the menu-1
location is actually active. That way, we only enqueue this script when its needed which will ensure that the #toggle-menu
ID will be available in the dom.
Getting a bit of a regression here compared to #50. Seems related to the WC button/cart and maybe some conflicting selectors and/or styles?
Also, wondering if we can improve the JS function to use scoping and relative variables so we can make it one function and use it for both the main menu UI and the WC menu UI. Happy to take a stab at it if you need :-) |
- refactor menu JS to deal with main menu and WC menu - improve menu button scoping for better toggling
Yeah, I stripped out the WC-related
Definitely — the JS there is really basic, and it'd make sense to use it in both places. Please feel free to pick this up and build that in! |
- use separate classes for locked scrolling and menu-open behaviors - clean up wc-menu markup and icons - remove duplicate wc styles from main stylesheet - clean up header markup - code tidying
…when the mobile menu is still open.
- use separate classes for locked scrolling and menu-open behaviors - clean up wc-menu markup and icons - remove duplicate wc styles from main stylesheet - clean up header markup - code tidying
@kjellr added some improvements to optimize the JS and unify this solution so it works for both the main menu and the Woo menu together without scoping conflicts. Note: I went ahead and updated the SVG icons to work with #52 so when it’s merged the close and menu icons should appear as expected. |
… menu would not display on click.
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.
Awesome, this works well.
Could use a little design direction here. Feels a bit awkward when you click the Menu button and the Close button jumps.
Let's just move the Woo cart over to the left:
Once that's all set, I think this is good to go. I want to make sure the desktop menu items are center-aligned (currently they're actually left-aligned), but I can take care of that in follow-up PR. 👍
Thanks!
This PR is identical to #50, except for a couple things:
body
doesn't scroll underneath the menu anymore.The menu on desktop should look 100% the same when compared to
master
.Screenshot: