import type { FC, ReactNode } from "react"; import { useState } from "react"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faMagnifyingGlass } from "@fortawesome/pro-duotone-svg-icons"; const SearchLg: FC<{ className?: string }> = ({ className }) => ; import { AnimatePresence, motion } from "motion/react"; import { Input } from "@/components/base/input/input"; import { UntitledLogo } from "@/components/foundations/logo/untitledui-logo"; import { cx } from "@/utils/cx"; import { MobileNavigationHeader } from "../base-components/mobile-header"; import { NavAccountCard } from "../base-components/nav-account-card"; import { NavItemBase } from "../base-components/nav-item"; import { NavList } from "../base-components/nav-list"; import type { NavItemType } from "../config"; interface SidebarNavigationDualTierProps { /** URL of the currently active item. */ activeUrl?: string; /** Feature card to display. */ featureCard?: ReactNode; /** List of items to display. */ items: NavItemType[]; /** List of footer items to display. */ footerItems?: NavItemType[]; /** Whether to hide the right side border. */ hideBorder?: boolean; } export const SidebarNavigationDualTier = ({ activeUrl, hideBorder, items, footerItems = [], featureCard }: SidebarNavigationDualTierProps) => { const activeItem = [...items, ...footerItems].find((item) => item.href === activeUrl || item.items?.some((subItem) => subItem.href === activeUrl)); const [currentItem, setCurrentItem] = useState(activeItem || items[1]); const [isHovering, setIsHovering] = useState(false); const isSecondarySidebarVisible = isHovering && Boolean(currentItem.items?.length); const MAIN_SIDEBAR_WIDTH = 296; const SECONDARY_SIDEBAR_WIDTH = 256; const mainSidebar = ( ); const secondarySidebar = ( {isSecondarySidebarVisible && (
    {currentItem.items?.map((item) => (
  • {item.label}
  • ))}
)}
); return ( <> {/* Mobile header navigation */} {mainSidebar} {/* Desktop sidebar navigation */}
setIsHovering(true)} onPointerLeave={() => setIsHovering(false)} > {mainSidebar} {secondarySidebar}
{/* Placeholder to take up physical space because the real sidebar has `fixed` position. */}
); };