132 lines
6.7 KiB
TypeScript
132 lines
6.7 KiB
TypeScript
"use client";
|
|
|
|
/* ═══════════════════════════════════════════════════════════════════════
|
|
RequestFlow — animated "watch a request travel through the bridge".
|
|
Deine KI → KI-Brücke (MCP) → HiveGrid and back. A packet travels the
|
|
track, stations light up, and a caption narrates each step. Auto-plays
|
|
and loops; pauses on hover; static under prefers-reduced-motion.
|
|
═══════════════════════════════════════════════════════════════════════ */
|
|
|
|
import { useEffect, useRef, useState } from "react";
|
|
import { Sparkle, PlugsConnected, Database } from "@phosphor-icons/react/ssr";
|
|
import { CHAMFER } from "@/lib/chamfer";
|
|
|
|
// Station centres in a 3-column grid → 1/6, 3/6, 5/6.
|
|
type Step = { pos: number; active: 0 | 1 | 2; n: string; title: string; detail: string; chip?: string };
|
|
const STEPS: Step[] = [
|
|
{ pos: 16.7, active: 0, n: "1", title: "Du fragst", detail: "„Zeig mir alle offenen Angebote über 10.000 €.“" },
|
|
{ pos: 50, active: 1, n: "2", title: "Über die KI-Brücke", detail: "Die Anfrage läuft sicher über MCP, nur im Rahmen deiner Freigaben." },
|
|
{ pos: 83.3, active: 2, n: "3", title: "HiveGrid führt es aus", detail: "Liest nur die Daten deines Betriebs, jeder Zugriff protokolliert.", chip: "hg_project_search · read" },
|
|
{ pos: 50, active: 1, n: "4", title: "Antwort zurück", detail: "Das Ergebnis läuft über die Brücke zurück zu deiner KI." },
|
|
{ pos: 16.7, active: 0, n: "5", title: "Ergebnis in deiner KI", detail: "3 Treffer, direkt im Chat. Kein Copy-Paste, kein Tab-Wechsel." },
|
|
];
|
|
|
|
const STATIONS = [
|
|
{ icon: <Sparkle size={24} weight="duotone" style={{ color: "var(--accent-yellow-dark)" }} />, label: "Deine KI", sub: "Dein KI-Client" },
|
|
{ icon: <PlugsConnected size={24} weight="duotone" style={{ color: "var(--accent-yellow)" }} />, label: "KI-Brücke", sub: "MCP", dark: true },
|
|
{ icon: <Database size={24} weight="duotone" style={{ color: "var(--accent-yellow-dark)" }} />, label: "HiveGrid", sub: "Deine Betriebsdaten" },
|
|
];
|
|
|
|
export default function RequestFlow() {
|
|
const [step, setStep] = useState(0);
|
|
const paused = useRef(false);
|
|
|
|
useEffect(() => {
|
|
if (typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches) return;
|
|
const id = window.setInterval(() => {
|
|
if (!paused.current) setStep((s) => (s + 1) % STEPS.length);
|
|
}, 3500);
|
|
return () => window.clearInterval(id);
|
|
}, []);
|
|
|
|
const cur = STEPS[step];
|
|
|
|
return (
|
|
<div className="w-full mx-auto flex flex-col gap-8" style={{ maxWidth: 920 }}>
|
|
{/* bridge + travelling packet */}
|
|
<div
|
|
className="relative"
|
|
onMouseEnter={() => { paused.current = true; }}
|
|
onMouseLeave={() => { paused.current = false; }}
|
|
>
|
|
{/* track line */}
|
|
<span className="absolute pointer-events-none" style={{ top: 33, left: "16.7%", right: "16.7%", height: 2, background: "var(--border-light)", borderRadius: 2 }} aria-hidden />
|
|
{/* travelling packet */}
|
|
<span
|
|
className="absolute pointer-events-none rounded-full"
|
|
style={{
|
|
top: 33, left: `${cur.pos}%`, width: 12, height: 12,
|
|
transform: "translate(-50%, -5px)",
|
|
background: "var(--accent-yellow)",
|
|
boxShadow: "0 0 14px 3px rgba(241,183,41,0.7)",
|
|
transition: "left 0.75s cubic-bezier(0.65,0,0.35,1)",
|
|
}}
|
|
aria-hidden
|
|
/>
|
|
|
|
{/* stations */}
|
|
<div className="grid grid-cols-3">
|
|
{STATIONS.map((s, i) => {
|
|
const on = cur.active === i;
|
|
return (
|
|
<div key={i} className="flex flex-col items-center gap-2 text-center px-1">
|
|
<span
|
|
className="relative grid place-items-center rounded-2xl transition-all duration-500"
|
|
style={{
|
|
width: 64, height: 64,
|
|
background: s.dark ? "var(--dark-bg)" : "var(--surface)",
|
|
border: `1.5px solid ${on ? "var(--accent-yellow)" : "var(--border-light)"}`,
|
|
transform: on ? "scale(1.08)" : "scale(1)",
|
|
filter: on ? "drop-shadow(0 8px 18px rgba(241,183,41,0.35))" : "none",
|
|
zIndex: 2,
|
|
}}
|
|
>
|
|
{s.icon}
|
|
</span>
|
|
<span className="text-[14px] md:text-[15px] font-bold" style={{ color: "var(--text-primary)" }}>{s.label}</span>
|
|
<span className="text-[11.5px] md:text-[12.5px] leading-snug" style={{ color: "var(--text-tertiary)" }}>{s.sub}</span>
|
|
</div>
|
|
);
|
|
})}
|
|
</div>
|
|
</div>
|
|
|
|
{/* caption — narrates the current step */}
|
|
<div
|
|
className="relative overflow-hidden mx-auto w-full flex items-start gap-4"
|
|
style={{ maxWidth: 640, background: "var(--container-bg)", padding: "20px 22px", clipPath: CHAMFER }}
|
|
>
|
|
<span className="grid place-items-center shrink-0 rounded-full text-[14px] font-extrabold" style={{ width: 32, height: 32, background: "var(--dark-bg)", color: "var(--accent-yellow)" }}>
|
|
{cur.n}
|
|
</span>
|
|
<div className="flex flex-col gap-1 min-w-0">
|
|
<span className="text-[16px] font-bold" style={{ color: "var(--text-primary)" }}>{cur.title}</span>
|
|
<span className="text-[14px] leading-relaxed" style={{ color: "var(--text-secondary)" }}>{cur.detail}</span>
|
|
{/* chip slot: reserve the height always so the appearing chip never
|
|
shifts the layout (the page would otherwise jump every cycle). */}
|
|
<div className="mt-1.5" style={{ minHeight: 30 }}>
|
|
{cur.chip && (
|
|
<span className="inline-flex items-center gap-2 self-start px-2.5 py-1 text-[12px]" style={{ background: "var(--surface)", border: "1px solid var(--border-light)", borderRadius: 6, fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace", color: "var(--text-primary)" }}>
|
|
{cur.chip}
|
|
</span>
|
|
)}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{/* step dots */}
|
|
<div className="flex items-center justify-center gap-2 -mt-2">
|
|
{STEPS.map((s, i) => (
|
|
<button
|
|
key={i}
|
|
onClick={() => setStep(i)}
|
|
aria-label={`Schritt ${s.n}`}
|
|
className="rounded-full transition-all"
|
|
style={{ width: i === step ? 22 : 8, height: 8, background: i === step ? "var(--accent-yellow)" : "var(--border-light)" }}
|
|
/>
|
|
))}
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|