import Image from "next/image"; import Link from "next/link"; import type { CSSProperties } from "react"; import { toCssAspectRatio } from "@/lib/format"; import type { StaticImageSlot } from "@/lib/types"; // Shared renderer for the "one-banner-bg" / "two-banner-bg" / "three-banner-bg" // static-image slots: url -> , linkUrl -> wrap in , slot.aspectRatio // drives the frame. An empty or failed slot keeps a flat, labelled placeholder // (this site's usual stand-in for undesigned art, see // public/images/categories/{id}.svg) instead of a fake photo, sized so the // business/designer can see exactly what to fill in. function BannerGrid({ slot, count, defaultAspect, recommendedWidth, cols, }: { slot?: StaticImageSlot; count: number; defaultAspect: string; recommendedWidth: number; cols: string; }) { const images = (slot?.images ?? []).slice(0, count); const cssAspect = toCssAspectRatio(slot?.aspectRatio) ?? defaultAspect; const aspectStyle = { aspectRatio: cssAspect } as CSSProperties; const cells = Array.from({ length: count }, (_, i) => images[i]); return ( {cells.map((img, i) => { if (!img) { return ( بنر تبلیغاتی {recommendedWidth}px · {cssAspect.replace("/", ":")} ); } const media = ( ); const frameClass = "relative block overflow-hidden rounded-xl bg-surface"; // Only wrap in when the slot actually carries a link — an // undesignated banner shouldn't become a dead click target. return img.linkUrl ? ( {media} ) : ( {media} ); })} ); } export function OneBanner({ slot }: { slot?: StaticImageSlot }) { return ; } export function TwoBanners({ slot }: { slot?: StaticImageSlot }) { return ( ); } export function ThreeBanners({ slot }: { slot?: StaticImageSlot }) { return ( ); }