feat: updated styles of visProgUI

Added a rounded outline to the editor and changed the edge to be an arrow so program-flow can be interpreted more easily from the UI.

ref: N25B-114
This commit is contained in:
JGerla
2025-09-30 15:20:16 +02:00
parent 0eb5b65f67
commit 10e5db057b

View File

@@ -11,16 +11,28 @@ import {
useNodesState, useNodesState,
useEdgesState, useEdgesState,
reconnectEdge, reconnectEdge,
addEdge, type Edge, type Connection, addEdge,
MarkerType,
type Edge,
type Connection,
} from '@xyflow/react'; } from '@xyflow/react';
import '@xyflow/react/dist/style.css'; import '@xyflow/react/dist/style.css';
const initialNodes = [ const initialNodes = [
{id: 'n1', position: {x: 0, y: 0}, data: {label: 'Node 1'}}, {id: 'n1', position: {x: 0, y: 0}, data: {label: 'Start'}},
{id: 'n2', position: {x: 0, y: 100}, data: {label: 'Node 2'}}, {id: 'n2', position: {x: 0, y: 100}, data: {label: 'End'}},
]; ];
const initialEdges = [{id: 'n1-n2', source: 'n1', target: 'n2'}]; const initialEdges = [{id: 'n1-n2', source: 'n1', target: 'n2'}];
const defaultEdgeOptions = {
type: 'floating',
markerEnd: {
type: MarkerType.ArrowClosed,
color: '#505050',
},
};
const VisualProgrammingUI = ()=> { const VisualProgrammingUI = ()=> {
const edgeReconnectSuccessful = useRef(true); const edgeReconnectSuccessful = useRef(true);
const [nodes, , onNodesChange] = useNodesState(initialNodes); const [nodes, , onNodesChange] = useNodesState(initialNodes);
@@ -51,10 +63,11 @@ const VisualProgrammingUI = ()=> {
}, [setEdges]); }, [setEdges]);
return ( return (
<div style={{ width: '90vw', height: '90vh' }}> <div style={{outlineStyle: 'solid', borderRadius: '10pt' ,marginInline: 'auto',width: '60vw', height: '60vh' }}>
<ReactFlow <ReactFlow
nodes={nodes} nodes={nodes}
edges={edges} edges={edges}
defaultEdgeOptions={defaultEdgeOptions}
onNodesChange={onNodesChange} onNodesChange={onNodesChange}
onEdgesChange={onEdgesChange} onEdgesChange={onEdgesChange}
snapToGrid snapToGrid
@@ -63,7 +76,7 @@ const VisualProgrammingUI = ()=> {
onReconnectEnd={onReconnectEnd} onReconnectEnd={onReconnectEnd}
onConnect={onConnect} onConnect={onConnect}
fitView fitView
attributionPosition="top-right" proOptions={{hideAttribution: true }}
> >
<Controls /> <Controls />
<Background /> <Background />