LucaVivona commited on
Commit
46e4902
·
1 Parent(s): ec9120e

Add Custom Line

Browse files
frontend/src/components/Edges/Custom.js CHANGED
@@ -18,7 +18,6 @@ export default function CustomEdge({
18
  targetY,
19
  sourcePosition,
20
  targetPosition,
21
- style = {},
22
  markerEnd,
23
  data
24
  }) {
@@ -41,7 +40,7 @@ export default function CustomEdge({
41
  <>
42
  <path
43
  id={id}
44
- style={style}
45
  className="react-flow__edge-path"
46
  d={edgePath}
47
  markerEnd={markerEnd}
 
18
  targetY,
19
  sourcePosition,
20
  targetPosition,
 
21
  markerEnd,
22
  data
23
  }) {
 
40
  <>
41
  <path
42
  id={id}
43
+ style={{stroke : "#00FF4A", strokeWidth : "6"}}
44
  className="react-flow__edge-path"
45
  d={edgePath}
46
  markerEnd={markerEnd}
frontend/src/components/Edges/CustomLine.js ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from 'react';
2
+ import { getBezierPath } from 'react-flow-renderer';
3
+
4
+ const CustomLine = ({
5
+ sourceX,
6
+ sourceY,
7
+ sourcePosition,
8
+ targetX,
9
+ targetY,
10
+ targetPosition,
11
+ connectionLineType,
12
+ connectionLineStyle,
13
+ }) => {
14
+
15
+ const edgePath = getBezierPath({
16
+ sourceX,
17
+ sourceY,
18
+ sourcePosition,
19
+ targetX,
20
+ targetY,
21
+ targetPosition,
22
+ });
23
+ return (
24
+ <g>
25
+ <path
26
+ fill="none"
27
+ stroke="#00FF4A"
28
+ strokeWidth={7}
29
+ className="animated"
30
+ d={edgePath}
31
+ />
32
+ </g>
33
+ );
34
+ };
35
+
36
+ export default CustomLine;
frontend/src/components/ReactFlow/ReactFlowEnv.js CHANGED
@@ -12,6 +12,7 @@ import ReactFlow, { Background,
12
  import React ,{ useState, useCallback, useRef, useEffect } from 'react';
13
  import Navbar from '../Navagation/navbar';
14
  import CustomEdge from '../Edges/Custom'
 
15
  import { useThemeDetector } from '../../helper/visual'
16
  import {CgMoreVerticalAlt} from 'react-icons/cg'
17
  import {BsFillEraserFill} from 'react-icons/bs'
@@ -165,7 +166,7 @@ export default function ReactEnviorment() {
165
  <ReactFlowProvider>
166
  <Navbar onDelete={deleteNodeContains} colour={JSON.parse(localStorage.getItem('colour'))} emoji={JSON.parse(localStorage.getItem('emoji'))}/>
167
  <div className="h-screen w-screen" ref={reactFlowWrapper}>
168
- <ReactFlow nodes={nodes} edges={edges} nodeTypes={NODE} edgeTypes={EDGE} onNodesChange={onNodesChange} onNodesDelete={deleteNode} onEdgesChange={onEdgesChange} onEdgeUpdate={onEdgeUpdate} onConnect={onConnect} onDragOver={onDragOver} onDrop={onDrop} onInit={setReactFlowInstance} fitView>
169
  <Background variant='dots' size={1} className=" bg-white dark:bg-neutral-800"/>
170
  <Controls/>
171
  </ReactFlow>
 
12
  import React ,{ useState, useCallback, useRef, useEffect } from 'react';
13
  import Navbar from '../Navagation/navbar';
14
  import CustomEdge from '../Edges/Custom'
15
+ import CustomLine from "../Edges/CustomLine.js";
16
  import { useThemeDetector } from '../../helper/visual'
17
  import {CgMoreVerticalAlt} from 'react-icons/cg'
18
  import {BsFillEraserFill} from 'react-icons/bs'
 
166
  <ReactFlowProvider>
167
  <Navbar onDelete={deleteNodeContains} colour={JSON.parse(localStorage.getItem('colour'))} emoji={JSON.parse(localStorage.getItem('emoji'))}/>
168
  <div className="h-screen w-screen" ref={reactFlowWrapper}>
169
+ <ReactFlow nodes={nodes} edges={edges} nodeTypes={NODE} edgeTypes={EDGE} onNodesChange={onNodesChange} onNodesDelete={deleteNode} onEdgesChange={onEdgesChange} onEdgeUpdate={onEdgeUpdate} onConnect={onConnect} onDragOver={onDragOver} onDrop={onDrop} onInit={setReactFlowInstance} connectionLineComponent={CustomLine} fitView>
170
  <Background variant='dots' size={1} className=" bg-white dark:bg-neutral-800"/>
171
  <Controls/>
172
  </ReactFlow>