Catalog-only (no cart); search targets store items and products pages. Co-authored-by: Cursor <cursoragent@cursor.com>
45 lines
1.8 KiB
TypeScript
45 lines
1.8 KiB
TypeScript
"use client";
|
|
|
|
import Link from "next/link";
|
|
import { Placeholder } from "@/components/Placeholder";
|
|
import type { NavCategory } from "@/lib/categories";
|
|
|
|
export function MegaMenu({ open, categories }: { open: boolean; categories: NavCategory[] }) {
|
|
if (!open) return null;
|
|
|
|
return (
|
|
<div className="absolute top-full right-0 z-50 mt-1 w-[min(920px,calc(100vw-2rem))] border border-line bg-white p-5 shadow-[0_20px_50px_rgba(0,0,0,0.08)]">
|
|
{categories.length === 0 ? (
|
|
<p className="text-[13px] text-muted">دستهبندیها بهزودی اضافه میشوند.</p>
|
|
) : (
|
|
<div className="grid grid-cols-2 gap-5 md:grid-cols-3 lg:grid-cols-4">
|
|
{categories.map((category) => (
|
|
<div key={category.id}>
|
|
<Link href={category.href} className="mb-3 flex items-center gap-2 text-[13.5px] font-semibold text-ink hover:text-brand">
|
|
<span className="grid size-9 place-items-center overflow-hidden rounded-xl bg-paper">
|
|
<Placeholder src={category.image || "/placeholders/category.svg"} className="size-full object-cover" />
|
|
</span>
|
|
{category.title}
|
|
</Link>
|
|
{category.children.length ? (
|
|
<ul className="space-y-1.5 pr-1">
|
|
{category.children.map((child) => (
|
|
<li key={child.id}>
|
|
<Link
|
|
href={child.href}
|
|
className="block rounded-lg px-2 py-1 text-[12.5px] text-muted transition hover:bg-paper hover:text-brand"
|
|
>
|
|
{child.title}
|
|
</Link>
|
|
</li>
|
|
))}
|
|
</ul>
|
|
) : null}
|
|
</div>
|
|
))}
|
|
</div>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|