Skip to content

Commit

Permalink
navbar adjustments for mobile view
Browse files Browse the repository at this point in the history
  • Loading branch information
hsmith-dev committed Aug 25, 2024
1 parent fe8b80c commit 36eea19
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/components/Header.astro
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@ const isHomePage = Astro.props.isHomePage ?? false; // Default to false
</header>

<style>
.dropdown-content {
display: none;
}

.dropdown-content.open {
display: block;
}

@media (min-width: 1024px) {
.dropdown:hover .dropdown-content {
display: block;
}
}

.sun { fill: black; }
.moon { fill: transparent; }

Expand Down Expand Up @@ -89,6 +103,7 @@ const isHomePage = Astro.props.isHomePage ?? false; // Default to false
const menuButton = document.getElementById('menu-button');
const menuLinks = document.querySelector('.menu-links');
const dropdowns = document.querySelectorAll('.dropdown');

const closeDropdowns = () => {
dropdowns.forEach(dropdown => {
const dropdownContent = dropdown.querySelector('.dropdown-content');
Expand Down Expand Up @@ -131,6 +146,8 @@ const isHomePage = Astro.props.isHomePage ?? false; // Default to false

if (!isOpen) {
dropdownContent.classList.add('open'); // Then open the clicked one
} else {
dropdownContent.classList.remove('open'); // Close if already open
}
}
});
Expand Down

0 comments on commit 36eea19

Please sign in to comment.