"use client"; import React from "react"; import { motion } from "framer-motion"; import { cn } from "../lib/utils"; interface Node { id: string; content: React.ReactNode; position: { x: number; y: number }; // absolute positions } interface Connection { from: string; // source node id to: string; // target node id direction?: "horizontal" | "vertical"; // optional override } interface ConnectionGraphProps { nodes: Node[]; connections: Connection[]; beamColor?: string; beamDuration?: number; // ms className?: string; } const ConnectionGraph: React.FC = ({ nodes, connections, beamColor = "#ff4500", beamDuration = 2000, className, }) => { return (
{/* Render Nodes */} {nodes.map((node) => (
{node.content}
))} {/* Render Connections */} {connections.map((conn, i) => { const from = nodes.find((n) => n.id === conn.from); const to = nodes.find((n) => n.id === conn.to); if (!from || !to) return null; const x1 = from.position.x + 56; // center offset const y1 = from.position.y + 56; const x2 = to.position.x + 56; const y2 = to.position.y + 56; const isHorizontal = Math.abs(y1 - y2) < Math.abs(x1 - x2); return ( {/* Line */} {/* Beam animation */} {/* Splash at the end */} ); })}
); }; export default ConnectionGraph;