"use client"; import { useRef } from "react"; import Image from "next/image"; import Link from "next/link"; import { ArrowUpRight } from "lucide-react"; import { useGSAP } from "@gsap/react"; import { gsap } from "gsap"; import { ScrollTrigger } from "gsap/dist/ScrollTrigger"; import styles from "./DesktopSystemCards.module.css"; gsap.registerPlugin(useGSAP, ScrollTrigger); export type DesktopSystemCardItem = { title: string; body: string; screenshot: string; screenshotWidth: number; screenshotHeight: number; href?: string; }; export default function DesktopSystemCards({ badge, headline, subtext, items, }: { badge: string; headline: string; subtext: string; items: readonly DesktopSystemCardItem[]; }) { const root = useRef(null); useGSAP( (_context, contextSafe) => { const select = gsap.utils.selector(root); const media = gsap.matchMedia(); media.add( { desktop: "(min-width: 1024px)", reduceMotion: "(prefers-reduced-motion: reduce)", }, (context) => { const { desktop, reduceMotion } = context.conditions as { desktop: boolean; reduceMotion: boolean; }; if (!desktop || reduceMotion) return; const heading = select("[data-system-heading]")[0]; if (heading) { gsap.from(heading.children, { autoAlpha: 0, y: 24, duration: 0.72, ease: "power3.out", stagger: 0.08, clearProps: "transform,opacity,visibility", scrollTrigger: { trigger: heading, start: "clamp(top 84%)", once: true, }, }); } select("[data-system-card]").forEach((card, index) => { const copy = card.querySelector("[data-system-copy]"); const visual = card.querySelector("[data-system-visual]"); const screenshot = card.querySelector("[data-system-screenshot]"); const direction = index % 2 === 0 ? 1 : -1; const reveal = gsap.timeline({ defaults: { ease: "power3.out" }, scrollTrigger: { trigger: card, start: "clamp(top 82%)", once: true, }, }); reveal.fromTo( card, { autoAlpha: 0, y: 38, scale: 0.985, }, { autoAlpha: 1, y: 0, scale: 1, duration: 0.78, clearProps: "transform,opacity,visibility", }, ); if (copy) { reveal.fromTo( copy, { autoAlpha: 0, x: -38 * direction, }, { autoAlpha: 1, x: 0, duration: 0.62, clearProps: "transform,opacity,visibility", }, 0.12 ); } if (visual) { reveal.fromTo( visual, { autoAlpha: 0, x: 72 * direction, rotation: 1.15 * direction, scale: 0.955, }, { autoAlpha: 1, x: 0, rotation: 0, scale: 1, duration: 0.86, clearProps: "transform,opacity,visibility", }, 0.08 ); } if (!screenshot) return; const enter = contextSafe!(() => { gsap.to(screenshot, { y: -4, scale: 1.006, boxShadow: "0 20px 44px rgba(15, 23, 42, 0.12)", duration: 0.3, ease: "power2.out", overwrite: "auto", }); }); const leave = contextSafe!(() => { gsap.to(screenshot, { y: 0, scale: 1, boxShadow: "0 14px 34px rgba(15, 23, 42, 0.09)", duration: 0.4, ease: "power3.out", overwrite: "auto", onComplete: () => { gsap.set(screenshot, { clearProps: "transform,boxShadow" }); }, }); }); screenshot.addEventListener("pointerenter", enter); screenshot.addEventListener("pointerleave", leave); context.add(() => { screenshot.removeEventListener("pointerenter", enter); screenshot.removeEventListener("pointerleave", leave); gsap.killTweensOf(screenshot); gsap.set(screenshot, { clearProps: "transform,boxShadow" }); }); }); } ); return () => media.revert(); }, { scope: root } ); return (
{badge}

{headline}

{subtext}

{items.map((item) => (

{item.title}

{item.body}

{item.href ? ( Bereich ansehen ) : null}
{`${item.title}
))}
); }