"use client"; import { Menu, Sun, X } from "lucide-react"; import Link from "next/link"; import { Fragment, createContext, useContext, useEffect, useState, } from "react"; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, } from "@/components/ui/accordion"; import { AnimatePresence, FadeIn } from "@/components/ui/fade-in"; import { contents, examples } from "./sidebar-content"; import { MobileThemeToggle, ThemeToggle } from "./theme-toggler"; import { usePathname } from "next/navigation"; interface NavbarMobileContextProps { isOpen: boolean; toggleNavbar: () => void; isDocsOpen: boolean; toggleDocsNavbar: () => void; } const NavbarContext = createContext( undefined, ); export const NavbarProvider = ({ children }: { children: React.ReactNode }) => { const [isOpen, setIsOpen] = useState(false); const [isDocsOpen, setIsDocsOpen] = useState(false); const toggleNavbar = () => { setIsOpen((prevIsOpen) => !prevIsOpen); }; const toggleDocsNavbar = () => { setIsDocsOpen((prevIsOpen) => !prevIsOpen); }; // @ts-ignore return ( {children} ); }; export const useNavbarMobile = (): NavbarMobileContextProps => { const context = useContext(NavbarContext); if (!context) { throw new Error( "useNavbarMobile must be used within a NavbarMobileProvider", ); } return context; }; export const NavbarMobileBtn: React.FC = () => { const { toggleNavbar } = useNavbarMobile(); return (
); }; export const NavbarMobile = () => { const { isOpen, toggleNavbar } = useNavbarMobile(); return (
{isOpen && ( {navMenu.map((menu, i) => ( {menu.child ? ( {menu.name} {menu.child.map((child, j) => ( {child.name} ))} ) : ( {menu.name} )} ))} )}
); }; export const DocsNavbarMobileBtn: React.FC = () => { const { toggleDocsNavbar: toggleNavbar } = useNavbarMobile(); return ( ); }; export const DocsNavBarMobile = () => { const { isDocsOpen: isOpen, toggleDocsNavbar: toggleNavbar } = useNavbarMobile(); const pathname = usePathname(); const content = pathname.startsWith("/docs/examples") ? examples : contents; return ( {isOpen && ( {content.map((menu, i) => (
{!!menu.Icon && } {menu.title}
{menu.list.map((child, j) => ( {child.group ? (

{child.title}

) : (
{child.title}
)} ))} ))} )} ); }; export const navMenu: { name: string; path: string; child?: { name: string; path: string; }[]; }[] = [ { name: "_helo", path: "/", }, { name: "docs", path: "/docs", }, { name: "examples", path: "/docs/examples/next-js", }, { name: "changelogs", path: "/changelogs", }, { name: "community", path: "/community", }, ]; export const DocsNavbarMobileTitle = () => { const pathname = usePathname(); if (pathname.startsWith("/docs/examples")) { return

Examples

; } else { return

Docs

; } };