logic-node.tsx

Overview

The logic-node.tsx file defines a React functional component named LogicNode that represents a visual node element within a flowchart or diagramming interface. This component is designed to work within a node-based flow system, rendering a node with connection handles on its left and right sides to facilitate linking with other nodes. It incorporates theming support (light/dark modes), selection styling, and displays a header with node information.

This component is intended to be used within a larger flow or graph rendering framework, likely powered by @xyflow/react, where users can visually create or manipulate logical nodes as part of a flow design or logic modeling tool.


Detailed Explanation

Imports and Dependencies


LogicNode Component

export function LogicNode({
  id,
  data,
  isConnectable = true,
  selected,
}: NodeProps<ILogicNode>) { ... }

Description

LogicNode is a React functional component that renders a styled node element with two connection handles and a header displaying the node's name and label.

Parameters

Return Value

Usage Example

<LogicNode
  id="node-1"
  data={{ name: 'Logic A', label: 'AND Gate' }}
  isConnectable={true}
  selected={false}
/>

This renders a logic node labeled "AND Gate" with two handles for connections, styled according to the current theme and not selected.


Implementation Details


Interaction with Other Parts of the System


Visual Diagram

classDiagram
    class LogicNode {
        +id: string
        +data: ILogicNode
        +isConnectable: boolean
        +selected: boolean
        +LogicNode(props: NodeProps<ILogicNode>)
    }

    class NodeHeader {
        +id: string
        +name: string
        +label: string
    }

    class Handle {
        +id: string
        +type: "source" | "target"
        +position: Position
        +isConnectable: boolean
        +className: string
        +style: React.CSSProperties
    }

    LogicNode --> NodeHeader : renders
    LogicNode --> Handle : renders (2 instances)

Summary

The logic-node.tsx file provides a reusable React component that visually represents a logic node within a graphical flow editor UI. It integrates connection handles to link nodes, supports theming and selection styling, and cleanly separates node header rendering to a dedicated component. It leverages external libraries for flow management and theming and is styled with CSS modules for maintainability.

This component plays a crucial role in enabling users to create and manipulate logical nodes visually, forming part of a larger system for flow-based programming, workflow design, or logic modeling.