Initial import of 1407 block sources under blocks/
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,577 @@
|
||||
"use client";
|
||||
import type { LucideIcon } from "lucide-react";
|
||||
import {
|
||||
Book,
|
||||
Cloud,
|
||||
Code,
|
||||
Database,
|
||||
Gift,
|
||||
Globe,
|
||||
Heart,
|
||||
Layout,
|
||||
MenuIcon,
|
||||
Monitor,
|
||||
Paintbrush,
|
||||
Server,
|
||||
Settings,
|
||||
Shield,
|
||||
ShoppingCart,
|
||||
Smartphone,
|
||||
Sparkles,
|
||||
Terminal,
|
||||
Users,
|
||||
X,
|
||||
Zap,
|
||||
} 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: LucideIcon;
|
||||
}
|
||||
|
||||
interface MenuGroup {
|
||||
title: string;
|
||||
links: MenuLink[];
|
||||
}
|
||||
|
||||
interface MenuItem {
|
||||
title: string;
|
||||
url?: string;
|
||||
groups?: MenuGroup[];
|
||||
}
|
||||
|
||||
interface DesktopMenuItemProps {
|
||||
item: MenuItem;
|
||||
index: number;
|
||||
}
|
||||
|
||||
interface MobileNavigationMenuProps {
|
||||
open: boolean;
|
||||
}
|
||||
|
||||
const LOGO = {
|
||||
url: "https://www.ShadcnBlocks",
|
||||
src: "/block-media/shadcnblocks/block/block-1.svg",
|
||||
alt: "لوگو",
|
||||
title: "شادسیانبلاکز",
|
||||
};
|
||||
|
||||
const NAVIGATION: MenuItem[] = [
|
||||
{
|
||||
title: "محصولات",
|
||||
groups: [
|
||||
{
|
||||
title: "وبلاگ شرکت",
|
||||
links: [
|
||||
{
|
||||
label: "بینشها",
|
||||
icon: Book,
|
||||
description: "اخبار و بهروزرسانیهای شرکت",
|
||||
url: "#",
|
||||
},
|
||||
{
|
||||
label: "مهندسی",
|
||||
icon: Code,
|
||||
description: "مطالب فنی عمیق",
|
||||
url: "#",
|
||||
},
|
||||
{
|
||||
label: "فرهنگ",
|
||||
icon: Users,
|
||||
description: "ارزشها، تجربهها و اهداف تیم",
|
||||
url: "#",
|
||||
},
|
||||
{
|
||||
label: "مطبوعات",
|
||||
icon: Globe,
|
||||
description: "بازتاب در رسانهها",
|
||||
url: "#",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title: "ابزارهای توسعه",
|
||||
links: [
|
||||
{
|
||||
label: "API",
|
||||
icon: Monitor,
|
||||
description: "دسترسی به REST اتصال هوشمند",
|
||||
url: "#",
|
||||
},
|
||||
{
|
||||
label: "CLI",
|
||||
icon: Terminal,
|
||||
description: "ابزارهای خط فرمان",
|
||||
url: "#",
|
||||
},
|
||||
{
|
||||
label: "SDKها",
|
||||
icon: Code,
|
||||
description: "یکپارچهسازی با SDKها",
|
||||
url: "#",
|
||||
},
|
||||
{
|
||||
label: "مستندات",
|
||||
icon: Book,
|
||||
description: "مستندات کامل",
|
||||
url: "#",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title: "تجارت",
|
||||
links: [
|
||||
{
|
||||
label: "فروشگاه",
|
||||
icon: ShoppingCart,
|
||||
description: "خرید محصولات ما",
|
||||
url: "#",
|
||||
},
|
||||
{
|
||||
label: "طرحها",
|
||||
icon: Database,
|
||||
description: "گزینههای اشتراک",
|
||||
url: "#",
|
||||
},
|
||||
{
|
||||
label: "اپ موبایل",
|
||||
icon: Smartphone,
|
||||
description: "خرید در هر مکان",
|
||||
url: "#",
|
||||
},
|
||||
{
|
||||
label: "کارت هدیه",
|
||||
icon: Gift,
|
||||
description: "ارسال فوری هدیه",
|
||||
url: "#",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title: "راهحلها",
|
||||
groups: [
|
||||
{
|
||||
title: "صنایع",
|
||||
links: [
|
||||
{
|
||||
label: "تجارت الکترونیک",
|
||||
icon: ShoppingCart,
|
||||
description: "راهحل برای فروشگاه آنلاین",
|
||||
url: "#",
|
||||
},
|
||||
{
|
||||
label: "SaaS",
|
||||
icon: Cloud,
|
||||
description: "ابزار برای اپلیکیشنهای سامانه ابری",
|
||||
url: "#",
|
||||
},
|
||||
{
|
||||
label: "مالی",
|
||||
icon: Shield,
|
||||
description: "اپلیکیشنهای مالی امن",
|
||||
url: "#",
|
||||
},
|
||||
{
|
||||
label: "سلامت",
|
||||
icon: Heart,
|
||||
description: "برای پلتفرمهای پزشکی",
|
||||
url: "#",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title: "سیستم طراحی",
|
||||
links: [
|
||||
{
|
||||
label: "بلاک",
|
||||
icon: Layout,
|
||||
description: "بخشهای رابط کاربری قابلاستفاده مجدد",
|
||||
url: "#",
|
||||
},
|
||||
{
|
||||
label: "توکنها",
|
||||
icon: Settings,
|
||||
description: "مرجع توکنهای طراحی",
|
||||
url: "#",
|
||||
},
|
||||
{
|
||||
label: "آیکونها",
|
||||
icon: Sparkles,
|
||||
description: "کتابخانه آیکون Lucide",
|
||||
url: "#",
|
||||
},
|
||||
{
|
||||
label: "تمها",
|
||||
icon: Paintbrush,
|
||||
description: "پیشتنظیم ظاهر رابط",
|
||||
url: "#",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title: "پلتفرم",
|
||||
groups: [
|
||||
{
|
||||
title: "خدمات اصلی",
|
||||
links: [
|
||||
{
|
||||
label: "میزبانی",
|
||||
icon: Server,
|
||||
description: "زیرساخت پایدار",
|
||||
url: "#",
|
||||
},
|
||||
{
|
||||
label: "احراز هویت",
|
||||
icon: Shield,
|
||||
description: "ورود امن و نقشها",
|
||||
url: "#",
|
||||
},
|
||||
{
|
||||
label: "پایگاه داده",
|
||||
icon: Database,
|
||||
description: "ذخیرهسازی مقیاسپذیر",
|
||||
url: "#",
|
||||
},
|
||||
{
|
||||
label: "توابع لبه",
|
||||
icon: Zap,
|
||||
description: "منطق با تأخیر کم",
|
||||
url: "#",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title: "منابع",
|
||||
url: "#",
|
||||
},
|
||||
{
|
||||
title: "قیمتگذاری",
|
||||
url: "#",
|
||||
},
|
||||
];
|
||||
|
||||
const DESKTOP_BUTTONS = [
|
||||
{
|
||||
label: "تماس",
|
||||
isPrimary: false,
|
||||
url: "#",
|
||||
},
|
||||
{
|
||||
label: "ورود",
|
||||
isPrimary: false,
|
||||
url: "#",
|
||||
},
|
||||
{
|
||||
label: "ثبتنام",
|
||||
isPrimary: true,
|
||||
url: "#",
|
||||
},
|
||||
];
|
||||
|
||||
const MOBILE_BUTTONS = [
|
||||
{
|
||||
label: "ثبتنام",
|
||||
isPrimary: true,
|
||||
url: "#",
|
||||
},
|
||||
{
|
||||
label: "ورود",
|
||||
isPrimary: false,
|
||||
url: "#",
|
||||
},
|
||||
];
|
||||
|
||||
const MOBILE_BREAKPOINT = 1024;
|
||||
|
||||
interface Navbar11Props {
|
||||
/** When true, positions inside block preview instead of the viewport. */
|
||||
contained?: boolean;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
const Navbar11 = ({ contained = false, className }: Navbar11Props) => {
|
||||
const [open, setOpen] = useState<boolean>(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 (
|
||||
<Fragment>
|
||||
<section
|
||||
lang="fa"
|
||||
className={cn(
|
||||
"pointer-events-auto z-999 flex h-16 w-full items-center justify-center bg-background text-start",
|
||||
contained ? "relative" : "fixed top-0",
|
||||
className,
|
||||
)}
|
||||
>
|
||||
<div className="container">
|
||||
<div className="flex items-center justify-between gap-8">
|
||||
<div className="flex items-center gap-8">
|
||||
<a
|
||||
href={LOGO.url}
|
||||
className="flex max-h-8 items-center gap-2 text-lg font-semibold tracking-tighter"
|
||||
>
|
||||
<img
|
||||
src={LOGO.src}
|
||||
alt={LOGO.alt}
|
||||
className="inline-block size-6"
|
||||
/>
|
||||
<span className="hidden md:inline-block">{LOGO.title}</span>
|
||||
</a>
|
||||
<NavigationMenu
|
||||
dir="rtl"
|
||||
className="relative z-50 hidden xl:flex"
|
||||
viewport={false}
|
||||
>
|
||||
<NavigationMenuList>
|
||||
{NAVIGATION.map((item, index) => (
|
||||
<DesktopMenuItem
|
||||
key={`desktop-link-${index}`}
|
||||
item={item}
|
||||
index={index}
|
||||
/>
|
||||
))}
|
||||
</NavigationMenuList>
|
||||
</NavigationMenu>
|
||||
</div>
|
||||
<div className="hidden items-center gap-3 xl:flex">
|
||||
{DESKTOP_BUTTONS.map((btn, index) => (
|
||||
<Button
|
||||
size="sm"
|
||||
variant={!btn.isPrimary ? "outline" : "default"}
|
||||
className={
|
||||
btn.isPrimary
|
||||
? "text-primary-foreground"
|
||||
: "text-foreground"
|
||||
}
|
||||
asChild
|
||||
key={`navbar-btn-${index}`}
|
||||
>
|
||||
<a href={btn.url}>{btn.label}</a>
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
<div className="xl:hidden">
|
||||
<Button
|
||||
className="size-11"
|
||||
variant="ghost"
|
||||
onClick={handleMobileMenu}
|
||||
aria-label={open ? "بستن منو" : "باز کردن منو"}
|
||||
>
|
||||
{open ? (
|
||||
<X className="size-5.5 stroke-foreground" />
|
||||
) : (
|
||||
<MenuIcon className="size-5.5 stroke-foreground" />
|
||||
)}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<MobileNavigationMenu open={open} />
|
||||
</Fragment>
|
||||
);
|
||||
};
|
||||
|
||||
const DesktopMenuItem = ({ item, index }: DesktopMenuItemProps) => {
|
||||
if (item.groups) {
|
||||
return (
|
||||
<NavigationMenuItem key={`desktop-menu-item-${index}`} value={`${index}`}>
|
||||
<NavigationMenuTrigger className="h-fit bg-transparent px-2.5 text-start font-normal text-muted-foreground [&_svg]:ms-1 [&_svg]:!ml-0">
|
||||
{item.title}
|
||||
</NavigationMenuTrigger>
|
||||
<NavigationMenuContent
|
||||
dir="rtl"
|
||||
className="start-0 end-auto left-auto z-50 !rounded-xl !border !p-0 text-start"
|
||||
>
|
||||
<ul
|
||||
className="flex flex-row-reverse p-2 text-start"
|
||||
style={{ width: item.groups.length * 248 }}
|
||||
>
|
||||
{item.groups.map((group, index1) => (
|
||||
<li className="flex-1" key={`desktop-group-${index1}`}>
|
||||
<ul>
|
||||
<li className="px-3 py-2 text-start text-sm leading-normal text-muted-foreground">
|
||||
{group.title}
|
||||
</li>
|
||||
{group.links.map((link, index2) => (
|
||||
<li key={`desktop-links-${index1}-${index2}`}>
|
||||
<NavigationMenuLink
|
||||
asChild
|
||||
className="group/link flex-row gap-2 px-3 py-2 text-start transition-colors duration-200"
|
||||
>
|
||||
<a href={link.url} className="text-start">
|
||||
<div className="flex size-8 shrink-0 rounded-lg border duration-400 fade-in group-hover/link:bg-background">
|
||||
<link.icon className="m-auto size-4 group-hover/link:stroke-black" />
|
||||
</div>
|
||||
<div className="flex min-w-0 flex-col gap-[2px] text-start">
|
||||
<div className="text-sm font-medium">
|
||||
{link.label}
|
||||
</div>
|
||||
<div className="text-xs text-muted-foreground group-hover/link:text-foreground">
|
||||
{link.description}
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</NavigationMenuLink>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</NavigationMenuContent>
|
||||
</NavigationMenuItem>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<NavigationMenuItem key={`desktop-menu-item-${index}`} value={`${index}`}>
|
||||
<NavigationMenuLink
|
||||
href={item.url}
|
||||
className={`${navigationMenuTriggerStyle()} h-fit bg-transparent px-2.5 text-start font-normal text-muted-foreground`}
|
||||
>
|
||||
{item.title}
|
||||
</NavigationMenuLink>
|
||||
</NavigationMenuItem>
|
||||
);
|
||||
};
|
||||
|
||||
const MobileNavigationMenu = ({ open }: MobileNavigationMenuProps) => {
|
||||
return (
|
||||
<Sheet open={open}>
|
||||
<SheetContent
|
||||
aria-describedby={undefined}
|
||||
side="top"
|
||||
className="dark inset-0 z-998 h-dvh w-full bg-background pt-[3.9375rem] [&>button]:hidden"
|
||||
>
|
||||
<div className="h-full overflow-y-auto pt-10 pb-20">
|
||||
<div className="container">
|
||||
<div className="absolute -m-px h-px w-px overflow-hidden border-0 mask-clip-border p-0 text-nowrap whitespace-nowrap">
|
||||
<SheetTitle className="text-primary">منوی موبایل</SheetTitle>
|
||||
</div>
|
||||
<div className="flex flex-col gap-6">
|
||||
<div className="flex flex-col gap-4">
|
||||
{MOBILE_BUTTONS.map((btn, index) => (
|
||||
<Button
|
||||
variant={!btn.isPrimary ? "outline" : "default"}
|
||||
className={
|
||||
btn.isPrimary
|
||||
? "text-primary-foreground"
|
||||
: "text-foreground"
|
||||
}
|
||||
asChild
|
||||
key={`navbar-btn-${index}`}
|
||||
>
|
||||
<a href={btn.url}>{btn.label}</a>
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
<Accordion
|
||||
type="multiple"
|
||||
dir="rtl"
|
||||
className="w-full text-start"
|
||||
>
|
||||
{NAVIGATION.map((item, index) =>
|
||||
renderMobileMenuItem(item, index),
|
||||
)}
|
||||
</Accordion>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</SheetContent>
|
||||
</Sheet>
|
||||
);
|
||||
};
|
||||
|
||||
const renderMobileMenuItem = (item: MenuItem, index: number) => {
|
||||
if (item.groups) {
|
||||
return (
|
||||
<AccordionItem
|
||||
key={item.title}
|
||||
value={`nav-${index}`}
|
||||
className="border-b-0"
|
||||
>
|
||||
<AccordionTrigger className="h-[3.75rem] items-center justify-start p-0 !px-4 text-start text-base leading-[3.75] font-normal text-muted-foreground hover:bg-muted hover:no-underline [&>svg]:ms-auto [&>svg]:me-0">
|
||||
{item.title}
|
||||
</AccordionTrigger>
|
||||
<AccordionContent className="max-h-[60dvh] overflow-x-auto">
|
||||
{item.groups.flatMap((group, groupIndex) =>
|
||||
group.links.map((link, linkIndex) => (
|
||||
<a
|
||||
key={`mobile-link-${groupIndex}-${linkIndex}`}
|
||||
href={link.url}
|
||||
className="flex h-12 items-center gap-2 rounded-lg px-4 text-start text-muted-foreground transition-colors duration-300 hover:bg-muted hover:text-foreground"
|
||||
>
|
||||
<link.icon className="size-4 stroke-muted-foreground" />
|
||||
{link.label}
|
||||
</a>
|
||||
)),
|
||||
)}
|
||||
</AccordionContent>
|
||||
</AccordionItem>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<a
|
||||
key={item.title}
|
||||
href={item.url}
|
||||
className="flex h-[3.75rem] items-center rounded-md p-0 px-4 text-start text-base leading-[3.75] font-normal text-muted-foreground ring-ring/10 outline-ring/50 transition-all hover:bg-muted focus-visible:ring-4 focus-visible:outline-1 nth-last-1:border-0"
|
||||
>
|
||||
{item.title}
|
||||
</a>
|
||||
);
|
||||
};
|
||||
|
||||
export { Navbar11 };
|
||||
Reference in New Issue
Block a user