"use client" import Image from "next/image" import { useCallback, useRef, useState } from "react" import LocalizedClientLink from "@modules/common/components/localized-client-link" import landing from "@/config/landing.json" type Slide = (typeof landing.hero.slides)[number] /** * Home hero carousel (suncobrani, pergole, tende). Each slide brings its own * headline, CTA and three product facts on the right. * * Autoplay is driven by the CSS progress bar (`.hero-progress` in * globals.css): when the active bar's animation ends, the next slide shows. * Keyboard focus pauses the bar; reduced motion disables the animation and so * autoplay. Slides under the transparent header (see HeaderShell). */ export default function LandingHero() { const { slides, intervalMs } = landing.hero const [active, setActive] = useState(0) const [paused, setPaused] = useState(false) const touchX = useRef(null) const go = useCallback( (index: number) => setActive((index + slides.length) % slides.length), [slides.length] ) return (
setPaused((e.target as HTMLElement).matches(":focus-visible"))} onBlur={() => setPaused(false)} onKeyDown={(e) => { if (e.key === "ArrowRight") go(active + 1) if (e.key === "ArrowLeft") go(active - 1) }} onTouchStart={(e) => (touchX.current = e.touches[0].clientX)} onTouchEnd={(e) => { if (touchX.current === null) return const dx = e.changedTouches[0].clientX - touchX.current if (Math.abs(dx) > 50) go(active + (dx < 0 ? 1 : -1)) touchX.current = null }} > {/* Images, cross-faded */} {slides.map((slide, i) => (
{slide.title} {/* Per-slide darkening (landing.json hero.slides[].overlay, 0–1) */} {slide.overlay > 0 && (
)}
))}
{/* Text: all slides stacked in one grid cell, only the active one visible */}
{slides.map((slide, i) => ( ))}
{/* Product facts for the visible slide */}
{slides.map((slide, i) => (
{slide.stats.map((stat) => (
{stat.value}
{stat.label}
))}
))}
{/* Slide selector with progress (drives autoplay) */}
{slides.map((slide, i) => ( ))}
) } function SlideText({ slide, index, total, active, }: { slide: Slide index: number total: number active: boolean }) { const Heading = index === 0 ? "h1" : "h2" return (

{slide.kicker}

{slide.title}

{slide.subtitle}

{slide.cta.label}
) }