File tree Expand file tree Collapse file tree 3 files changed +31
-3
lines changed Expand file tree Collapse file tree 3 files changed +31
-3
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import MobileNav from "../navigation/MobileNav.astro";
5
5
import type { NavLink } from " ../navigation/NavLink" ;
6
6
7
7
import List from " phosphor-astro/List.astro"
8
+ import ToggleMobileNav from " ../navigation/ToggleMobileNav.astro" ;
8
9
9
10
const navigationLinks: NavLink [] = [
10
11
{
@@ -34,7 +35,7 @@ const navigationLinks: NavLink[] = [
34
35
<!-- Navbar -->
35
36
<DesktopNav links ={ navigationLinks } />
36
37
<MobileNav links ={ navigationLinks } />
37
- <button class = " block md:hidden " onclick = " toggleNavigation () " >< List class = " w-8 " /></ button >
38
+ <ToggleMobileNav / >
38
39
</Fragment >
39
40
</Container >
40
41
</header >
Original file line number Diff line number Diff line change @@ -4,8 +4,13 @@ import type { NavigationProps } from "./NavLink";
4
4
const { links } = Astro .props as NavigationProps ;
5
5
---
6
6
7
- <nav class =" absolute top-16 left-0 w-screen py-4 overflow-hidden bg-accent-950 block md:hidden" >
8
- <ul class =" flex flex-col justify-center items-center h-full list-none gap-3" >
7
+ <nav
8
+ id =" mobile-navigation"
9
+ class =" absolute top-16 left-0 w-screen max-h-0 overflow-hidden bg-accent-950 block md:hidden transition-[max-height] duration-300"
10
+ >
11
+ <ul
12
+ class =" flex flex-col justify-center items-center h-full list-none gap-3 py-4"
13
+ >
9
14
{
10
15
links .map (({ url , label }) => (
11
16
<li class = " hover:text-accent-500" >
Original file line number Diff line number Diff line change
1
+ ---
2
+ import List from " phosphor-astro/List.astro" ;
3
+ ---
4
+
5
+ <button id =" mobile-toggle-btn" class =" block md:hidden"
6
+ ><List class =" w-8" /></button
7
+ >
8
+
9
+ <script >
10
+ document.addEventListener("DOMContentLoaded", () => {
11
+ const button = document.getElementById("mobile-toggle-btn")!;
12
+ const navigation = document.getElementById("mobile-navigation")!;
13
+
14
+ button.addEventListener("click", () => {
15
+ if (navigation.classList.contains("max-h-0")) {
16
+ navigation.classList.replace("max-h-0", "max-h-[100px]");
17
+ } else {
18
+ navigation.classList.replace("max-h-[100px]", "max-h-0");
19
+ }
20
+ });
21
+ });
22
+ </script >
You can’t perform that action at this time.
0 commit comments