"use client"; import type { LucideIcon } from "lucide-react"; import { Bell, Book, ChevronRight, FileText, Globe, Grid, HelpCircle, Info, Menu, X, } from "lucide-react"; import { Fragment, useEffect, useState } from "react"; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, } from "@/components/ui/accordion"; import { Button } from "@/components/ui/button"; import { NavigationMenu, NavigationMenuContent, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, navigationMenuTriggerStyle, } from "@/components/ui/navigation-menu"; import { Sheet, SheetContent, SheetTitle } from "@/components/ui/sheet"; import { cn } from "@/lib/utils"; interface MenuLink { label: string; description?: string; url?: string; icon?: { component: LucideIcon; color: string; }; } interface MenuItem { title: string; url?: string; links?: MenuLink[]; } interface DesktopMenuItemProps { item: MenuItem; index: number; } interface MobileNavigationMenuProps { open: boolean; } interface MenuSubLinkProps { link: MenuLink; } const LOGO = { url: "https://www.ShadcnBlocks", src: "/block-media/shadcnblocks/block/block-1.svg", alt: "لوگو", title: "موج‌مارکت", }; const NAVIGATION: MenuItem[] = [ { title: "محصولات", links: [ { label: "وبلاگ", description: "بینش بازاریابی و به‌روزرسانی محصول", url: "#", icon: { component: FileText, color: "#10b981", }, }, { label: "پلتفرم ما", description: "کمپین، سگمنت و لید را در یک جا مدیریت کنید", url: "#", icon: { component: Grid, color: "#6366f1", }, }, ], }, { title: "شرکت", links: [ { label: "درباره ما", url: "#", description: "مأموریت ما رشد تقاضا با داده شفاف است", icon: { component: Info, color: "#f59e0b", }, }, { label: "مرکز راهنما", url: "#", description: "راهنمای راه‌اندازی و پشتیبانی سریع", icon: { component: HelpCircle, color: "#3b82f6", }, }, { label: "آخرین اخبار", url: "#", description: "به‌روزرسانی‌های محصول", icon: { component: Bell, color: "#f97316", }, }, ], }, { title: "منابع", links: [ { label: "مستندات", url: "#", description: "راهنماها و مراجع API", icon: { component: Book, color: "#8b5cf6", }, }, { label: "مرجع API", url: "#", description: "کاوش endpointهای موج‌مارکت", icon: { component: Globe, color: "#ef4444", }, }, ], }, { title: "قیمت‌گذاری", url: "#", }, { title: "تماس", url: "#", }, ]; const PRIMARY_BUTTON = { label: "شروع رایگان", url: "#", }; const MOBILE_BREAKPOINT = 1024; interface Navbar9Props { className?: string; } const Navbar9 = ({ className }: Navbar9Props) => { const [open, setOpen] = useState(false); useEffect(() => { const handleResize = () => { if (window.innerWidth > MOBILE_BREAKPOINT) { setOpen(false); } }; handleResize(); window.addEventListener("resize", handleResize); return () => { window.removeEventListener("resize", handleResize); }; }, []); useEffect(() => { document.body.style.overflow = open ? "hidden" : "auto"; }, [open]); const handleMobileMenu = () => { const nextOpen = !open; setOpen(nextOpen); }; return (
{LOGO.alt} {LOGO.title} {NAVIGATION.map((item, index) => ( ))}
); }; const DesktopMenuItem = ({ item, index }: DesktopMenuItemProps) => { if (item.links) { return ( {item.title}
    {item.links.map((link, index) => (
  • ))}
); } return ( {item.title} ); }; const MenuSubLink = ({ link }: MenuSubLinkProps) => { return (
{link.icon && ( )}

{link.label}

{link.description}

); }; const MobileNavigationMenu = ({ open }: MobileNavigationMenuProps) => { return (
منوی موبایل
{NAVIGATION.map((item, index) => renderMobileMenuItem(item, index), )}
); }; const renderMobileMenuItem = (item: MenuItem, index: number) => { if (item.links) { return ( {item.title} {item.links.map((subItem) => ( ))} ); } return ( {item.title} ); }; interface GithubStarsProps { repoUrl: string; } const GithubStars = ({ repoUrl }: GithubStarsProps) => { const [stargazersCount, setStargazersCount] = useState(""); const [owner, repo] = repoUrl.split("github.com/")[1].split("/"); const githubApiEndpoint = `https://api.github.com/repos/${owner}/${repo}`; const formatStargazers = (count: number | ""): string => { if (count === "") return ""; if (count < 1000) return count.toString(); return `${Math.round(count / 1000)}k`; }; useEffect(() => { const getStars = async () => { try { const response = await fetch(githubApiEndpoint); const json = await response.json(); const formattedCount = formatStargazers(json.stargazers_count); setStargazersCount(formattedCount); } catch (error: unknown) { if (error instanceof Error) { console.error(error.message); } } }; getStars(); }, [githubApiEndpoint]); return ( ); }; export { Navbar9 };