diff --git a/src/pages/VisProgPage/visualProgrammingUI/VisProgUI.css b/src/pages/VisProgPage/visualProgrammingUI/VisProgUI.css index 936f478..b853be4 100644 --- a/src/pages/VisProgPage/visualProgrammingUI/VisProgUI.css +++ b/src/pages/VisProgPage/visualProgrammingUI/VisProgUI.css @@ -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 { padding: 10px 15px; background-color: canvas; diff --git a/src/pages/VisProgPage/visualProgrammingUI/VisProgUI.tsx b/src/pages/VisProgPage/visualProgrammingUI/VisProgUI.tsx index 323ad2f..229057e 100644 --- a/src/pages/VisProgPage/visualProgrammingUI/VisProgUI.tsx +++ b/src/pages/VisProgPage/visualProgrammingUI/VisProgUI.tsx @@ -1,22 +1,22 @@ import './VisProgUI.css' import { - Background, - Controls, - Panel, - ReactFlow, - ReactFlowProvider, - MarkerType, + Background, + Controls, + Panel, + ReactFlow, + ReactFlowProvider, + MarkerType, } from '@xyflow/react'; import '@xyflow/react/dist/style.css'; import { - StartNode, - EndNode, - PhaseNode, - NormNode + StartNode, + EndNode, + PhaseNode, + NormNode } from './components/NodeDefinitions.tsx'; -import { Sidebar } from './components/DragDropSidebar.tsx'; +import {Sidebar} from './components/DragDropSidebar.tsx'; import useFlowStore from './VisProgStores.tsx'; import {useShallow} from 'zustand/react/shallow'; @@ -24,82 +24,94 @@ import type {FlowState} from './VisProgTypes.tsx'; // --| config starting params for flow |-- -const nodeTypes = { - start: StartNode, - end: EndNode, - phase: PhaseNode, - norm: NormNode +/** + * contains the types of all nodes that are available in the editor + */ +const NODE_TYPES = { + start: StartNode, + end: EndNode, + phase: PhaseNode, + norm: NormNode }; -const defaultEdgeOptions = { - type: 'default', - markerEnd: { - type: MarkerType.ArrowClosed, - color: '#505050', - }, +/** + * defines how the default edge looks inside the editor + */ +const DEFAULT_EDGE_OPTIONS = { + type: 'default', + markerEnd: { + type: MarkerType.ArrowClosed, + color: '#505050', + }, }; const selector = (state: FlowState) => ({ - nodes: state.nodes, - edges: state.edges, - onNodesChange: state.onNodesChange, - onEdgesChange: state.onEdgesChange, - onConnect: state.onConnect, - onReconnectStart: state.onReconnectStart, - onReconnectEnd: state.onReconnectEnd, - onReconnect: state.onReconnect + nodes: state.nodes, + edges: state.edges, + onNodesChange: state.onNodesChange, + onEdgesChange: state.onEdgesChange, + onConnect: state.onConnect, + onReconnectStart: state.onReconnectStart, + onReconnectEnd: state.onReconnectEnd, + onReconnect: state.onReconnect }); // --| define ReactFlow editor |-- -const VisProgUI = ()=> { +const VisProgUI = () => { + const { + nodes, edges, + onNodesChange, + onEdgesChange, + onConnect, + onReconnect, + onReconnectStart, + onReconnectEnd + } = useFlowStore(useShallow(selector)); // instructs the editor to use the corresponding functions from the FlowStore - const { nodes, edges, onNodesChange, onEdgesChange, onConnect, onReconnect, onReconnectStart, onReconnectEnd } = useFlowStore( - useShallow(selector), - ); - - return ( -