import type { ReactNode } from 'react'; import { Icon } from './Icon'; export type FlowNode = { id: string; label: ReactNode; sub?: ReactNode }; /** * Lightweight architecture / data-flow diagram rendered as a token-styled * node chain (no SVG layout engine). For freeform diagrams, pass children * instead and lay them out with flex/grid. */ export function Diagram({ nodes, direction = 'row', caption, children, }: { nodes?: FlowNode[]; direction?: 'row' | 'col'; caption?: string; children?: ReactNode; }) { const isRow = direction === 'row'; return (
{caption &&
{caption}
} {nodes ? (
{nodes.map((n, i) => (
{n.label}
{n.sub &&
{n.sub}
}
{i < nodes.length - 1 && ( )}
))}
) : children}
); }