diff --git a/src/app/meshkee/static-image-slots/route.ts b/src/app/meshkee/static-image-slots/route.ts index 1612b0e..1e26462 100644 --- a/src/app/meshkee/static-image-slots/route.ts +++ b/src/app/meshkee/static-image-slots/route.ts @@ -52,6 +52,15 @@ export async function GET() { itemCount: 3, recommendedWidth: 520, }, + { + key: "sale-banner", + label: "بنر ثابت کروسل تخفیف‌های ویژه", + kind: "single", + pageKey: "home", + aspectRatio: "4:5", + itemCount: 1, + recommendedWidth: 480, + }, ], }); } diff --git a/src/app/page.tsx b/src/app/page.tsx index 9e0b375..0cbb518 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -77,7 +77,7 @@ export default async function Home() { return (
- + diff --git a/src/components/SpecialSaleCarousel.tsx b/src/components/SpecialSaleCarousel.tsx index 98d13d3..2537995 100644 --- a/src/components/SpecialSaleCarousel.tsx +++ b/src/components/SpecialSaleCarousel.tsx @@ -4,13 +4,27 @@ import Link from "next/link"; import { Swiper, SwiperSlide } from "swiper/react"; import { Autoplay, Navigation } from "swiper/modules"; import "swiper/css"; -import type { SpecialCarouselItem } from "@/lib/types"; +import type { SpecialCarouselItem, StaticImageSlot } from "@/lib/types"; +import { toCssAspectRatio } from "@/lib/format"; import ProductCard from "./ui/ProductCard"; import { ChevronLeftIcon, ChevronRightIcon } from "./icons"; -export default function SpecialSaleCarousel({ items }: { items: SpecialCarouselItem[] }) { +export default function SpecialSaleCarousel({ + items, + bannerSlot, +}: { + items: SpecialCarouselItem[]; + bannerSlot?: StaticImageSlot; +}) { if (items.length === 0) return null; + const bannerImage = bannerSlot?.images[0]; + const cssAspectRatio = toCssAspectRatio(bannerSlot?.aspectRatio); + const bannerAspectStyle = cssAspectRatio ? { aspectRatio: cssAspectRatio } : undefined; + const bannerSrc = bannerImage?.url ?? "/images/special-sale/banner.svg"; + const bannerHref = bannerImage?.linkUrl; + const BannerWrapper = bannerHref ? "a" : "div"; + return (
@@ -32,51 +46,58 @@ export default function SpecialSaleCarousel({ items }: { items: SpecialCarouselI
-
- 5} - spaceBetween={14} - slidesPerView={1.8} - breakpoints={{ - 480: { slidesPerView: 2.2 }, - 640: { slidesPerView: 3 }, - 1024: { slidesPerView: 4.5, spaceBetween: 20 }, - }} +
+ {/* Fixed on the right — stays put while the products scroll beside it. */} + - - - - {items.map(({ product, discount }) => ( - - - - ))} - + + - - +
+ + {items.map(({ product, discount }) => ( + + + + ))} + + + + +
); diff --git a/src/components/ui/ProductCard.tsx b/src/components/ui/ProductCard.tsx index c956471..9bd3ae4 100644 --- a/src/components/ui/ProductCard.tsx +++ b/src/components/ui/ProductCard.tsx @@ -48,7 +48,7 @@ export default function ProductCard({
{/* Fixed height regardless of 1 or 2 lines, so card heights stay consistent across a row of mixed-length titles. */} -

+

{title}

@@ -69,7 +69,7 @@ export default function ProductCard({ )}
-
+
{price != null ? formatToman(price) : "تماس بگیرید"}