toolbar.tsx


Overview

The toolbar.tsx file defines a React functional component named ToolBar that provides an interactive toolbar interface for nodes within a graphical flow or editor. It offers common node actions such as running, duplicating, and deleting nodes, presented as icon buttons within a tooltip overlay.

This component is designed to be used in a node-based graph editor UI, integrating closely with the application’s graph state management and custom hooks for duplicating and deleting nodes. The toolbar's UI is rendered as a tooltip that appears when interacting with a node, enabling quick access to node-specific operations.


Exports

ToolBar Component

Description

ToolBar is the main exported React component from this file. It renders a set of icon buttons inside a tooltip associated with a node. It supports:

It uses internal hooks and global state store functions to perform these actions.

Props

Prop

Type

Description

Default

selected

[boolean \

undefined](/projects/311/74002)

Indicates if the node is currently selected, affecting tooltip styling

label

string

The label/type of the node, used to differentiate deletion logic

id

string

Unique identifier of the node to perform actions on

showRun

boolean

Whether to show the run/play icon button

true

children

React.ReactNode

The node's visual element triggering the tooltip

required

Usage Example

<ToolBar selected={true} label="Iteration" id="node-123" showRun={false}>
  <NodeVisualElement />
</ToolBar>

Behavior


Internal Components and Functions

IconWrapper Component

A simple presentational wrapper component that styles the icon buttons consistently.

Props

Usage

Wraps icons (Play, Copy, Trash2) to provide padding, background color, rounded corners, and cursor styling.

<IconWrapper onClick={handleDuplicate}>
  <Copy className="size-3.5" />
</IconWrapper>

Imports and Dependencies


Implementation Details


Interaction with Other Parts of the System


Visual Diagram: Component Structure and Interaction

componentDiagram
    direction LR
    ToolBar -- uses --> TooltipNode
    TooltipNode -- contains --> TooltipTrigger
    TooltipNode -- contains --> TooltipContent
    TooltipContent -- contains --> IconWrapper
    IconWrapper -- wraps --> Play
    IconWrapper -- wraps --> Copy
    IconWrapper -- wraps --> Trash2
    ToolBar -- uses --> useGraphStore
    ToolBar -- uses --> useDuplicateNode

Summary

The toolbar.tsx file provides a focused UI component enabling common node actions in a graph editor context. It combines reusable UI primitives (tooltips and icons), application state management (graph store and duplication hooks), and conditional logic to cater to different node types. This modular design promotes maintainability and clear separation of concerns within the node editor system.


If you need further details on the related hooks or store implementations (useDuplicateNode, useGraphStore), or on the tooltip components, those would be found in other files in the project.