import { ReactNode, useRef, useState } from "react"; import { ArrowLeft, ArrowRight, ExternalLink } from "lucide-react"; const campaigns = [ { title: "Your snack-time manifesto", src: "", alt: "" }, { title: "Your savoury snack experts", src: "/campaigns/snack-range.webp", alt: "ADUCKTIVE’s range of salted egg cornflakes, rolls and mushroom crisps. Your unique savoury snacks expert." }, { title: "Find us at selected AEON stores", src: "/campaigns/aeon.webp", alt: "ADUCKTIVE campaign announcing availability at selected AEON stores, with the duck mascot and snack range. Open the full banner to read the listed locations." }, { title: "Get your crunch at emart24", src: "/campaigns/emart24.webp", alt: "ADUCKTIVE original and spicy salted egg cornflakes mini packs. Get your salted egg snacks at emart24." }, { title: "Bold flavours. Taste adventure.", src: "/campaigns/bold-flavours.jpg", alt: "ADUCKTIVE snack range: bold flavours, savoury snacks, taste adventure. Cornflakes, rolls and mushroom crisps pictured with their product information." }, { title: "Snack happiness every day", src: "/campaigns/new-banner.webp", alt: "A family sharing ADUCKTIVE snacks together. Snack happiness every day." }, { title: "Bold flavours at OH!SOME", src: "/campaigns/oh-some.jpg", alt: "ADUCKTIVE tempeh chips, mushroom crisps and cornflakes. Now available at OH!SOME." }, { title: "Family pack. Dua pilihan, satu keceriaan.", src: "/campaigns/family-pack.jpg", alt: "ADUCKTIVE original and spicy salted egg cornflakes family packs. Open the full banner for promotional details." }, { title: "Office snack fiesta with pandamart", src: "/campaigns/pandamart-fiesta.png", alt: "Lapar kat office? ADUCKTIVE snacks on pandamart. Open the full banner for promotional details." }, { title: "More salted egg favourites at emart24", src: "/campaigns/emart-update.webp", alt: "ADUCKTIVE spicy and original salted egg cornflakes mini packs at emart24." }, { title: "Find us at ST Rosyam Mart", src: "/campaigns/rosyam-mart.webp", alt: "ADUCKTIVE snacks now available at ST Rosyam Mart. Open the full banner to read the listed locations." }, ]; export function CampaignCarousel({ children }: { children: ReactNode }) { const [active, setActive] = useState(0); const touch = useRef<{ x: number; y: number } | null>(null); const move = (delta: number) => setActive(value => (value + delta + campaigns.length) % campaigns.length); return
MORE REASONS TO CRUNCH

{active + 1} / {campaigns.length} · {campaigns[active].title}

{campaigns.map((campaign, index) => )}
{ if (event.key === "ArrowRight" || event.key === "ArrowLeft") { event.preventDefault(); move(event.key === "ArrowRight" ? 1 : -1); } }} onTouchStart={event => { const point = event.touches[0]; touch.current = { x: point.clientX, y: point.clientY }; }} onTouchCancel={() => { touch.current = null; }} onTouchEnd={event => { if (!touch.current) return; const point = event.changedTouches[0]; const dx = point.clientX - touch.current.x; const dy = point.clientY - touch.current.y; touch.current = null; if (Math.abs(dx) > 55 && Math.abs(dx) > Math.abs(dy) * 1.5) move(dx < 0 ? 1 : -1); }}> {campaigns.slice(1).map((campaign, index) => )}
; }