"use client"; import { Menu, X } from "lucide-react"; import Link from "next/link"; import { Fragment, createContext, useContext, useState } from "react"; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, } from "@/components/ui/accordion"; import { AnimatePresence, FadeIn } from "@/components/ui/fade-in"; import { contents } from "./sidebar-content"; 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(); return ( {isOpen && ( {contents.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: "_changelogs", path: "/changelogs", }, { name: "_community", path: "https://discord.gg/GYC3W7tZzb", }, ];