diff --git a/chainforge/react-server/src/DraggablePopover.tsx b/chainforge/react-server/src/DraggablePopover.tsx new file mode 100644 index 000000000..3f60f1d87 --- /dev/null +++ b/chainforge/react-server/src/DraggablePopover.tsx @@ -0,0 +1,152 @@ +import { + Popover, + Badge, + Text, + Textarea, + NumberInput, + Button, + Stack, +} from "@mantine/core"; +import { IconBulb } from "@tabler/icons-react"; +import { useState, CSSProperties } from "react"; + +interface MarkerPopoverProps { + anchor: { x: number; y: number }; + preview: string; + context: string; + setContext: (s: string) => void; + variants: string; + setVariants: (v: string) => void; + onGenerate: () => void; + loading?: boolean; + nodeType?: "textfields" | "prompt" | "chat"; +} + +export default function MarkerPopover({ + anchor, + preview, + context, + setContext, + variants, + setVariants, + onGenerate, + loading = false, + nodeType = "textfields", +}: MarkerPopoverProps) { + const [open, setOpen] = useState(false); + + const bulbStyle: CSSProperties = { + position: "fixed", + top: anchor.y, + left: anchor.x, + zIndex: 10_000, + }; + + const getLabels = () => { + switch (nodeType) { + case "prompt": + return { + title: "PROMPT CONFIGURATION", + contextLabel: "Prompt context", + variantsLabel: "Prompt variants to generate", + }; + case "chat": + return { + title: "CHAT CONFIGURATION", + contextLabel: "Chat context", + variantsLabel: "Response variants to generate", + }; + default: + return { + title: "FIELD CONFIGURATION", + contextLabel: "Extra configuration", + variantsLabel: "Variants to generate", + }; + } + }; + + const labels = getLabels(); + + return ( + + + + + + + } + > + {labels.title} + + + {preview && ( + + "{preview}" + + )} + + +
+ + {labels.contextLabel} + +