Skip to content

Commit 0163d42

Browse files
000-712: navigation
1 parent 655569e commit 0163d42

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

_includes/header.html

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
<div class="navbar-item has-dropdown is-hoverable {% if site.fixed_navbar == 'bottom' %} has-dropdown-up {% endif %}">
1919
<a href="{{ item.link | relative_url }}" class="navbar-link {% if page.url contains item.link %}is-active{% endif %}">
2020
{{ item.name }}
21-
{% if item.dropdown %}<span class="icon is-small"><i class="fas fa-angle-down"></i></span>{% endif %}
21+
<span class="icon is-small"><i class="fas fa-angle-down"></i></span>
2222
</a>
2323
<div class="navbar-dropdown">
2424
{% for subitem in item.dropdown %}
2525
{% if subitem.dropdown %}
2626
<div class="navbar-item has-dropdown is-hoverable">
2727
<a href="{{ subitem.link | relative_url }}" class="navbar-link {% if page.url contains subitem.link %}is-active{% endif %}">
2828
{{ subitem.name }}
29-
{% if subitem.dropdown %}<span class="icon is-small"><i class="fas fa-angle-right"></i></span>{% endif %}
29+
<span class="icon is-small"><i class="fas fa-angle-right"></i></span>
3030
</a>
3131
<div class="navbar-dropdown">
3232
{% for subsubitem in subitem.dropdown %}
@@ -55,3 +55,32 @@
5555
</div>
5656
</div>
5757
</nav>
58+
59+
<!-- Add this JavaScript to handle the dropdown toggle behavior -->
60+
<script>
61+
document.addEventListener('DOMContentLoaded', () => {
62+
// Dropdowns
63+
const dropdowns = document.querySelectorAll('.navbar-item.has-dropdown');
64+
65+
dropdowns.forEach(dropdown => {
66+
const link = dropdown.querySelector('.navbar-link');
67+
const dropdownMenu = dropdown.querySelector('.navbar-dropdown');
68+
69+
// Add event listener for click or hover
70+
link.addEventListener('click', (event) => {
71+
event.preventDefault(); // Prevent default link behavior
72+
dropdownMenu.classList.toggle('is-active');
73+
dropdown.classList.toggle('is-active');
74+
});
75+
76+
// Optional: Add hover behavior for desktop
77+
dropdown.addEventListener('mouseenter', () => {
78+
dropdownMenu.classList.add('is-active');
79+
});
80+
81+
dropdown.addEventListener('mouseleave', () => {
82+
dropdownMenu.classList.remove('is-active');
83+
});
84+
});
85+
});
86+
</script>

0 commit comments

Comments
 (0)