Files
portal/components/flow.tsx
T
Tom Chien (IQ-AS) 1988c635fe
CI/CD (dev on branch, prod on tag) / build-and-deploy (push) Successful in 20m35s
upload
2026-11-18 14:26:36 +08:00

122 lines
3.6 KiB
TypeScript

import type { CSSProperties, ReactNode } from "react";
import { ChevronDown, ChevronRight } from "lucide-react";
/** One box in a flow diagram: icon tile, title, subtitle and a mono detail line. */
export function FlowNode({
icon,
title,
subtitle,
detail,
accent,
step,
className = "",
}: {
icon: ReactNode;
title: string;
subtitle?: string;
detail?: string;
/** Hex colour used for the icon tile glow. */
accent: string;
step?: number;
className?: string;
}) {
return (
<div
className={`relative min-w-0 flex-1 rounded-xl border border-white/10 bg-slate-900/70 p-4 shadow-lg shadow-black/20 backdrop-blur ${className}`}
>
{step !== undefined && (
<span className="absolute -top-2.5 -left-2.5 flex size-6 items-center justify-center rounded-full border border-white/15 bg-slate-800 text-[11px] font-semibold text-slate-200">
{step}
</span>
)}
<div
className="mb-3 flex size-11 items-center justify-center rounded-lg border"
style={{
backgroundColor: `${accent}1f`,
borderColor: `${accent}40`,
}}
>
{icon}
</div>
<h4 className="text-sm font-semibold text-white">{title}</h4>
{subtitle && <p className="mt-1 text-xs leading-5 text-slate-400">{subtitle}</p>}
{detail && (
<p className="mt-2 break-words rounded-md bg-black/30 px-2 py-1 font-mono text-[11px] leading-4 text-sky-300">
{detail}
</p>
)}
</div>
);
}
/**
* Animated dashed connector with an arrow head. Vertical on mobile and
* horizontal on lg+, unless `vertical` pins it to a top-to-bottom hand-off.
*/
export function Connector({
label,
color = "#38bdf8",
vertical = false,
}: {
label?: string;
color?: string;
vertical?: boolean;
}) {
if (vertical) {
return (
<div className="flex items-center justify-center gap-3 py-1" aria-hidden="true">
<div className="flex flex-col items-center">
<span className="flow-line-v" style={{ "--flow-color": color } as CSSProperties} />
<ChevronDown className="-mt-1.5 size-4" style={{ color }} />
</div>
{label && <span className="font-mono text-[11px] text-slate-400">{label}</span>}
</div>
);
}
return (
<div
className="flex flex-none items-center justify-center gap-2 py-1 lg:flex-col lg:gap-1 lg:px-1 lg:py-0"
aria-hidden="true"
>
{label && (
<span className="order-2 font-mono text-[11px] whitespace-nowrap text-slate-400 lg:order-0">
{label}
</span>
)}
<div className="order-1 flex flex-col items-center lg:order-0 lg:flex-row">
<span className="flow-line" style={{ "--flow-color": color } as CSSProperties} />
<ChevronDown className="-mt-1.5 size-4 lg:hidden" style={{ color }} />
<ChevronRight className="-ml-1.5 hidden size-4 lg:block" style={{ color }} />
</div>
</div>
);
}
/** Dashed container that groups nodes belonging to the same host / system. */
export function Boundary({
label,
icon,
children,
className = "",
tone = "border-white/15",
}: {
label: string;
icon: ReactNode;
children: ReactNode;
className?: string;
tone?: string;
}) {
return (
<div
className={`relative rounded-2xl border border-dashed bg-white/2 px-4 pt-7 pb-5 sm:px-6 ${tone} ${className}`}
>
<div className="absolute -top-3.5 left-5 flex items-center gap-2 rounded-full border border-white/15 bg-slate-950 px-3 py-1 text-xs font-medium text-slate-200">
{icon}
{label}
</div>
{children}
</div>
);
}