From 17739de7bd89b748cf123cbfa0d36c55cff1c109 Mon Sep 17 00:00:00 2001 From: dtoro Date: Fri, 6 Mar 2026 22:20:52 +0100 Subject: [PATCH] refactor handles --- src/components/graph/BaseHandle.tsx | 24 +++++++++++ src/components/graph/ConfigNode.tsx | 9 ++-- src/components/graph/NodeHandles.tsx | 58 ++++++++++++++++++++++++++ src/components/graph/RenderingNode.tsx | 6 +-- 4 files changed, 89 insertions(+), 8 deletions(-) create mode 100644 src/components/graph/BaseHandle.tsx create mode 100644 src/components/graph/NodeHandles.tsx diff --git a/src/components/graph/BaseHandle.tsx b/src/components/graph/BaseHandle.tsx new file mode 100644 index 0000000..33ac7c9 --- /dev/null +++ b/src/components/graph/BaseHandle.tsx @@ -0,0 +1,24 @@ +import type { ComponentProps } from "react"; +import { Handle, type HandleProps } from "@xyflow/react"; + +import { cn } from "@/lib/utils"; + +export type BaseHandleProps = HandleProps; + +export function BaseHandle({ + className, + children, + ...props +}: ComponentProps) { + return ( + + {children} + + ); +} diff --git a/src/components/graph/ConfigNode.tsx b/src/components/graph/ConfigNode.tsx index 534d710..8216520 100644 --- a/src/components/graph/ConfigNode.tsx +++ b/src/components/graph/ConfigNode.tsx @@ -1,5 +1,4 @@ import React, { memo, useCallback, useContext, useEffect, useRef, useState } from 'react' -import { Handle, Position } from 'reactflow' import Editor, { loader } from '@monaco-editor/react' import FlowContext from '../../lib/flowContext' import { @@ -22,6 +21,7 @@ import { MenubarSubTrigger, MenubarTrigger, } from '../ui/menubar' +import { InputHandle, OutputHandle } from './NodeHandles' // Ensure Monaco can load its web workers under Vite by pointing to a CDN loader.config({ paths: { vs: 'https://unpkg.com/monaco-editor@latest/min/vs' } }) @@ -201,12 +201,11 @@ export const ConfigNode = memo(function ConfigNode({ id, data }: Props) { -
Stored YAML: {storedYaml ? `${storedYaml.length} chars` : 'none'}
+
{storedYaml ? `${storedYaml.length} chars` : 'none'}
- - - + + ) }) diff --git a/src/components/graph/NodeHandles.tsx b/src/components/graph/NodeHandles.tsx new file mode 100644 index 0000000..cf77817 --- /dev/null +++ b/src/components/graph/NodeHandles.tsx @@ -0,0 +1,58 @@ +import React from 'react' +import { Handle, Position } from 'reactflow' +import { Circle, CircleDashed } from 'lucide-react' + +type NodeHandleProps = { + id: string +} + +export function InputHandle({ id }: NodeHandleProps) { + return ( + + + + ) +} + +export function OutputHandle({ id }: NodeHandleProps) { + return ( + + + + ) +} + diff --git a/src/components/graph/RenderingNode.tsx b/src/components/graph/RenderingNode.tsx index b25a18e..bb14c42 100644 --- a/src/components/graph/RenderingNode.tsx +++ b/src/components/graph/RenderingNode.tsx @@ -1,5 +1,4 @@ import { memo, useContext, useEffect, useMemo, useState } from 'react' -import { Handle, Position } from 'reactflow' import yaml from 'js-yaml' import FlowContext from '../../lib/flowContext' import { Empty, EmptyHeader, EmptyTitle, EmptyDescription, EmptyContent, EmptyMedia } from '../ui/empty' @@ -11,6 +10,7 @@ import { BaseNodeHeaderTitle, } from './BaseNode' import { Rocket } from 'lucide-react' +import { InputHandle, OutputHandle } from './NodeHandles' type Props = { id: string @@ -178,8 +178,8 @@ export const RenderingNode = memo(function RenderingNode({ id }: Props) {
Parsed YAML output
- - + + ) })