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
72 changes: 69 additions & 3 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// * Imports *
import { useState, useCallback, useEffect, useRef, version } from 'react';

Check failure on line 2 in src/App.jsx

View workflow job for this annotation

GitHub Actions / test (20.x, 3.11)

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

Check failure on line 2 in src/App.jsx

View workflow job for this annotation

GitHub Actions / test (20.x, 3.10)

'version' is defined but never used. Allowed unused vars must match /^[A-Z_]/u
import {
ReactFlowProvider,
useReactFlow,
Expand Down Expand Up @@ -48,6 +48,7 @@
const [nodes, setNodes, onNodesChange] = useNodesState(initialNodes);
const [edges, setEdges, onEdgesChange] = useEdgesState(initialEdges);
const [selectedNode, setSelectedNode] = useState(null);
const [sidebarVisible, setSidebarVisible] = useState(true);
const [activeTab, setActiveTab] = useState('graph');
const [simulationResults, setSimulationResults] = useState(null);
const [selectedEdge, setSelectedEdge] = useState(null);
Expand Down Expand Up @@ -82,7 +83,7 @@
}, []);

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

Check failure on line 86 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 86 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 @@ -301,7 +302,7 @@
setNodes((nds) => [...nds, newNode]);
setNodeCounter((count) => count + 1);
},
[screenToFlowPosition, type, nodeCounter, fetchDefaultValues, setDefaultValues, setNodes, setNodeCounter],

Check warning on line 305 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 305 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 @@ -946,7 +947,7 @@
return () => {
document.removeEventListener('keydown', handleKeyDown);
};
}, [selectedEdge, selectedNode, copiedNode, duplicateNode, setCopyFeedback]);

Check warning on line 950 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 950 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 All @@ -957,9 +958,74 @@
{/* Graph Editor Tab */}
{activeTab === 'graph' && (
<div style={{ display: 'flex', flex: 1, height: 'calc(100vh - 50px)', overflow: 'hidden' }}>
<div style={{ width: 250, height: '100%', borderRight: '1px solid #ccc' }}>
<Sidebar />
</div>
{/* Sidebar Toggle Button */}
<button
onClick={() => setSidebarVisible(!sidebarVisible)}
style={{
position: 'absolute',
top: '60px',
left: sidebarVisible ? '240px' : '10px',
zIndex: 1000,
backgroundColor: '#2c2c54',
color: '#ffffff',
border: '1px solid #555',
borderRadius: '4px',
width: '32px',
height: '32px',
cursor: 'pointer',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
transition: 'left 0.3s ease',
boxShadow: '0 2px 4px rgba(0,0,0,0.3)',
padding: '4px'
}}
onMouseEnter={(e) => {
e.target.style.backgroundColor = '#3c3c64';
e.target.style.borderColor = '#78A083';
}}
onMouseLeave={(e) => {
e.target.style.backgroundColor = '#2c2c54';
e.target.style.borderColor = '#555';
}}
title={sidebarVisible ? 'Hide Sidebar' : 'Show Sidebar'}
>
<svg
width="20"
height="20"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
{sidebarVisible ? (
// Hide sidebar icon (sidebar with left arrow)
<>
<rect x="2" y="3" width="6" height="18" rx="1" fill="currentColor" opacity="0.3" />
<rect x="10" y="3" width="12" height="18" rx="1" stroke="currentColor" strokeWidth="1.5" fill="none" />
<path d="M6 12L4 10M6 12L4 14M6 12H1" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
</>
) : (
// Show sidebar icon (sidebar with right arrow)
<>
<rect x="2" y="3" width="6" height="18" rx="1" stroke="currentColor" strokeWidth="1.5" fill="none" />
<rect x="10" y="3" width="12" height="18" rx="1" stroke="currentColor" strokeWidth="1.5" fill="none" />
<path d="M5 12L7 10M5 12L7 14M5 12H10" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
</>
)}
</svg>
</button>

{/* Sidebar */}
{sidebarVisible && (
<div style={{
width: 250,
height: '100%',
borderRight: '1px solid #ccc',
transition: 'width 0.3s ease'
}}>
<Sidebar />
</div>
)}

<GraphView
refEl={ref}
Expand Down
6 changes: 3 additions & 3 deletions src/components/GraphView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function FloatingButtons({
<button
style={{
position: 'absolute',
left: 20,
left: 50,
top: 70,
zIndex: 10,
padding: '8px 12px',
Expand All @@ -75,7 +75,7 @@ function FloatingButtons({
<button
style={{
position: 'absolute',
left: 20,
left: 50,
top: 120,
zIndex: 10,
padding: '8px 12px',
Expand Down Expand Up @@ -127,7 +127,7 @@ function FloatingButtons({
<button
style={{
position: 'absolute',
left: 20,
left: 50,
top: 20,
zIndex: 10,
padding: '8px 12px',
Expand Down
12 changes: 10 additions & 2 deletions src/components/Sidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { useDnD } from './DnDContext';
import { nodeCategories, getNodeDisplayName } from '../nodeConfig.js';

export default () => {

Check warning on line 5 in src/components/Sidebar.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 5 in src/components/Sidebar.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
const [_, setType] = useDnD();
const [expandedCategories, setExpandedCategories] = useState({
'Sources': false,
Expand Down Expand Up @@ -110,7 +110,9 @@
cursor: 'grab',
fontSize: '13px',
transition: 'all 0.2s ease',
display: 'block'
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between'
}}
onMouseEnter={(e) => {
const currentBg = window.getComputedStyle(e.target).backgroundColor;
Expand All @@ -136,7 +138,13 @@
e.target.style.cursor = 'grab';
}}
>
{getNodeDisplayName(nodeType)}
<span>{getNodeDisplayName(nodeType)}</span>
<span style={{
fontSize: '12px',
color: '#888',
}}>
⋮⋮
</span>
</div>
))}
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/styles/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ aside .description {
}

.dndnode {
height: 50px;
height: 15px;
padding: 10px;
border: 1px solid #78A083;
border-radius: 5px;
Expand Down
Loading