From 9fb6fa12590609a4cd25d2e212166c61e1c23580 Mon Sep 17 00:00:00 2001
From: Sam Nystrom <sam@samnystrom.dev>
Date: Fri, 8 Mar 2024 08:09:18 +0000
Subject: Add basic toolbar

---
 src/NodeEditor.tsx | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

(limited to 'src/NodeEditor.tsx')

diff --git a/src/NodeEditor.tsx b/src/NodeEditor.tsx
index 0340a49..17e7c27 100644
--- a/src/NodeEditor.tsx
+++ b/src/NodeEditor.tsx
@@ -3,7 +3,7 @@ import { signal, computed, batch, useSignal, useComputed, Signal } from '@preact
 import { nodeRegistry } from './nodes';
 import { SocketHandlers, SocketHandler, NodeInfo } from './node.tsx';
 import { InputSocket } from './dataflow.ts';
-import { AddNodeMenu } from './AddNodeMenu.tsx';
+import { Toolbar } from './Toolbar.tsx';
 import styles from './NodeEditor.module.css';
 
 export const nodeFactory = () => {
@@ -221,9 +221,16 @@ export const NodeEditor = () => {
 		scale.value *= 1 + delta;
 	});
 
+	const onNodeAdded = (node: NodeInfo) => {
+		nodes.value = nodes.value.concat(instantiateNode(100, 100, node));
+	};
+
 	return (
 		<>
-		<AddNodeMenu nodes={nodeRegistry} onClick={node => nodes.value = nodes.value.concat(instantiateNode(100, 100, node))} />
+		<header>
+			<Toolbar nodes={nodeRegistry} onNodeAdded={onNodeAdded} />
+		</header>
+		<main>
 		<svg width="100vw" height="100vh" ref={svgRef} onMouseDown={onBgMouseDown} onWheel={onBgWheel}>
 			<pattern
 				id="bg-grid-major"
@@ -251,6 +258,7 @@ export const NodeEditor = () => {
 				</SocketHandlers.Provider>
 			</g>
 		</svg>
+		</main>
 		</>
 	);
 };
\ No newline at end of file
-- 
cgit v1.2.3

