Merge pull request #1106 from ae-utbm/navbar-keyboard-navigation

Refactor navbar css and use details instead of div for better semantics
This commit is contained in:
Bartuccio Antoine
2025-06-05 18:17:58 +02:00
committed by GitHub
3 changed files with 98 additions and 75 deletions
+19 -2
View File
@@ -124,10 +124,27 @@
{% block script %}
<script>
const menuItems = document.querySelectorAll(".navbar details[name='navbar'].menu");
const isMobile = () => {
return window.innerWidth >= 500;
}
for (const item of menuItems){
item.addEventListener("mouseover", () => {
if (isMobile()){
item.setAttribute("open", "");
}
})
item.addEventListener("mouseout", () => {
if (isMobile()){
item.removeAttribute("open");
}
})
}
function showMenu() {
let navbar = document.getElementById("navbar-content");
const current = navbar.style.getPropertyValue("display");
navbar.style.setProperty("display", current === "none" ? "block" : "none");
const current = navbar.getAttribute("mobile-display");
navbar.setAttribute("mobile-display", current === "hidden" ? "revealed" : "hidden")
}
document.addEventListener("keydown", (e) => {