Skip to content

Commit 9378b95

Browse files
000-779: extra level navi
1 parent 5146798 commit 9378b95

File tree

1 file changed

+55
-5
lines changed

1 file changed

+55
-5
lines changed

_includes/header.html

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,42 @@
1010
<span aria-hidden="true"></span>
1111
</a>
1212
</div>
13-
<div class="navbar-menu" id="navMenu" :class="{ 'is-active': openNav }">
13+
<div class="navbar-menu" id="navMenu">
1414
<div class="navbar-start">
1515
{% if site.data.navigation %}
1616
{% for item in site.data.navigation %}
1717
{% if item.dropdown %}
18-
<div class="navbar-item has-dropdown is-hoverable {% if site.fixed_navbar == 'bottom' %} has-dropdown-up {% endif %}">
19-
<a href="{{ item.link | relative_url }}" class="navbar-link {% if page.url contains item.link %}is-active{% endif %}">{{ item.name }}</a>
18+
<!-- First-level dropdown (open on click) -->
19+
<div class="navbar-item has-dropdown">
20+
<a href="{{ item.link | relative_url }}" class="navbar-link {% if page.url contains item.link %}is-active{% endif %}" onclick="toggleDropdown(event)">
21+
{{ item.name }}
22+
</a>
2023
<div class="navbar-dropdown">
2124
{% for subitem in item.dropdown %}
22-
<a href="{{ subitem.link | relative_url }}" class="navbar-item {% if subitem.link == page.url %}is-active{% endif %}">{{ subitem.name }}</a>
25+
{% if subitem.dropdown %}
26+
<!-- Second-level dropdown (hoverable) -->
27+
<div class="navbar-item has-dropdown is-hoverable">
28+
<a href="{{ subitem.link | relative_url }}" class="navbar-link">{{ subitem.name }}</a>
29+
<div class="navbar-dropdown">
30+
{% for subsubitem in subitem.dropdown %}
31+
<a href="{{ subsubitem.link | relative_url }}" class="navbar-item">{{ subsubitem.name }}</a>
32+
{% endfor %}
33+
</div>
34+
</div>
35+
{% else %}
36+
<a href="{{ subitem.link | relative_url }}" class="navbar-item {% if subitem.link == page.url %}is-active{% endif %}">{{ subitem.name }}</a>
37+
{% endif %}
2338
{% endfor %}
2439
</div>
2540
</div>
2641
{% else %}
42+
<!-- Non-dropdown first-level link -->
2743
<a href="{{ item.link | relative_url }}" class="navbar-item {% if item.link == page.url %}is-active{% endif %}">{{ item.name }}</a>
2844
{% endif %}
2945
{% endfor %}
3046
{% endif %}
3147
</div>
48+
3249
<div class="navbar-end">
3350
<a href=""><img src="../../../../flag.png"/></a>
3451
<a class="navbar-item" href="#">
@@ -39,4 +56,37 @@
3956

4057
</div>
4158
</div>
42-
</nav>
59+
</nav>
60+
61+
<script>
62+
function toggleDropdown(event) {
63+
event.preventDefault();
64+
65+
// Find the parent dropdown container
66+
const parentItem = event.target.closest('.has-dropdown');
67+
68+
// Toggle the active state
69+
if (parentItem.classList.contains('is-active')) {
70+
parentItem.classList.remove('is-active');
71+
} else {
72+
// Close all other dropdowns
73+
document.querySelectorAll('.navbar-item.has-dropdown.is-active').forEach(item => {
74+
item.classList.remove('is-active');
75+
});
76+
77+
// Open the clicked dropdown
78+
parentItem.classList.add('is-active');
79+
}
80+
}
81+
82+
// Close dropdowns when clicking outside
83+
document.addEventListener('click', function (event) {
84+
const target = event.target;
85+
if (!target.closest('.has-dropdown')) {
86+
document.querySelectorAll('.navbar-item.has-dropdown.is-active').forEach(item => {
87+
item.classList.remove('is-active');
88+
});
89+
}
90+
});
91+
</script>
92+

0 commit comments

Comments
 (0)