'use client'; import { clsx } from 'clsx/lite'; import { usePathname } from 'next/navigation'; import Link from 'next/link'; import AppGrid from '../components/AppGrid'; import AppViewSwitcher, { SwitcherSelection } from '@/app/AppViewSwitcher'; import { PATH_ROOT, isPathAbout, isPathAdmin, isPathFull, isPathGrid, isPathProtected, isPathSignIn, } from '@/app/path'; import AnimateItems from '../components/AnimateItems'; import { GRID_HOMEPAGE_ENABLED, NAV_CAPTION, } from './config'; import { useRef } from 'react'; import useStickyNav from './useStickyNav'; import { useAppState } from '@/app/AppState'; const NAV_HEIGHT_CLASS = NAV_CAPTION ? 'min-h-[4rem] sm:min-h-[5rem]' : 'min-h-[4rem]'; export default function NavClient({ navTitle, navCaption, isInEmptyState, }: { navTitle: string navCaption?: string isInEmptyState: boolean }) { const ref = useRef(null); const pathname = usePathname(); const showNav = !isPathSignIn(pathname); const { hasLoadedWithAnimations, } = useAppState(); const { classNameStickyContainer, classNameStickyNav, isNavVisible, } = useStickyNav(ref, !isPathAdmin(pathname)); const renderLink = ( text: string, linkOrAction: string | (() => void), ) => typeof linkOrAction === 'string' ? {text} : ; const switcherSelectionForPath = (): SwitcherSelection | undefined => { if (pathname === PATH_ROOT) { return GRID_HOMEPAGE_ENABLED ? 'grid' : 'full'; } else if (isPathGrid(pathname)) { return 'grid'; } else if (isPathFull(pathname)) { return 'full'; } else if (isPathAbout(pathname)) { return 'about'; } else if (isPathProtected(pathname)) { return 'admin'; } }; return (
{renderLink(navTitle, PATH_ROOT)}
{navCaption &&
{navCaption}
}
] : []} /> } /> ); };