Files
HiveGrid-Wireframes/03 Quellen und Referenzen/hivegrid-website/app/waitlist/WaitlistNext.tsx
T

142 lines
6.7 KiB
TypeScript

"use client";
import { useEffect, useRef } from "react";
import { gsap } from "gsap";
import { ScrollTrigger } from "gsap/dist/ScrollTrigger";
import { EnvelopeSimple, ChatCircleDots, Confetti } from "@phosphor-icons/react/ssr";
import type { Icon as PhosphorIcon } from "@phosphor-icons/react";
// Flat-top hexagon → ties the step nodes into the honeycomb theme.
const HEX = "polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%)";
type Step = { n: string; t: string; d: string; Icon: PhosphorIcon };
const STEPS: Step[] = [
{ n: "01", t: "Du trägst dich ein", d: "Eine E-Mail genügt. Kein Vertrag, keine Kreditkarte, komplett unverbindlich.", Icon: EnvelopeSimple },
{ n: "02", t: "Wir melden uns", d: "Sobald HiveGrid für deinen Betrieb bereit ist, persönlich und ohne Spam.", Icon: ChatCircleDots },
{ n: "03", t: "Du bist von Anfang an dabei", d: "Unter den Ersten, die HiveGrid nutzen und mitgestalten.", Icon: Confetti },
];
// Scroll-linked "how it works" timeline: a fill line grows with scroll progress
// and each hex node lights up the moment the fill reaches it.
export default function WaitlistNext() {
const listRef = useRef<HTMLDivElement>(null);
const trackRef = useRef<HTMLSpanElement>(null);
const fillRef = useRef<HTMLSpanElement>(null);
useEffect(() => {
const list = listRef.current;
const track = trackRef.current;
const fill = fillRef.current;
if (!list || !track || !fill) return;
const steps = Array.from(list.querySelectorAll<HTMLElement>("[data-step]"));
const hexes = steps.map((s) => s.querySelector<HTMLElement>("[data-node]")!);
// Reduced motion: skip the scrub, just show the finished state.
if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) {
const lr = list.getBoundingClientRect();
const first = hexes[0].getBoundingClientRect().top - lr.top + hexes[0].offsetHeight / 2;
const last = hexes[hexes.length - 1].getBoundingClientRect().top - lr.top + hexes[hexes.length - 1].offsetHeight / 2;
track.style.top = fill.style.top = `${first}px`;
track.style.height = fill.style.height = `${last - first}px`;
steps.forEach((s) => s.classList.add("is-active"));
return;
}
gsap.registerPlugin(ScrollTrigger);
let centers: number[] = [];
let first = 0;
let span = 0;
const measure = () => {
const lr = list.getBoundingClientRect();
centers = hexes.map((h) => h.getBoundingClientRect().top - lr.top + h.offsetHeight / 2);
first = centers[0];
span = centers[centers.length - 1] - first;
track.style.top = `${first}px`;
track.style.height = `${span}px`;
fill.style.top = `${first}px`;
};
const ctx = gsap.context(() => {
measure();
ScrollTrigger.create({
trigger: list,
start: "top 80%",
end: "bottom 62%",
scrub: 0.4,
onRefresh: measure,
onUpdate: (self) => {
const filled = self.progress * span;
fill.style.height = `${filled}px`;
const reach = first + filled;
steps.forEach((s, i) => s.classList.toggle("is-active", reach >= centers[i] - 1));
},
});
}, list);
return () => ctx.revert();
}, []);
return (
<section className="section-full wl-next" style={{ background: "var(--surface)", paddingBlock: 88 }}>
<style>{`
.wl-next [data-node]{ background:#E8EAEF; transition:background .5s ease, transform .5s cubic-bezier(.2,.8,.2,1), filter .5s ease; }
.wl-next [data-node] svg{ color:var(--text-tertiary); transition:color .5s ease; }
.wl-next [data-num]{ color:var(--text-tertiary); transition:color .5s ease; }
.wl-next [data-title]{ opacity:.82; transition:opacity .5s ease; }
.wl-next [data-step] p{ opacity:.66; transition:opacity .5s ease; }
.wl-next [data-step].is-active [data-node]{ background:var(--accent-yellow); transform:scale(1.07); filter:drop-shadow(0 8px 18px rgba(241,183,41,.5)); }
.wl-next [data-step].is-active [data-node] svg{ color:#171106; }
.wl-next [data-step].is-active [data-num]{ color:var(--accent-yellow-dark); }
.wl-next [data-step].is-active [data-title]{ opacity:1; }
.wl-next [data-step].is-active p{ opacity:1; }
.wl-next .rail-head{ position:absolute; left:50%; bottom:-4px; transform:translateX(-50%); width:11px; height:11px; border-radius:50%; background:var(--accent-yellow); box-shadow:0 0 14px 2px rgba(241,183,41,.75); }
`}</style>
<div className="mx-auto flex flex-col items-center gap-12" style={{ maxWidth: "var(--content-width)" }}>
<div className="flex flex-col items-center gap-3 text-center">
<span
className="text-[12px] font-semibold tracking-widest chamfer-badge px-3 py-1"
style={{ background: "var(--accent-yellow-light)", color: "var(--accent-yellow-dark)" }}
>
SO GEHT&apos;S WEITER
</span>
<h2 className="text-[28px] md:text-[38px] font-bold leading-[1.15]" style={{ color: "var(--text-primary)" }}>
Was nach deiner Anmeldung passiert.
</h2>
</div>
<div ref={listRef} className="relative w-full" style={{ maxWidth: 560 }}>
{/* rail: dim track + animated fill with a glowing head */}
<span ref={trackRef} aria-hidden className="absolute rounded-full" style={{ left: 26, width: 2, top: 0, height: 0, background: "var(--border-light)" }} />
<span ref={fillRef} aria-hidden className="absolute rounded-full rail-fill" style={{ left: 26, width: 2, top: 0, height: 0, background: "linear-gradient(var(--accent-yellow), var(--accent-yellow-dark))" }}>
<span className="rail-head" aria-hidden />
</span>
{STEPS.map((s, i) => (
<div
key={s.n}
data-step
className="relative flex items-start gap-5 md:gap-6"
style={{ paddingBottom: i === STEPS.length - 1 ? 0 : 56 }}
>
<span data-node className="relative z-10 grid place-items-center shrink-0" style={{ width: 54, height: 48, clipPath: HEX }}>
<s.Icon size={24} weight="duotone" />
</span>
<div className="pt-1.5">
<div className="flex items-baseline gap-2.5">
<span data-num className="text-[13px] font-extrabold tracking-[0.14em]">{s.n}</span>
<h3 data-title className="text-[18px] md:text-[20px] font-bold" style={{ color: "var(--text-primary)" }}>{s.t}</h3>
</div>
<p className="text-[14.5px] leading-relaxed mt-1.5 max-w-[420px]" style={{ color: "var(--text-secondary)" }}>{s.d}</p>
</div>
</div>
))}
</div>
</div>
</section>
);
}