Spaces:
Sleeping
Sleeping
File size: 1,394 Bytes
9081dbe 7061b92 9081dbe | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | import { Handle, Position, type NodeProps, type Node } from '@xyflow/react';
import { clsx } from 'clsx';
import { CheckCircle2, Circle, Clock } from 'lucide-react';
type NodeData = {
label: string;
status: 'pending' | 'in_progress' | 'completed';
description?: string;
links?: { title: string; url: string }[];
};
// We need to extend NodeProps to include our specific data type
export function CustomNode({ data }: NodeProps<Node<NodeData>>) {
const statusColors = {
pending: 'bg-gray-100 border-gray-300 text-gray-500',
in_progress: 'bg-blue-50 border-blue-400 text-blue-700',
completed: 'bg-green-50 border-green-400 text-green-700',
};
const status = (data.status as keyof typeof statusColors) || 'pending';
const StatusIcon = {
pending: Circle,
in_progress: Clock,
completed: CheckCircle2,
}[status];
return (
<div className={clsx(
"px-4 py-2 rounded-lg border-2 shadow-sm min-w-[150px] transition-all bg-white",
statusColors[status]
)}>
<Handle type="target" position={Position.Top} className="w-3 h-3 !bg-gray-400" />
<div className="flex items-center gap-2">
<StatusIcon className="w-4 h-4" />
<span className="font-medium text-sm">{data.label}</span>
</div>
<Handle type="source" position={Position.Bottom} className="w-3 h-3 !bg-gray-400" />
</div>
);
}
|