Skip to content

Commit

Permalink
Slightly scuffed implementation of mobile navbar
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonappah committed Jun 27, 2024
1 parent 46d741f commit 9b072b3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/layouts/base.astro
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import '../styles/reset.css'
import '../styles/index.css'
import '../styles/App.css'
import Navbar from '../components/navbar.astro'
import Navbar from '../components/navbar'
import Footer from '../components/footer.astro'
interface Props {
Expand Down Expand Up @@ -41,7 +41,7 @@ import { ViewTransitions } from 'astro:transitions';
/>
<ViewTransitions />
</head>
<Navbar />
<Navbar client:load transition:persist />
<main>
<slot />
<Footer />
Expand Down
16 changes: 16 additions & 0 deletions src/utils/useMediaQuery.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { useEffect, useState } from 'react'

function useMedia(query: string) {
const [matches, setMatches] = useState(false)
useEffect(() => {
const media = window.matchMedia(query)
const listener = () => setMatches(media.matches)
listener()
media.addEventListener('change', listener)

return () => media.removeEventListener('change', listener)
}, [matches, query])
return matches
};

export default useMedia

0 comments on commit 9b072b3

Please sign in to comment.