"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 {includes} from "lodash"; import {motion, AnimatePresence} from "framer-motion"; import {useEffect} from "react"; import {usePress} from "@react-aria/interactions"; import {useFocusRing} from "@react-aria/focus"; import {currentVersion} from "@/utils/version"; import {siteConfig} from "@/config/site"; import {Route} from "@/libs/docs/page"; import {LargeLogo, SmallLogo, ThemeSwitch} from "@/components"; import {TwitterIcon, GithubIcon, DiscordIcon, 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 {trackEvent} from "@/utils/va"; 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(); useEffect(() => { if (isMenuOpen) { setIsMenuOpen(false); } }, [pathname]); useEffect(() => { setCommandKey(isAppleDevice() ? "command" : "ctrl"); }, []); const handleOpenCmdk = () => { cmdkStore.onOpen(); trackEvent("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) => { trackEvent("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 {/* hide feedback and changelog at this moment */} {/* */} {/* handlePressNavbarItem("Introducing v2.2.0", "/blog/v2.2.0")} > Introducing v2.2.0  🚀 */}
handlePressNavbarItem("Github", "https://github.com/nextui-org/nextui")} > handlePressNavbarItem("New version v2.4.0", "/blog/v2.4.0")} > New version v2.4.0  🚀 handlePressNavbarItem("Twitter", siteConfig.links.twitter)} > handlePressNavbarItem("Discord", siteConfig.links.discord)} > handlePressNavbarItem("Github", siteConfig.links.github)} > {searchButton} {/* */} {children} ); };