"use client"; import {useRef, useState, FC, ReactNode, Key} from "react"; import { link, Navbar as NextUINavbar, NavbarContent, NavbarMenu, NavbarMenuToggle, NavbarBrand, NavbarItem, Link, Button, Kbd, Dropdown, DropdownMenu, DropdownItem, DropdownTrigger, Chip, } from "@nextui-org/react"; import {dataFocusVisibleClasses} from "@nextui-org/theme"; import {ChevronDownIcon, LinkIcon} from "@nextui-org/shared-icons"; import {isAppleDevice} from "@react-aria/utils"; import {clsx} from "@nextui-org/shared-utils"; import NextLink from "next/link"; import {usePathname} from "next/navigation"; import {motion, AnimatePresence} from "framer-motion"; import {useEffect} from "react"; import {usePress} from "@react-aria/interactions"; import {useFocusRing} from "@react-aria/focus"; import {usePostHog} from "posthog-js/react"; import {currentVersion} from "@/utils/version"; import {siteConfig} from "@/config/site"; import {Route} from "@/libs/docs/page"; import {LargeLogo, SmallLogo, ThemeSwitch} from "@/components"; import {GithubIcon, SearchLinearIcon} from "@/components/icons"; import {useIsMounted} from "@/hooks/use-is-mounted"; import {DocsSidebar} from "@/components/docs/sidebar"; import {useCmdkStore} from "@/components/cmdk"; import {FbRoadmapLink} from "@/components/featurebase/fb-roadmap-link"; import githubInfo from "@/config/github-info.json"; export interface NavbarProps { routes: Route[]; mobileRoutes?: Route[]; tag?: string; slug?: string; children?: ReactNode; } export const Navbar: FC = ({children, routes, mobileRoutes = [], slug, tag}) => { const [isMenuOpen, setIsMenuOpen] = useState(false); const [commandKey, setCommandKey] = useState<"ctrl" | "command">("command"); const ref = useRef(null); const isMounted = useIsMounted(); const pathname = usePathname(); const cmdkStore = useCmdkStore(); const posthog = usePostHog(); useEffect(() => { if (isMenuOpen) { setIsMenuOpen(false); } }, [pathname]); useEffect(() => { setCommandKey(isAppleDevice() ? "command" : "ctrl"); }, []); const handleOpenCmdk = () => { cmdkStore.onOpen(); posthog.capture("Navbar - Search", { name: "navbar - search", action: "press", category: "cmdk", }); }; const {pressProps} = usePress({ onPress: handleOpenCmdk, }); const {focusProps, isFocusVisible} = useFocusRing(); const docsPaths = [ "/docs/guide/introduction", "/docs/guide/installation", "/docs/guide/upgrade-to-v2", ]; const searchButton = ( ); if (pathname.includes("/examples")) { return null; } const navLinkClasses = clsx(link({color: "foreground"}), "data-[active=true]:text-primary"); const handleVersionChange = (key: Key) => { if (key === "v1") { const newWindow = window.open("https://v1.nextui.org", "_blank", "noopener,noreferrer"); if (newWindow) newWindow.opener = null; } }; const handlePressNavbarItem = (name: string, url: string) => { posthog.capture("NavbarItem", { name, action: "press", category: "navbar", data: url, }); }; return ( handlePressNavbarItem("Home", "/")} > {ref.current ? ( {isMounted && ( )} v{currentVersion} }> v1.0.0 ) : (
)}
    handlePressNavbarItem("Docs", "/docs/guide/introduction")} > Docs handlePressNavbarItem("Components", "/docs/components/accordion")} > Components handlePressNavbarItem("Blog", "/blog")} > Blog handlePressNavbarItem("Figma", "/figma")} > Figma
handlePressNavbarItem("Github", siteConfig.links.github)} > handlePressNavbarItem("New version v2.4.0", "/blog/v2.4.0")} > New version v2.4.0  🚀 {searchButton} handlePressNavbarItem("Github", siteConfig.links.github)} > {githubInfo.stars.formatted} {/* */} {children} ); };