Skip to content
This repository has been archived by the owner on Jun 18, 2020. It is now read-only.

Varya: Add mobile navigation treatment #50

Closed
wants to merge 12 commits into from
Closed

Conversation

kjellr
Copy link
Contributor

@kjellr kjellr commented Apr 3, 2020

This PR adds a small-screen menu treatment to match the design comps. Still a few things to do:

  • Fix bug where the top of the screen is scrollable.
  • Adjust the position of the menu if the WP-Admin bar is visible. (Currently it gets hidden behind the bar).
  • Fix the horizontal scroll overflow.

... and probably some more bugs too!


Before:

mobile-menu-before

After:

mobile-menu

@kjellr kjellr added the enhancement New feature or request label Apr 3, 2020
@kjellr kjellr self-assigned this Apr 3, 2020
@kjellr kjellr requested review from jffng and allancole April 6, 2020 19:21
@kjellr kjellr marked this pull request as ready for review April 6, 2020 19:22
@kjellr
Copy link
Contributor Author

kjellr commented Apr 6, 2020

This is ready for a review. The only major bug at this point is that it appears to be totally weird in Safari. 😄 I'm still looking into that, but if you happen to determine why please let me know.

--primary-nav--font-size-mobile: var(--global--font-size-xxl);
--primary-nav--font-size-sub-menu-mobile: var(--global--font-size-lg);
--primary-nav--font-style: normal;
--primary-nav--font-style-sub-menu-mobile: italic;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some of these new variables feel bit granular, but I included them because I figure we'll want to override them pretty easily for child themes.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, at first I thought this might’ve been too complex, but its actually kind of necessary to easily make a ‘Vanilla’ version. 👍

@kjellr
Copy link
Contributor Author

kjellr commented Apr 6, 2020

Just added a subtle animation too (slowed down for the GIF):

menu

Copy link
Contributor

@jffng jffng left a comment

Choose a reason for hiding this comment

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

Mobile menu is looking nice! I encountered two bugs:

  1. The desktop menu is inheriting a few mobile styles, so it's not appearing:
    no desktop menu

  2. The content underneath the menu is still scrollable on mobile
    content_scroll_bug
    :

@kjellr
Copy link
Contributor Author

kjellr commented Apr 7, 2020

The desktop menu is inheriting a few mobile styles, so it's not appearing:

Ah, that was working until my last animation commit. 😄 I can sort that out.

The content underneath the menu is still scrollable on mobile

This is a tougher one. I'm not totally sure I can restrict that without JS. Will take a closer look.

@kjellr
Copy link
Contributor Author

kjellr commented Apr 7, 2020

The desktop menu is inheriting a few mobile styles, so it's not appearing:

This should be fixed in e0e7eb0.

The content underneath the menu is still scrollable on mobile

I did some further digging for this one, but I'm not sure we can implement without adding some (very simple) JavaScript. Right now, the menu is opened and closed via just some CSS and a checkbox. There is a CSS property that could do what we're looking for, but its browser support isn't great. As it stands now, we otherwise reach up the DOM tree to tell the rest of the page not to move when the menu is open.

A potential fix would be to allow the background scroll, but hide it completely behind the menu (this is what happens on logged out views already). This would at least remove the distraction of the scrolling content. But when you close the menu, you'd be in a new spot on the page, which is disorienting. In addition, this would require placing our theme's menu above the WP-Admin menu, which seems hacky, and also requires the Menu button to move when the menu is open:

menu

Given all that, I think the simplest approach would be to just add a quick couple lines of JavaScript to handle this for us. The theme is mostly devoid of JavaScript at this moment, but it seems like this is a good use case for it.

Would it make sense to handle that in a separate PR? (and either way, would you mind doing another review of the code here?)

@jffng jffng self-requested a review April 7, 2020 18:36
Copy link
Contributor

@jffng jffng left a comment

Choose a reason for hiding this comment

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

I made a handful of changes that address the desktop menu positioning.

Here's what I was seeing before:

Screen Shot 2020-04-07 at 12 47 30 PM

And after:

Screen Shot 2020-04-07 at 2 36 49 PM

@kjellr
Copy link
Contributor Author

kjellr commented Apr 8, 2020

Thanks @jffng! Seeing the menu up there, I'm having second thoughts about its position. I think rather than keep the menu up there (as in the original comps), it would be simpler to put it back down underneath the site branding. This will remove a bit of the awkward hierarchy that's present when the menu is up top, but the branding is below it.

I imagine that might be a better starting point for child themes too. I'll add a couple commits to take care of that.

@nielslange
Copy link
Member

Based on https://uxplanet.org/the-ultimate-guide-to-the-hamburger-menu-and-its-alternatives-e2da8dc7f1db (and other similar sites), I was wondering if it wouldn't make more sense to have the mobile navigation at the bottom of the screen, thus, where it's much easier to reach? (Please ignore my comment if you believe that the hamburger menu is the way to proceed here.)

@kjellr
Copy link
Contributor Author

kjellr commented Apr 8, 2020

I was wondering if it wouldn't make more sense to have the mobile navigation at the bottom of the screen, thus, where it's much easier to reach?

For apps, yes. But in the case of the mobile web, some web browsers (Safari 👀) have UI that actually makes bottom-aligned buttons a bit more difficult to use. Here's an example showing that opening a bottom on Safari menu frustratingly takes two taps instead of one:

menu-bottom

@kjellr
Copy link
Contributor Author

kjellr commented Apr 8, 2020

I got some fixes queued up for this, but it turns out they also break the mobile menu. I'm starting to think I should take a step back and spin this all up in a fresh PR — one with a little snippet of JS from the start, with a cleaner approach.

Copy link
Collaborator

@allancole allancole left a comment

Choose a reason for hiding this comment

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

Looks great! All this needs is support for the Woo cart.

Desktop Mobile
image image

--primary-nav--font-size-mobile: var(--global--font-size-xxl);
--primary-nav--font-size-sub-menu-mobile: var(--global--font-size-lg);
--primary-nav--font-style: normal;
--primary-nav--font-style-sub-menu-mobile: italic;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, at first I thought this might’ve been too complex, but its actually kind of necessary to easily make a ‘Vanilla’ version. 👍

--primary-nav--font-weight: normal;
--primary-nav--color-link: var(--global--color-primary);
--primary-nav--color-link-hover: var(--global--color-primary-hover);
--primary-nav--color-text: var(--global--color-foreground);
--primary-nav--padding: calc(0.66 * var(--global--spacing-unit) );
--primary-nav--justify-content: center;
--primary-nav--icon-size: 24px;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if this can be connected to a nav-line-height or nav-font-size variable, so the icon size can be relative as opposed to an absolute pixel value—if thats even possible.

@allancole
Copy link
Collaborator

Given all that, I think the simplest approach would be to just add a quick couple lines of JavaScript to handle this for us. The theme is mostly devoid of JavaScript at this moment, but it seems like this is a good use case for it.

Agreed 👍

Would it make sense to handle that in a separate PR?

Seems like the JS would be simple enough to do it on this PR 👍

@kjellr
Copy link
Contributor Author

kjellr commented Apr 8, 2020

Closing in favor of #56.

@kjellr kjellr closed this Apr 8, 2020
@kjellr kjellr deleted the update/mobile-menu branch April 8, 2020 20:01
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants