Skip to content

Commit f160251

Browse files
authored
Merge pull request #62 from couchbase/top-level-menu
Remove main menu from top level and show other top menu link
2 parents 890c984 + e686bf1 commit f160251

File tree

3 files changed

+35
-5
lines changed

3 files changed

+35
-5
lines changed

preview-src/ui-model.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ site:
1717
url: /index.html
1818
navigation:
1919
- content: Introduction
20+
url: /index.html
21+
urlType: fragment
2022
items:
2123
- content: Why Couchbase?
2224
url: '#'

src/js/01-nav.js

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,36 @@
150150
var topPositon = currentPageMenu.offsetTop
151151
var leftMenu = document.querySelector('.left-sidebar-menu .nav-menu')
152152
leftMenu.scrollTop = topPositon
153-
}
154-
}, 200)
155153

154+
// show depth 0 child element
155+
156+
var otherNavs = document.querySelectorAll('.nav-list > .nav-item[data-depth="0"]')
157+
otherNavs.forEach(function (nav) {
158+
var navSubMenu = Array.from(nav.querySelector('ul.nav-list').children)
159+
// var navDataDepth = Array.from(nav.querySelector('ul.nav-list'))
160+
navSubMenu.forEach(function (item) {
161+
item.classList.remove('is-inactive')
162+
})
163+
164+
// hide main menu for top level navigation -
165+
166+
if (nav.className.includes('is-current-page')) {
167+
navMenuControl.style.display = 'none'
168+
}
169+
170+
// hide in second level menu
171+
if (nav.className.includes('is-current-path')) {
172+
otherNavs.forEach(function (navItem) {
173+
if (!navItem.className.includes('is-current-path')) {
174+
navItem.classList.add('is-inactive')
175+
}
176+
})
177+
}
178+
})
179+
// if(otherNavs) {
180+
181+
// }
182+
}
183+
}, 100)
156184
// clearTimeout(scrollCurrentPageMenu, 20000)
157185
})()

src/partials/nav-tree.hbs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{{#if navigation}}
22
{{#each navigation}}
33
{{#if (eq ../crumbAtLevel this)}}
4-
{{#if ( eq ../crumbLevel 0 or eq ../crumbLevel 1 or eq ../crumbLevel 2)}}
5-
<div class="main-nav-parent new">
4+
{{#if ( eq ../crumbLevel 0 or eq ../crumbLevel 1 or eq ../crumbLevel 2 or eq ../crumbLevel 3)}}
5+
<div class="main-nav-parent new " data-depth="{{../level}}">
66
<span class="back-to-menu"><i class="fas fa-chevron-left"></i> Main Menu </span>
77
{{!-- <span class="nav-text">{{{./content}}}</span> --}}
88
</div>
@@ -14,7 +14,7 @@
1414
{{#each navigation}}
1515
<li class="nav-item{{#if (eq ../crumbAtLevel this)}}
1616
{{~#if (eq this (last @root.page.breadcrumbs))}} is-current-page{{~else}} is-current-path{{/if}} is-active
17-
{{~else if (eq ../level 0)}} {{!--is-active--}} is-inactive{{/if}}{{#if (eq ../crumbAtLevel this (and eq ../level 2))}} is-active-depth-2 {{/if}} " data-depth="{{../level}}">
17+
{{~else if (eq ../level 1)}} {{!--is-active--}} is-inactive{{/if}}{{#if (eq ../crumbAtLevel this (and eq ../level 2))}} is-active-depth-2 {{/if}} " data-depth="{{../level}}">
1818

1919
{{#if ./content}}
2020
<span class="nav-line " data-depth="{{../level}}">

0 commit comments

Comments
 (0)