Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import { nodeTypes, nodeDynamicHandles } from './nodeConfig.js';
import LogDock from './components/LogDock.jsx';

import { createFunctionNode } from './components/nodes/FunctionNode.jsx';

Check failure on line 27 in src/App.jsx

View workflow job for this annotation

GitHub Actions / test (20.x, 3.11)

'createFunctionNode' is defined but never used. Allowed unused vars must match /^[A-Z_]/u

Check failure on line 27 in src/App.jsx

View workflow job for this annotation

GitHub Actions / test (20.x, 3.10)

'createFunctionNode' is defined but never used. Allowed unused vars must match /^[A-Z_]/u

// * Declaring variables *

Expand Down Expand Up @@ -70,7 +70,7 @@
}, []);

const onDragStart = (event, nodeType) => {
setType(nodeType);

Check failure on line 73 in src/App.jsx

View workflow job for this annotation

GitHub Actions / test (20.x, 3.11)

'setType' is not defined

Check failure on line 73 in src/App.jsx

View workflow job for this annotation

GitHub Actions / test (20.x, 3.10)

'setType' is not defined
event.dataTransfer.setData('text/plain', nodeType);
event.dataTransfer.effectAllowed = 'move';
};
Expand Down Expand Up @@ -272,7 +272,10 @@
}

// Create node data with label and initialize all expected fields as empty strings
let nodeData = { label: `${type} ${newNodeId}` };
let nodeData = {
label: `${type} ${newNodeId}`,
nodeColor: '#DDE6ED' // Default node color
};

// if node in nodeDynamicHandles, ensure add outputCount and inputCount to data
if (nodeDynamicHandles.includes(type)) {
Expand All @@ -295,7 +298,7 @@
setNodes((nds) => [...nds, newNode]);
setNodeCounter((count) => count + 1);
},
[screenToFlowPosition, type, nodeCounter, fetchDefaultValues, setDefaultValues, setNodes, setNodeCounter],

Check warning on line 301 in src/App.jsx

View workflow job for this annotation

GitHub Actions / test (20.x, 3.11)

React Hook useCallback has an unnecessary dependency: 'setDefaultValues'. Either exclude it or remove the dependency array

Check warning on line 301 in src/App.jsx

View workflow job for this annotation

GitHub Actions / test (20.x, 3.10)

React Hook useCallback has an unnecessary dependency: 'setDefaultValues'. Either exclude it or remove the dependency array
);

// Function to save a graph to computer with "Save As" dialog
Expand Down Expand Up @@ -386,7 +389,7 @@
return;
}

// Load the graph data
// Load the graph data and ensure nodeColor exists on all nodes
const {
nodes: loadedNodes,
edges: loadedEdges,
Expand All @@ -396,7 +399,17 @@
events: loadedEvents,
pythonCode: loadedPythonCode
} = graphData;
setNodes(loadedNodes || []);

// Ensure all loaded nodes have a nodeColor property
const nodesWithColors = (loadedNodes || []).map(node => ({
...node,
data: {
...node.data,
nodeColor: node.data.nodeColor || '#DDE6ED'
}
}));

setNodes(nodesWithColors);
setEdges(loadedEdges || []);
setSelectedNode(null);
setNodeCounter(loadedNodeCounter ?? loadedNodes.length);
Expand Down Expand Up @@ -457,7 +470,17 @@
events: loadedEvents,
pythonCode: loadedPythonCode
} = graphData;
setNodes(loadedNodes || []);

// Ensure all loaded nodes have a nodeColor property
const nodesWithColors = (loadedNodes || []).map(node => ({
...node,
data: {
...node.data,
nodeColor: node.data.nodeColor || '#DDE6ED'
}
}));

setNodes(nodesWithColors);
setEdges(loadedEdges || []);
setSelectedNode(null);
setNodeCounter(loadedNodeCounter ?? loadedNodes.length);
Expand Down Expand Up @@ -677,9 +700,9 @@
const es = new EventSource(getApiEndpoint('/logs/stream'));
sseRef.current = es;

es.addEventListener('start', () => append('log stream connected…'));

Check failure on line 703 in src/App.jsx

View workflow job for this annotation

GitHub Actions / test (20.x, 3.11)

'append' is not defined

Check failure on line 703 in src/App.jsx

View workflow job for this annotation

GitHub Actions / test (20.x, 3.10)

'append' is not defined
es.onmessage = (evt) => append(evt.data);

Check failure on line 704 in src/App.jsx

View workflow job for this annotation

GitHub Actions / test (20.x, 3.11)

'append' is not defined

Check failure on line 704 in src/App.jsx

View workflow job for this annotation

GitHub Actions / test (20.x, 3.10)

'append' is not defined
es.onerror = () => { append('log stream error'); es.close(); sseRef.current = null; };

Check failure on line 705 in src/App.jsx

View workflow job for this annotation

GitHub Actions / test (20.x, 3.11)

'append' is not defined

Check failure on line 705 in src/App.jsx

View workflow job for this annotation

GitHub Actions / test (20.x, 3.10)

'append' is not defined

try {
const graphData = {
Expand Down Expand Up @@ -1032,7 +1055,7 @@
return () => {
document.removeEventListener('keydown', handleKeyDown);
};
}, [selectedEdge, selectedNode, copiedNode, duplicateNode, setCopyFeedback]);

Check warning on line 1058 in src/App.jsx

View workflow job for this annotation

GitHub Actions / test (20.x, 3.11)

React Hook useEffect has missing dependencies: 'deleteSelectedEdge' and 'deleteSelectedNode'. Either include them or remove the dependency array

Check warning on line 1058 in src/App.jsx

View workflow job for this annotation

GitHub Actions / test (20.x, 3.10)

React Hook useEffect has missing dependencies: 'deleteSelectedEdge' and 'deleteSelectedNode'. Either include them or remove the dependency array

return (
<div style={{ width: '100vw', height: '100vh', display: 'flex', flexDirection: 'column' }}>
Expand Down
133 changes: 130 additions & 3 deletions src/components/NodeSidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,10 @@ const NodeSidebar = ({
const nodeDefaults = defaultValues[selectedNode.type] || {};

// Create a list of all possible parameters (both current data and defaults)
// Exclude 'label' since it's now editable directly in the title
// Exclude 'label' and 'nodeColor' since they're handled separately
const allParams = new Set([
...Object.keys(selectedNode.data).filter(key => key !== 'label'),
...Object.keys(nodeDefaults).filter(key => key !== 'label')
...Object.keys(selectedNode.data).filter(key => key !== 'label' && key !== 'nodeColor'),
...Object.keys(nodeDefaults).filter(key => key !== 'label' && key !== 'nodeColor')
]);

return Array.from(allParams)
Expand Down Expand Up @@ -212,6 +212,133 @@ const NodeSidebar = ({
});
})()}

{/* Color Picker Section */}
<div style={{
marginTop: '20px',
marginBottom: '20px',
borderTop: '1px solid #555',
paddingTop: '15px'
}}>
<h4 style={{
margin: '0 0 12px 0',
fontSize: '14px',
fontWeight: '600',
color: '#a8b3cf',
textTransform: 'uppercase',
letterSpacing: '0.5px'
}}>Node Color</h4>

<div style={{
display: 'flex',
alignItems: 'center',
gap: '12px',
marginBottom: '8px'
}}>
<input
type="color"
value={selectedNode.data.nodeColor || '#DDE6ED'}
onChange={(e) => {
const newColor = e.target.value;
const updatedNode = {
...selectedNode,
data: { ...selectedNode.data, nodeColor: newColor },
};

setNodes((nds) =>
nds.map((node) =>
node.id === selectedNode.id ? updatedNode : node
)
);
setSelectedNode(updatedNode);
}}
style={{
width: '40px',
height: '40px',
borderRadius: '6px',
border: '2px solid #555',
backgroundColor: 'transparent',
cursor: 'pointer',
padding: '0'
}}
/>

<input
type="text"
value={selectedNode.data.nodeColor || '#DDE6ED'}
onChange={(e) => {
const newColor = e.target.value;
const updatedNode = {
...selectedNode,
data: { ...selectedNode.data, nodeColor: newColor },
};

setNodes((nds) =>
nds.map((node) =>
node.id === selectedNode.id ? updatedNode : node
)
);
setSelectedNode(updatedNode);
}}
placeholder="#DDE6ED"
style={{
flex: 1,
padding: '8px 12px',
borderRadius: '4px',
border: '1px solid #555',
backgroundColor: '#2a2a3e',
color: '#ffffff',
fontSize: '14px',
fontFamily: 'monospace'
}}
/>
</div>

{/* Color preset buttons */}
<div style={{
display: 'grid',
gridTemplateColumns: 'repeat(4, 1fr)',
gap: '8px',
marginTop: '12px'
}}>
{['#DDE6ED', '#FFE5E5', '#E5F3FF', '#E5FFE5', '#FFF5E5', '#F0E5FF', '#FFE5F5', '#E5FFFF'].map(color => (
<button
key={color}
onClick={() => {
const updatedNode = {
...selectedNode,
data: { ...selectedNode.data, nodeColor: color },
};

setNodes((nds) =>
nds.map((node) =>
node.id === selectedNode.id ? updatedNode : node
)
);
setSelectedNode(updatedNode);
}}
style={{
width: '100%',
height: '30px',
backgroundColor: color,
border: selectedNode.data.nodeColor === color ? '2px solid #007bff' : '1px solid #666',
borderRadius: '4px',
cursor: 'pointer',
transition: 'all 0.2s ease'
}}
onMouseEnter={(e) => {
if (selectedNode.data.nodeColor !== color) {
e.target.style.transform = 'scale(1.05)';
}
}}
onMouseLeave={(e) => {
e.target.style.transform = 'scale(1)';
}}
title={color}
/>
))}
</div>
</div>

<br />
<button
style={{
Expand Down
2 changes: 1 addition & 1 deletion src/components/nodes/AdderNode.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default function AdderNode({ data }) {
style={{
width: 60,
height: 60,
background: '#DDE6ED',
background: data.nodeColor || '#DDE6ED',
color: 'black',
borderRadius: '50%',
display: 'flex',
Expand Down
4 changes: 2 additions & 2 deletions src/components/nodes/AmplifierNode.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function AmplifierNode({ data }) {
>

<svg width="100%" height="100%" viewBox="0 0 100 100" preserveAspectRatio="none">
<polygon points="0,0 100,50 0,100" fill="#DDE6ED" />
<polygon points="0,0 100,50 0,100" fill={data.nodeColor || "#DDE6ED"} />
</svg>
<div style={{
fontSize: '12px',
Expand Down Expand Up @@ -50,7 +50,7 @@ export function AmplifierNodeReverse({ data }) {
>

<svg width="100%" height="100%" viewBox="0 0 100 100" preserveAspectRatio="none">
<polygon points="0,50 100,100 100,0" fill="#DDE6ED" />
<polygon points="0,50 100,100 100,0" fill={data.nodeColor || "#DDE6ED"} />
</svg>
<div style={{
fontSize: '12px',
Expand Down
2 changes: 1 addition & 1 deletion src/components/nodes/BubblerNode.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default function BubblerNode({ data }) {
style={{
width: 210,
height: 140,
background: '#DDE6ED',
background: data.nodeColor || '#DDE6ED',
color: 'black',
borderRadius: 8,
padding: 10,
Expand Down
2 changes: 1 addition & 1 deletion src/components/nodes/ConstantNode.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default function ConstantNode({ data }) {
<div
style={{
width: 180,
background: '#DDE6ED',
background: data.nodeColor || '#DDE6ED',
color: 'black',
borderRadius: 12,
padding: 10,
Expand Down
2 changes: 1 addition & 1 deletion src/components/nodes/DefaultNode.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default function DefaultNode({ data }) {
<div
style={{
width: 180,
background: '#DDE6ED',
background: data.nodeColor || '#DDE6ED',
color: 'black',
borderRadius: 0,
padding: 10,
Expand Down
2 changes: 1 addition & 1 deletion src/components/nodes/DelayNode.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default function DelayNode({ data }) {
style={{
width: 80,
height: 60,
background: '#DDE6ED',
background: data.nodeColor || '#DDE6ED',
color: 'black',
borderRadius: 8,
padding: 8,
Expand Down
2 changes: 1 addition & 1 deletion src/components/nodes/DynamicHandleNode.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback, useState, useEffect } from 'react';

Check failure on line 1 in src/components/nodes/DynamicHandleNode.jsx

View workflow job for this annotation

GitHub Actions / test (20.x, 3.11)

'useCallback' is defined but never used. Allowed unused vars must match /^[A-Z_]/u

Check failure on line 1 in src/components/nodes/DynamicHandleNode.jsx

View workflow job for this annotation

GitHub Actions / test (20.x, 3.10)

'useCallback' is defined but never used. Allowed unused vars must match /^[A-Z_]/u
import { Handle, useUpdateNodeInternals } from '@xyflow/react';

export function DynamicHandleNode({ id, data }) {
Expand Down Expand Up @@ -31,7 +31,7 @@
style={{
width: Math.max(180, (data.label?.length || 8) * 8 + 40),
height: Math.max(60, Math.max(inputHandleCount, outputHandleCount) * 25 + 30),
background: '#DDE6ED',
background: data.nodeColor || '#DDE6ED',
color: 'black',
borderRadius: 0,
padding: 10,
Expand Down
2 changes: 1 addition & 1 deletion src/components/nodes/FunctionNode.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
style={{
width: dynamicWidth,
height: dynamicHeight,
background: '#DDE6ED',
background: data.nodeColor || '#DDE6ED',
color: 'black',
borderRadius: 0,
padding: 10,
Expand All @@ -122,4 +122,4 @@
}

// Default FunctionNode with 1 input and 1 output
export default createFunctionNode(1, 1);

Check warning on line 125 in src/components/nodes/FunctionNode.jsx

View workflow job for this annotation

GitHub Actions / test (20.x, 3.11)

Fast refresh can't handle anonymous components. Add a name to your export

Check warning on line 125 in src/components/nodes/FunctionNode.jsx

View workflow job for this annotation

GitHub Actions / test (20.x, 3.10)

Fast refresh can't handle anonymous components. Add a name to your export
2 changes: 1 addition & 1 deletion src/components/nodes/IntegratorNode.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function IntegratorNode({ data }) {
<div
style={{
width: 180,
background: '#DDE6ED',
background: data.nodeColor || '#DDE6ED',
color: 'black',
borderRadius: 0,
padding: 10,
Expand Down
2 changes: 1 addition & 1 deletion src/components/nodes/MultiplierNode.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default function MultiplierNode({ data }) {
style={{
width: 60,
height: 60,
background: '#DDE6ED',
background: data.nodeColor || '#DDE6ED',
color: 'black',
borderRadius: '50%',
display: 'flex',
Expand Down
4 changes: 2 additions & 2 deletions src/components/nodes/ProcessNode.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export function ProcessNode({ data }) {
style={{
width: 180,
height: 100,
background: '#DDE6ED',
background: data.nodeColor || '#DDE6ED',
color: 'black',
borderRadius: 12,
padding: 10,
Expand Down Expand Up @@ -55,7 +55,7 @@ export function ProcessNodeHorizontal({ data }) {
style={{
width: 100,
height: 180,
background: '#DDE6ED',
background: data.nodeColor || '#DDE6ED',
color: 'black',
borderRadius: 12,
padding: 10,
Expand Down
2 changes: 1 addition & 1 deletion src/components/nodes/ScopeNode.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default function ScopeNode({ data }) {
style={{
width: 100,
height: 120,
background: '#DDE6ED',
background: data.nodeColor || '#DDE6ED',
color: 'black',
borderRadius: 12,
padding: 10,
Expand Down
4 changes: 2 additions & 2 deletions src/components/nodes/Splitters.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export function Splitter2Node({ data }) {
style={{
width: 100,
height: 100,
background: '#DDE6ED',
background: data.nodeColor || '#DDE6ED',
color: 'black',
borderRadius: 0,
padding: 10,
Expand Down Expand Up @@ -88,7 +88,7 @@ export function Splitter3Node({ data }) {
style={{
width: 100,
height: 100,
background: '#DDE6ED',
background: data.nodeColor || '#DDE6ED',
color: 'black',
borderRadius: 0,
padding: 10,
Expand Down
2 changes: 1 addition & 1 deletion src/components/nodes/StepSourceNode.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default function StepSourceNode({ data }) {
style={{
width: 100,
height: 100,
background: '#DDE6ED',
background: data.nodeColor || '#DDE6ED',
color: 'black',
borderRadius: 12,
padding: 10,
Expand Down
2 changes: 1 addition & 1 deletion src/components/nodes/WallNode.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default function WallNode({ data }) {
style={{
width: 50,
height: 180,
background: '#DDE6ED',
background: data.nodeColor || '#DDE6ED',
color: 'black',
borderRadius: 0,
padding: 10,
Expand Down
Loading