Spaces:
Sleeping
Sleeping
File size: 1,903 Bytes
05c5ed5 | 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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | "use client";
import { NodeKind } from "lib/ai/workflow/workflow.interface";
import { cn } from "lib/utils";
import {
BotIcon,
BoxIcon,
HardDriveUpload,
HouseIcon,
InfoIcon,
LandPlotIcon,
SplitIcon,
TerminalIcon,
TextIcon,
WrenchIcon,
} from "lucide-react";
import { useMemo } from "react";
export function NodeIcon({
type,
className,
iconClassName,
}: { type: NodeKind; className?: string; iconClassName?: string }) {
const Icon = useMemo(() => {
switch (type) {
case NodeKind.Input:
return HouseIcon;
case NodeKind.Output:
return LandPlotIcon;
case NodeKind.Note:
return InfoIcon;
case NodeKind.Tool:
return WrenchIcon;
case NodeKind.LLM:
return BotIcon;
case NodeKind.Condition:
return SplitIcon;
case NodeKind.Http:
return HardDriveUpload;
case NodeKind.Template:
return TextIcon;
case NodeKind.Code:
return TerminalIcon;
default:
return BoxIcon;
}
}, [type]);
return (
<div
className={cn(
type === NodeKind.Input
? "bg-blue-500"
: type === NodeKind.Output
? "bg-green-500"
: type === NodeKind.Note
? "text-foreground bg-input"
: type === NodeKind.LLM
? "bg-indigo-500"
: type === NodeKind.Tool
? "bg-blue-500"
: type === NodeKind.Code || type === NodeKind.Http
? "bg-rose-500"
: type === NodeKind.Template
? "bg-purple-500"
: type === NodeKind.Condition
? "bg-amber-500"
: "bg-card",
"p-1 rounded",
className,
)}
>
<Icon className={cn("size-4 text-white", iconClassName)} />
</div>
);
}
|