feat: add interactivity with script

This commit is contained in:
Ruidy 2024-12-31 09:50:17 +01:00
parent 7e01b7e81f
commit 628e4d955e
No known key found for this signature in database
GPG key ID: E00F51288CB857CC
5 changed files with 30 additions and 1 deletions

View file

@ -0,0 +1,5 @@
<div class="hamburger">
<span class="line"></span>
<span class="line"></span>
<span class="line"></span>
</div>

View file

@ -1,7 +1,9 @@
---
import Hamburger from "./Hamburger.astro";
import Navigation from "./Navigation.astro";
---
<header>
<Hamburger />
<Navigation />
</header>

View file

@ -19,5 +19,8 @@ const pageTitle = "Orbital Orbit"
<h1>{pageTitle}</h1>
<Footer/>
</body>
<script>
import "../scripts/menu.js"
</script>
</body>
</html>

3
src/scripts/menu.js Normal file
View file

@ -0,0 +1,3 @@
document.querySelector(".hamburger")?.addEventListener("click", () => {
document.querySelector(".nav-links")?.classList.toggle("expanded");
});

View file

@ -21,6 +21,18 @@ h1 {
}
/* nav styles */
.hamburger {
padding-right: 20px;
cursor: pointer;
}
.hamburger .line {
display: block;
width: 40px;
height: 5px;
margin-bottom: 10px;
background-color: #ff9776;
}
.nav-links {
width: 100%;
@ -63,4 +75,8 @@ h1 {
display: inline-block;
padding: 15px 20px;
}
.hamburger {
display: none;
}
}