'use client' import { Fragment, useEffect, useRef, useState } from 'react' import Link from 'next/link' import { usePathname } from 'next/navigation' import { useTheme } from 'next-themes' import { Popover, Transition } from '@headlessui/react' import clsx from 'clsx' import { Container } from '@/components/Container' function CloseIcon(props: React.ComponentPropsWithoutRef<'svg'>) { return ( ) } function ChevronDownIcon(props: React.ComponentPropsWithoutRef<'svg'>) { return ( ) } function SunIcon(props: React.ComponentPropsWithoutRef<'svg'>) { return ( ) } function MoonIcon(props: React.ComponentPropsWithoutRef<'svg'>) { return ( ) } function MobileNavItem({ href, children, }: { href: string children: React.ReactNode }) { return (
  • {children}
  • ) } function MobileNavigation( props: React.ComponentPropsWithoutRef, ) { return ( Menu

    Navigation

    ) } function NavItem({ href, children, }: { href: string children: React.ReactNode }) { let isActive = usePathname() === href return (
  • {children} {isActive && ( // Can use this for an active state later if wanted )}
  • ) } function DesktopNavigation(props: React.ComponentPropsWithoutRef<'nav'>) { return ( ) } function ThemeToggle() { let { resolvedTheme, setTheme } = useTheme() let otherTheme = resolvedTheme === 'dark' ? 'light' : 'dark' let [mounted, setMounted] = useState(false) useEffect(() => { setMounted(true) }, []) return ( ) } function clamp(number: number, a: number, b: number) { let min = Math.min(a, b) let max = Math.max(a, b) return Math.min(Math.max(number, min), max) } export function Header() { let isHomePage = usePathname() === '/' let headerRef = useRef>(null) let avatarRef = useRef>(null) let isInitial = useRef(true) useEffect(() => { let downDelay = avatarRef.current?.offsetTop ?? 0 let upDelay = 64 function setProperty(property: string, value: string) { document.documentElement.style.setProperty(property, value) } function removeProperty(property: string) { document.documentElement.style.removeProperty(property) } function updateHeaderStyles() { if (!headerRef.current) { return } let { top, height } = headerRef.current.getBoundingClientRect() let scrollY = clamp( window.scrollY, 0, document.body.scrollHeight - window.innerHeight, ) if (isInitial.current) { setProperty('--header-position', 'sticky') } setProperty('--content-offset', `${downDelay}px`) if (isInitial.current || scrollY < downDelay) { setProperty('--header-height', `${downDelay + height}px`) setProperty('--header-mb', `${-downDelay}px`) } else if (top + height < -upDelay) { let offset = Math.max(height, scrollY - upDelay) setProperty('--header-height', `${offset}px`) setProperty('--header-mb', `${height - offset}px`) } else if (top === 0) { setProperty('--header-height', `${scrollY + height}px`) setProperty('--header-mb', `${-scrollY}px`) } if (top === 0 && scrollY > 0 && scrollY >= downDelay) { setProperty('--header-inner-position', 'fixed') removeProperty('--header-top') removeProperty('--avatar-top') } else { removeProperty('--header-inner-position') setProperty('--header-top', '0px') setProperty('--avatar-top', '0px') } } function updateStyles() { updateHeaderStyles() isInitial.current = false } updateStyles() window.addEventListener('scroll', updateStyles, { passive: true }) window.addEventListener('resize', updateStyles) return () => { window.removeEventListener('scroll', updateStyles) window.removeEventListener('resize', updateStyles) } }, [isHomePage]) return ( <>
    {isHomePage && ( <> )}
    nate.⚰️
    {isHomePage && (
    )} ) }