Skip to content

Commit

Permalink
Adding support for no megamenu localnav (#3421)
Browse files Browse the repository at this point in the history
  • Loading branch information
bandana147 authored Jan 8, 2025
1 parent b0d094b commit 490a349
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion libs/blocks/global-navigation/global-navigation.css
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ header.global-navigation {

/* Hamburger toggle */
.feds-toggle {
width: 60px;
margin: 0;
padding: 0;
border: none;
Expand All @@ -99,6 +98,7 @@ header.global-navigation {
cursor: pointer;
font-size: 20px;
font-weight: 300;
padding-left: 20px;
}

.feds-toggle:before {
Expand All @@ -125,6 +125,7 @@ header.global-navigation {

.feds-brand {
display: flex;
padding-left: 22px;
}

.feds-logo {
Expand Down
12 changes: 9 additions & 3 deletions libs/blocks/global-navigation/global-navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,13 @@ class Gnav {
.elements
.navWrapper
?.querySelectorAll('.feds-nav > section.feds-navItem')
?.length === 1;
?.length <= 1;

hasMegaMenu = () => this
.elements
.navWrapper
?.querySelectorAll('.feds-nav > section.feds-navItem')
?.length >= 1;

toggleMenuMobile = () => {
const toggle = this.elements.mobileToggle;
Expand All @@ -800,7 +806,7 @@ class Gnav {
disableMobileScroll();
const sections = document.querySelectorAll('header.new-nav .feds-nav > section.feds-navItem > button.feds-navLink');
animateInSequence(sections, 0.075);
if (this.isLocalNav()) {
if (this.isLocalNav() && this.hasMegaMenu()) {
const section = sections[0];
queueMicrotask(() => section.click());
}
Expand All @@ -816,7 +822,7 @@ class Gnav {
};

decorateToggle = () => {
if (!this.mainNavItemCount) return '';
if (!this.mainNavItemCount || !this.hasMegaMenu()) return '';

const toggle = toFragment`<button
class="feds-toggle"
Expand Down

0 comments on commit 490a349

Please sign in to comment.