Skip to content

Commit

Permalink
Fix layout shift caused by nav on index page
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewStanciu committed Dec 7, 2023
1 parent e595165 commit 1103bb0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions components/nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ const Nav = ({ noSticky = false }: { noSticky?: boolean }) => {
<nav
className={
noSticky
? `w-full top-0 z-10 bg-gray-100 dark:bg-gray-800`
: `w-full top-0 z-10 bg-gray-nav dark:bg-gray-nav-dark backdrop-blur fixed`
? `w-full top-0 z-10 bg-gray-100 dark:bg-gray-800 h-14`
: `w-full top-0 z-10 bg-gray-nav dark:bg-gray-nav-dark backdrop-blur fixed h-14`
}
>
<div className="container px-4 sm:px-14 mx-auto flex">
{pathname !== '/' && <BackButton />}
<div className="grow" />
{resolvedTheme && <ThemeButton />}
{/* {resolvedTheme && <ThemeButton />} */}
<ThemeButton />
</div>
</nav>
)
Expand Down
6 changes: 3 additions & 3 deletions components/theme-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { useEffect, useState } from 'react'
import { Moon, Sun } from 'react-feather'

const ThemeButton = () => {
const [mounted, setMounted] = useState(false)
// const [mounted, setMounted] = useState(false)
const { setTheme, resolvedTheme } = useTheme()

useEffect(() => setMounted(true), [])
// useEffect(() => setMounted(true), [])

if (!mounted) return null
// if (!mounted) return null

return (
<button
Expand Down

0 comments on commit 1103bb0

Please sign in to comment.