Merging dev into main #49

Merged
8464960 merged 260 commits from dev into main 2026-01-28 10:48:52 +00:00
2 changed files with 112 additions and 69 deletions
Showing only changes of commit f6fcd20462 - Show all commits

View File

@@ -1,3 +1,34 @@
/* editor UI */
.outer-editor-container {
margin-inline: auto;
display: flex;
justify-self: center;
padding: 10px;
align-items: center;
width: 80vw;
height: 80vh;
}
.inner-editor-container {
outline-style: solid;
border-radius: 10pt;
width: 90%;
height: 100%;
}
.dnd-panel {
margin-inline-start: auto;
margin-inline-end: auto;
background-color: canvas;
margin-bottom: 0.5rem;
margin-top:auto;
width: 50%;
height:7%;
}
/* Node Styles */
.default-node { .default-node {
padding: 10px 15px; padding: 10px 15px;
background-color: canvas; background-color: canvas;

View File

@@ -16,7 +16,7 @@ import {
NormNode NormNode
} from './components/NodeDefinitions.tsx'; } from './components/NodeDefinitions.tsx';
import { Sidebar } from './components/DragDropSidebar.tsx'; import {Sidebar} from './components/DragDropSidebar.tsx';
import useFlowStore from './VisProgStores.tsx'; import useFlowStore from './VisProgStores.tsx';
import {useShallow} from 'zustand/react/shallow'; import {useShallow} from 'zustand/react/shallow';
@@ -24,14 +24,20 @@ import type {FlowState} from './VisProgTypes.tsx';
// --| config starting params for flow |-- // --| config starting params for flow |--
const nodeTypes = { /**
* contains the types of all nodes that are available in the editor
*/
const NODE_TYPES = {
start: StartNode, start: StartNode,
end: EndNode, end: EndNode,
phase: PhaseNode, phase: PhaseNode,
norm: NormNode norm: NormNode
}; };
const defaultEdgeOptions = { /**
* defines how the default edge looks inside the editor
*/
const DEFAULT_EDGE_OPTIONS = {
type: 'default', type: 'default',
markerEnd: { markerEnd: {
type: MarkerType.ArrowClosed, type: MarkerType.ArrowClosed,
@@ -52,20 +58,25 @@ const selector = (state: FlowState) => ({
// --| define ReactFlow editor |-- // --| define ReactFlow editor |--
const VisProgUI = ()=> { const VisProgUI = () => {
const {
const { nodes, edges, onNodesChange, onEdgesChange, onConnect, onReconnect, onReconnectStart, onReconnectEnd } = useFlowStore( nodes, edges,
useShallow(selector), onNodesChange,
); onEdgesChange,
onConnect,
onReconnect,
onReconnectStart,
onReconnectEnd
} = useFlowStore(useShallow(selector)); // instructs the editor to use the corresponding functions from the FlowStore
return ( return (
<div style={{marginInline: 'auto',display: 'flex',justifySelf: 'center', padding:'10px', alignItems: 'center', width: '80vw', height: '80vh'}}> <div className={'outer-editor-container'}>
<div style={{outlineStyle: 'solid', borderRadius: '10pt',width: '90%', height:'100%' }}> <div className={'inner-editor-container'}>
<ReactFlow <ReactFlow
nodes={nodes} nodes={nodes}
edges={edges} edges={edges}
defaultEdgeOptions={defaultEdgeOptions} defaultEdgeOptions={DEFAULT_EDGE_OPTIONS}
nodeTypes={nodeTypes} nodeTypes={NODE_TYPES}
onNodesChange={onNodesChange} onNodesChange={onNodesChange}
onEdgesChange={onEdgesChange} onEdgesChange={onEdgesChange}
onReconnect={onReconnect} onReconnect={onReconnect}
@@ -74,13 +85,13 @@ const VisProgUI = ()=> {
onConnect={onConnect} onConnect={onConnect}
snapToGrid snapToGrid
fitView fitView
proOptions={{hideAttribution: true }} proOptions={{hideAttribution: true}}
> >
<Panel position="top-center" style={{marginInlineStart: 'auto', marginInlineEnd:'auto',backgroundColor: 'canvas' ,marginBottom: '0.5rem', marginTop:'auto', width: '50%', height:'7%'}}> <Panel position="top-center" className={'dnd-panel'}>
<Sidebar /> <Sidebar/> {/* contains the drag and drop panel for nodes */}
</Panel> </Panel>
<Controls /> <Controls/>
<Background /> <Background/>
</ReactFlow> </ReactFlow>
</div> </div>
</div> </div>
@@ -88,16 +99,17 @@ const VisProgUI = ()=> {
}; };
/* --| Places the VisProgUI component inside a ReactFlowProvider /**
* Places the VisProgUI component inside a ReactFlowProvider
* *
* Wrapping the editor component inside a ReactFlowProvider * Wrapping the editor component inside a ReactFlowProvider
* allows us to access and interact with the components inside the editor, outside the editor definition, * allows us to access and interact with the components inside the editor, outside the editor definition,
* thus facilitating the addition of node specific functions inside their node definitions * thus facilitating the addition of node specific functions inside their node definitions
*/ */
function VisualProgrammingUI(){ function VisualProgrammingUI() {
return ( return (
<ReactFlowProvider> <ReactFlowProvider>
<VisProgUI /> <VisProgUI/>
</ReactFlowProvider> </ReactFlowProvider>
); );
} }