chore(repo): sync wireframe structure and references
This commit is contained in:
1 parent
05d2d5777f
commit
d953a79e95
453 files changed
+36639
-621
No files matched your search
+220
@@ -0,0 +1,220 @@
|
||||
"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<HTMLElement>(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 (
|
||||
<section ref={root} className={styles.section} aria-labelledby="desktop-system-cards-title">
|
||||
<div className={styles.inner}>
|
||||
<header className={styles.heading} data-system-heading>
|
||||
<span>{badge}</span>
|
||||
<h2 id="desktop-system-cards-title">{headline}</h2>
|
||||
<p>{subtext}</p>
|
||||
</header>
|
||||
|
||||
<div className={styles.lanes}>
|
||||
{items.map((item) => (
|
||||
<article className={styles.card} data-system-card key={item.title}>
|
||||
<div className={styles.copy} data-system-copy>
|
||||
<h3>{item.title}</h3>
|
||||
<p>{item.body}</p>
|
||||
{item.href ? (
|
||||
<Link href={item.href} className={styles.link}>
|
||||
Bereich ansehen <ArrowUpRight size={17} aria-hidden />
|
||||
</Link>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
<div className={styles.visual} data-system-visual>
|
||||
<div className={styles.screenshot} data-system-screenshot>
|
||||
<Image
|
||||
src={item.screenshot}
|
||||
alt={`${item.title} in HiveGrid`}
|
||||
width={item.screenshotWidth}
|
||||
height={item.screenshotHeight}
|
||||
sizes="(min-width: 1280px) 760px, (min-width: 1024px) 58vw, 100vw"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user