Skip to content

Enable second navigation menu on pages (#300)#309

Merged
alexgibson merged 3 commits intomozilla:masterfrom
stephaniehobson:nav
Feb 21, 2019
Merged

Enable second navigation menu on pages (#300)#309
alexgibson merged 3 commits intomozilla:masterfrom
stephaniehobson:nav

Conversation

@stephaniehobson
Copy link
Copy Markdown
Contributor

@stephaniehobson stephaniehobson commented Feb 12, 2019

  • make navigation button code only open its associated menu
  • update navigation template macro
    • add download button and mozilla logo as optional parameters
    • remove id from template as it was not being consumed
  • add second menu to navigation demo page

@alexgibson alexgibson self-requested a review February 12, 2019 08:49
@stephaniehobson stephaniehobson added Review: S Code review time: 30 mins to 1 hour Needs:Review 👋 Ready for Developer Review labels Feb 13, 2019
@stephaniehobson
Copy link
Copy Markdown
Contributor Author

Needs tests but the other code is ready for a first pass.

Copy link
Copy Markdown
Contributor

@alexgibson alexgibson left a comment

Choose a reason for hiding this comment

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

Code-wise I think this looks fine, although I have some slight reservations about the usefulness of a navigation organism that only contains a menu molecule, and nothing else. The only real functionality it provides here is hiding the menu on small screens behind a hamburger icon. I guess this may well be justification enough, but the alternative would be just to use a second Menu molecule on the page? This is kinda what I originally had in mind for the Menu being a separate thing, although whether or not this turns out to be more complicated than it's worth is another question. Either way, it's up to you here as you have a specific usecase in mind.

navButtons[i].addEventListener('click', Navigation.onClick, false);
}
}
Navigation.setAria();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could setAria() be inside the if (navItemsLists.length > 0) {} conditional?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

<button class="mzp-c-navigation-menu-button" type="button" aria-controls="map-c-navigation-items">Menu</button>
<div class="mzp-c-navigation-logo"><a href="https://www.mozilla.org/">Mozilla</a></div>
{{#if logo}}<div class="mzp-c-navigation-logo"><a href="https://www.mozilla.org/">Mozilla</a></div>{{/if}}
<div class="mzp-c-navigation-items" id="mzp-c-navigation-items">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should probably remove ids like id="mzp-c-navigation-items" from the component if we're now using more than one in a single page?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

✅ ID is now configurable (we need to keep an ID for the ARIA to work properly)

* Event handler for navigation menu button `click` events.
*/
Navigation.onClick = function(e) {
var thisNavItemList = e.target.parentNode.querySelector('.mzp-c-navigation-items');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If there can now be multiple navigation menus on one page, should we pass thisNavItemList as a parameter to onNavOpen and onNavClose, so those callbacks can work out which menu was interacted with?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@stephaniehobson
Copy link
Copy Markdown
Contributor Author

I do want the collapse functionality for my use case.

However, I also misunderstood the documentation on the Menu page thinking only the part that displays on hover is the menu. I will add a visual example to that page of the entire menu component since I found it hard to synthesize the code example without it.

- make navigation button code only open its associated menu
- update navigation template macro
  - add download button and mozilla logo as optional parameters
  - remove id from template as it was not being consumed
- add second menu to navigation demo page
@stephaniehobson
Copy link
Copy Markdown
Contributor Author

Updated.

@alexgibson alexgibson merged commit 2504acd into mozilla:master Feb 21, 2019
@stephaniehobson stephaniehobson removed the Needs:Review 👋 Ready for Developer Review label Apr 3, 2019
@stephaniehobson stephaniehobson deleted the nav branch September 23, 2019 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Review: S Code review time: 30 mins to 1 hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants