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

Disable menu with CSS on mobile devices #2538

Merged
merged 1 commit into from Oct 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion engines/common/nucleus/particles/menu.html.twig
Expand Up @@ -123,7 +123,7 @@
{% import _self as macro %}

{% if menu.root.count() %}
<nav class="g-main-nav" role="navigation"{{ particle.mobileTarget ? ' data-g-mobile-target' : '' }} data-g-hover-expand="{{ particle.hoverExpand|default('true') ? 'true': 'false' }}">
<nav class="g-main-nav{{ particle.disableMobile ? ' g-hide-mobile' : '' }}" role="navigation"{{ particle.mobileTarget ? ' data-g-mobile-target' : '' }} data-g-hover-expand="{{ particle.hoverExpand|default('true') ? 'true': 'false' }}">
<ul class="g-toplevel">
{{ macro.displayItems(menu.root, menu, _context) }}
</ul>
Expand Down
6 changes: 6 additions & 0 deletions engines/wordpress/nucleus/particles/menu.yaml
Expand Up @@ -70,3 +70,9 @@ form:
label: Force Target Attribute
description: 'Adds ''target="_self"'' attribute to all menu items. Fixes an issue with pinned tabs in Firefox where external links always open in a new tab.'
default: 0

disableMobile:
type: input.checkbox
label: Disable on Mobile
description: Check this field to completely disable the menu on mobile devices. This prevents menu flickering but you might end with no menu when JS is not supported by the respective device.
default: 0
7 changes: 7 additions & 0 deletions themes/hydrogen/common/scss/hydrogen/_nav.scss
Expand Up @@ -93,6 +93,13 @@
}
}

.g-main-nav.g-hide-mobile{
@include breakpoint(mobile-only) {
display: none;
visibility: hidden;
}
}

#g-navigation, #g-header {
.align-left {
.g-toplevel {
Expand Down