Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/Hamburger.astro
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
---

<div class="hamburger">
<button aria-expanded="false" aria-controls="main-menu" class="hamburger">
<span class="line"></span>
<span class="line"></span>
<span class="line"></span>
</div>
</button>
2 changes: 1 addition & 1 deletion src/components/Header.astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import ThemeIcon from "./ThemeIcon.astro";
---

<header>
<nav>
<nav aria-label="Main menu">
<Hamburger />
<ThemeIcon />
<Navigation />
Expand Down
2 changes: 1 addition & 1 deletion src/components/Navigation.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
---
<div class="nav-links">
<div id="main-menu" class="nav-links">
<a href="/">Home</a>
<a href="/about/">About</a>
<a href="/blog/">Blog</a>
Expand Down
7 changes: 5 additions & 2 deletions src/scripts/menu.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
document.querySelector('.hamburger').addEventListener('click', () => {
document.querySelector('.nav-links').classList.toggle('expanded');
const hamburger = document.querySelector('.hamburger')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@HiDeoo Did we still have opinions on this script? (will also have to be a casualty of the Great Hamburger Reckoning)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing we would also rename the variable to menu for consistency and that should be enough if I'm not forgetting anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I renamed it correctly


hamburger.addEventListener('click', () => {
const isExpanded = hamburger.getAttribute('aria-expanded') === 'true';
hamburger.setAttribute('aria-expanded', !isExpanded);
});
13 changes: 10 additions & 3 deletions src/styles/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ h1 {
/* nav styles */

.hamburger {
background: transparent;
display: block;
border: none;
padding-right: 20px;
cursor: pointer;
}
Expand All @@ -39,7 +42,6 @@ h1 {
width: 100%;
top: 5rem;
left: 48px;
background-color: #ff9776;
display: none;
margin: 0;
}
Expand All @@ -59,7 +61,7 @@ h1 {
background-color: #ff9776;
}

.expanded {
.hamburger[aria-expanded="true"] ~ .nav-links {
display: unset;
}

Expand Down Expand Up @@ -87,6 +89,11 @@ html.dark {
color: #fff;
}

.dark .nav-links a:hover,
.dark .nav-links a:focus {
color: #000;
}

.dark .nav-links a {
color: #fff;
}
}