Skip to content

Commit 8e1d4b2

Browse files
committed
Add support for nav without JS enabled
Page defaults to assuming JS is not available. When navigation JS loads it adds a JS class to <html>. Without that class, desktop dropdown is opened on hover or keyboard focus.
1 parent 261bb54 commit 8e1d4b2

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

‎css/main.scss‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,14 +343,25 @@ header {
343343
transform: translateY(-50%) scale(1);
344344
}
345345

346-
&.dropdown.open .dropdown-content {
346+
&.dropdown.open .dropdown-content,
347+
html:not(.js) &.dropdown:hover .dropdown-content,
348+
html:not(.js) &.dropdown:focus-within .dropdown-content {
347349
visibility: visible;
348350
opacity: 1;
349351
pointer-events: auto;
350352
transform: translateX(-50%) translateY(0);
351353
transition-delay: 0s;
352354
}
353355

356+
html:not(.js) &.dropdown .dropdown-content::before {
357+
position: absolute;
358+
right: 0;
359+
bottom: 100%;
360+
left: 0;
361+
height: 10px;
362+
content: "";
363+
}
364+
354365
.dropdown-content {
355366
position: absolute;
356367
top: calc(100% + 10px);

‎js/hamburger.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
document.documentElement.classList.add("js");
2+
13
document.addEventListener("DOMContentLoaded", () => {
24
const hamburger = document.getElementById("hamburger");
35
const menu = document.getElementById("hamburger-menu");

0 commit comments

Comments
 (0)