Skip to content

Commit

Permalink
Use hamburger icon for menu
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonappah committed Jun 27, 2024
1 parent 03b42fa commit 980f68d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@astrojs/sitemap": "^3.1.6",
"@fontsource-variable/open-sans": "^5.0.29",
"@fontsource-variable/unbounded": "^5.0.20",
"@heroicons/react": "^2.1.4",
"@types/react": "^18.2.55",
"@types/react-dom": "^18.2.19",
"astro": "^4.11.0",
Expand Down
24 changes: 16 additions & 8 deletions src/components/navbar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {useEffect, useRef} from 'react'
import { Bars3Icon } from '@heroicons/react/24/solid'
import { useEffect, useRef } from 'react'
import { HOME_LINK, discordInvite, instagramURL, mainNavLinks } from '../data'
import useMedia from '../utils/useMediaQuery'

Expand All @@ -13,6 +14,11 @@ const styles = `
background: ${menuBg};
}
summary > svg {
width: 32px;
height: 32px;
}
summary {
list-style: none;
}
Expand All @@ -25,14 +31,14 @@ function Navbar() {
const detailsRef = useRef<HTMLDetailsElement>(null)
useEffect(() => {
const listener = () => {
if (!mobile || !detailsRef.current) {
return;
}
detailsRef.current.open = false;
if (!mobile || !detailsRef.current) {
return
}
document.addEventListener('astro:page-load', listener);
detailsRef.current.open = false
}
document.addEventListener('astro:page-load', listener)
return () => {
document.removeEventListener('astro:page-load', listener);
document.removeEventListener('astro:page-load', listener)
}
}, [detailsRef, mobile])
return (
Expand Down Expand Up @@ -102,7 +108,9 @@ function Navbar() {
? (
<details ref={detailsRef}>
{/* TODO: hamburger icon */}
<summary style={{ cursor: 'pointer' }}>Menu</summary>
<summary style={{ cursor: 'pointer' }}>
<Bars3Icon/>
</summary>
<NavLinks mobile={mobile} />
</details>
) : (
Expand Down

0 comments on commit 980f68d

Please sign in to comment.