Spaces:
Configuration error
Configuration error
LucaVivona
commited on
Commit
•
1e8b235
1
Parent(s):
467436a
update/refactor frontend
Browse files
frontend/src/components/Nodes/Custom.js
CHANGED
@@ -82,8 +82,8 @@ export default class CustomNodeIframe extends React.Component {
|
|
82 |
this.original_x = this.myRef.current.getBoundingClientRect().left;
|
83 |
this.original_y = this.myRef.current.getBoundingClientRect().top;
|
84 |
|
85 |
-
this.original_mouse_x = e.
|
86 |
-
this.original_mouse_y = e.
|
87 |
}
|
88 |
|
89 |
resize = (e, point) => {
|
@@ -91,56 +91,23 @@ export default class CustomNodeIframe extends React.Component {
|
|
91 |
var width = 0;
|
92 |
// e.dataTransfer.setDragImage(new Image(), 0, 0)
|
93 |
if (point === 'bottom-right'){
|
94 |
-
width = this.original_width + (e.
|
95 |
-
height = this.original_height + (e.
|
96 |
if (width > MINIMUM_WIDTH) {
|
97 |
this.myRef.current.style.width = `${width}px`
|
98 |
-
|
99 |
-
if (height > MINIMUM_HEIGHT) {
|
100 |
-
this.myRef.current.style.height = `${height}px`
|
101 |
-
}
|
102 |
-
|
103 |
-
} else if (point === "bottom-left"){
|
104 |
-
height = this.original_height + (e.pageY - this.original_mouse_y)
|
105 |
-
width = this.original_width - (e.pageX - this.original_mouse_x);
|
106 |
-
if (height > MINIMUM_HEIGHT) {
|
107 |
-
this.myRef.current.style.height = `${height}px`
|
108 |
-
}
|
109 |
-
if (width > MINIMUM_WIDTH) {
|
110 |
-
this.myRef.current.style.width = `${width}px`
|
111 |
-
this.myRef.current.style.left = this.original_x + (e.pageX - this.original_mouse_x) + 'px'
|
112 |
|
113 |
}
|
114 |
-
} else if (point === "top-right"){
|
115 |
-
width = this.original_width + (e.pageX - this.original_mouse_x);
|
116 |
-
height = this.original_height - (e.pageY - this.original_mouse_y)
|
117 |
-
|
118 |
-
if (width > MINIMUM_WIDTH) {
|
119 |
-
this.myRef.current.style.width = `${width}px`
|
120 |
-
}
|
121 |
if (height > MINIMUM_HEIGHT) {
|
122 |
this.myRef.current.style.height = `${height}px`
|
123 |
-
this.
|
124 |
-
}
|
125 |
-
} else {
|
126 |
-
height = this.original_height - (e.pageY - this.original_mouse_y)
|
127 |
-
width = this.original_width - (e.pageX - this.original_mouse_x);
|
128 |
-
if (width > MINIMUM_WIDTH) {
|
129 |
-
this.myRef.current.style.width = `${width}px`
|
130 |
-
this.myRef.current.style.left = this.original_x + (e.pageX - this.original_mouse_x) + 'px'
|
131 |
|
132 |
}
|
133 |
-
|
134 |
-
this.myRef.current.style.height = `${height}px`
|
135 |
-
this.myRef.current.style.top = this.original_y + (e.pageY - this.original_mouse_y) + 'px'
|
136 |
-
}
|
137 |
-
}
|
138 |
-
|
139 |
-
this.setState({id : this.state.id, reachable : this.state.reachable, selected : this.state.selected, data : this.state.data, width : parseInt(width) , height : parseInt(height), size : this.state.size, iframe : this.state.iframe})
|
140 |
-
|
141 |
}
|
142 |
|
143 |
OnDragEnd = () => {
|
|
|
144 |
this.setState({id : this.state.id, reachable : this.state.reachable, selected : this.state.selected, data : this.state.data, width : parseInt(this.myRef.current.style.width), height : parseInt(this.myRef.current.style.height), size : this.state.size, iframe : this.state.iframe})
|
145 |
|
146 |
}
|
|
|
82 |
this.original_x = this.myRef.current.getBoundingClientRect().left;
|
83 |
this.original_y = this.myRef.current.getBoundingClientRect().top;
|
84 |
|
85 |
+
this.original_mouse_x = e.clientX
|
86 |
+
this.original_mouse_y = e.clientY
|
87 |
}
|
88 |
|
89 |
resize = (e, point) => {
|
|
|
91 |
var width = 0;
|
92 |
// e.dataTransfer.setDragImage(new Image(), 0, 0)
|
93 |
if (point === 'bottom-right'){
|
94 |
+
width = this.original_width + (e.clientX - this.original_mouse_x);
|
95 |
+
height = this.original_height + (e.clientY - this.original_mouse_y)
|
96 |
if (width > MINIMUM_WIDTH) {
|
97 |
this.myRef.current.style.width = `${width}px`
|
98 |
+
this.setState({id : this.state.id, reachable : this.state.reachable, selected : this.state.selected, data : this.state.data, width : parseInt(width) , height : parseInt(height), size : this.state.size, iframe : this.state.iframe})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
|
100 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
if (height > MINIMUM_HEIGHT) {
|
102 |
this.myRef.current.style.height = `${height}px`
|
103 |
+
this.setState({id : this.state.id, reachable : this.state.reachable, selected : this.state.selected, data : this.state.data, width : parseInt(width) , height : parseInt(height), size : this.state.size, iframe : this.state.iframe})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
|
105 |
}
|
106 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
}
|
108 |
|
109 |
OnDragEnd = () => {
|
110 |
+
console.log("end")
|
111 |
this.setState({id : this.state.id, reachable : this.state.reachable, selected : this.state.selected, data : this.state.data, width : parseInt(this.myRef.current.style.width), height : parseInt(this.myRef.current.style.height), size : this.state.size, iframe : this.state.iframe})
|
112 |
|
113 |
}
|
frontend/src/components/ReactFlow/ReactFlowEnv.js
CHANGED
@@ -7,7 +7,9 @@ import ReactFlow, { Background,
|
|
7 |
import React ,{ useState, useCallback, useRef, useEffect } from 'react';
|
8 |
import Navbar from '../Navagation/navbar';
|
9 |
import { useThemeDetector } from '../../helper/visual'
|
10 |
-
import {CgMoreVerticalAlt} from 'react-icons/cg'
|
|
|
|
|
11 |
|
12 |
const types = {
|
13 |
custom : CustomNodeIframe,
|
@@ -68,6 +70,16 @@ export default function ReactEnviorment() {
|
|
68 |
}
|
69 |
}, [reactFlowInstance]);
|
70 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
|
72 |
const onDrop = useCallback(
|
73 |
(event) => {
|
@@ -103,10 +115,11 @@ export default function ReactEnviorment() {
|
|
103 |
|
104 |
return (
|
105 |
<div className={`${theme ? "dark" : ""}`}>
|
106 |
-
<div className={` absolute
|
107 |
-
<CgMoreVerticalAlt className={` text-black dark:text-white ${tool ? "-rotate-0 mr-auto ml-auto" : "rotate-
|
108 |
-
<h1 title={theme ? 'Dark Mode' : 'Light Mode'} className={`p-4 px-1 ${tool ? "visible
|
109 |
-
<
|
|
|
110 |
</div>
|
111 |
<div className={`flex h-screen w-screen ${theme ? "dark" : ""} transition-all`}>
|
112 |
<Navbar onDelete={deleteNodeContains} colour={JSON.parse(localStorage.getItem('colour'))} emoji={JSON.parse(localStorage.getItem('emoji'))}/>
|
|
|
7 |
import React ,{ useState, useCallback, useRef, useEffect } from 'react';
|
8 |
import Navbar from '../Navagation/navbar';
|
9 |
import { useThemeDetector } from '../../helper/visual'
|
10 |
+
import {CgMoreVerticalAlt} from 'react-icons/cg'
|
11 |
+
import {BsFillEraserFill} from 'react-icons/bs'
|
12 |
+
import {FaRegSave} from 'react-icons/fa'
|
13 |
|
14 |
const types = {
|
15 |
custom : CustomNodeIframe,
|
|
|
70 |
}
|
71 |
}, [reactFlowInstance]);
|
72 |
|
73 |
+
const onErase = useCallback(() => {
|
74 |
+
const flow = localStorage.getItem("flowkey")
|
75 |
+
if (reactFlowInstance && flow){
|
76 |
+
alert("The current nodes have been erased from the localstorage")
|
77 |
+
localStorage.removeItem("flowkey")
|
78 |
+
localStorage.removeItem('colour')
|
79 |
+
localStorage.removeItem('emoji')
|
80 |
+
}
|
81 |
+
},[reactFlowInstance])
|
82 |
+
|
83 |
|
84 |
const onDrop = useCallback(
|
85 |
(event) => {
|
|
|
115 |
|
116 |
return (
|
117 |
<div className={`${theme ? "dark" : ""}`}>
|
118 |
+
<div className={` absolute text-center ${tool ? "h-[203.3333px]" : "h-[41px]"} overflow-hidden w-[41px] text-4xl top-4 right-5 z-50 cursor-default select-none bg-white dark:bg-stone-900 rounded-full border border-black dark:border-white duration-500`} >
|
119 |
+
<CgMoreVerticalAlt className={` text-black dark:text-white ${tool ? "-rotate-0 mr-auto ml-auto mt-1" : " rotate-180 mr-auto ml-auto mt-1"} duration-300`} onClick={() => setTool(!tool)}/>
|
120 |
+
<h1 title={theme ? 'Dark Mode' : 'Light Mode'} className={`p-4 px-1 pb-0 ${tool ? "visible" : "invisible"} text-3xl`} onClick={() => setTheme(!theme)} >{theme ? '🌙' : '☀️'}</h1>
|
121 |
+
<FaRegSave title="Save" className={`mt-6 text-black dark:text-white ${tool ? "visible" : " invisible"} ml-auto mr-auto `} onClick={() => onSave()}/>
|
122 |
+
<BsFillEraserFill title="Erase" className={`mt-6 text-black dark:text-white ml-auto mr-auto ${tool ? "visible" : " invisible"} `} onClick={() => onErase()}/>
|
123 |
</div>
|
124 |
<div className={`flex h-screen w-screen ${theme ? "dark" : ""} transition-all`}>
|
125 |
<Navbar onDelete={deleteNodeContains} colour={JSON.parse(localStorage.getItem('colour'))} emoji={JSON.parse(localStorage.getItem('emoji'))}/>
|
frontend/src/css/dist/output.css
CHANGED
@@ -728,6 +728,10 @@ video {
|
|
728 |
margin-top: auto;
|
729 |
}
|
730 |
|
|
|
|
|
|
|
|
|
731 |
.block {
|
732 |
display: block;
|
733 |
}
|
@@ -796,6 +800,22 @@ video {
|
|
796 |
height: 39.750px;
|
797 |
}
|
798 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
799 |
.w-10 {
|
800 |
width: 2.5rem;
|
801 |
}
|
@@ -848,6 +868,10 @@ video {
|
|
848 |
width: 29.5px;
|
849 |
}
|
850 |
|
|
|
|
|
|
|
|
|
851 |
.max-w-full {
|
852 |
max-width: 100%;
|
853 |
}
|
@@ -1347,6 +1371,22 @@ video {
|
|
1347 |
padding-top: 0.5rem;
|
1348 |
}
|
1349 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1350 |
.text-center {
|
1351 |
text-align: center;
|
1352 |
}
|
@@ -1479,6 +1519,18 @@ video {
|
|
1479 |
transition-delay: 170ms;
|
1480 |
}
|
1481 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1482 |
.duration-300 {
|
1483 |
transition-duration: 300ms;
|
1484 |
}
|
|
|
728 |
margin-top: auto;
|
729 |
}
|
730 |
|
731 |
+
.mt-2 {
|
732 |
+
margin-top: 0.5rem;
|
733 |
+
}
|
734 |
+
|
735 |
.block {
|
736 |
display: block;
|
737 |
}
|
|
|
800 |
height: 39.750px;
|
801 |
}
|
802 |
|
803 |
+
.h-\[157px\] {
|
804 |
+
height: 157px;
|
805 |
+
}
|
806 |
+
|
807 |
+
.h-\[41px\] {
|
808 |
+
height: 41px;
|
809 |
+
}
|
810 |
+
|
811 |
+
.h-\[203\.3px\] {
|
812 |
+
height: 203.3px;
|
813 |
+
}
|
814 |
+
|
815 |
+
.h-\[203\.3333px\] {
|
816 |
+
height: 203.3333px;
|
817 |
+
}
|
818 |
+
|
819 |
.w-10 {
|
820 |
width: 2.5rem;
|
821 |
}
|
|
|
868 |
width: 29.5px;
|
869 |
}
|
870 |
|
871 |
+
.w-\[41px\] {
|
872 |
+
width: 41px;
|
873 |
+
}
|
874 |
+
|
875 |
.max-w-full {
|
876 |
max-width: 100%;
|
877 |
}
|
|
|
1371 |
padding-top: 0.5rem;
|
1372 |
}
|
1373 |
|
1374 |
+
.pb-1 {
|
1375 |
+
padding-bottom: 0.25rem;
|
1376 |
+
}
|
1377 |
+
|
1378 |
+
.pb-2 {
|
1379 |
+
padding-bottom: 0.5rem;
|
1380 |
+
}
|
1381 |
+
|
1382 |
+
.pb-6 {
|
1383 |
+
padding-bottom: 1.5rem;
|
1384 |
+
}
|
1385 |
+
|
1386 |
+
.pb-0 {
|
1387 |
+
padding-bottom: 0px;
|
1388 |
+
}
|
1389 |
+
|
1390 |
.text-center {
|
1391 |
text-align: center;
|
1392 |
}
|
|
|
1519 |
transition-delay: 170ms;
|
1520 |
}
|
1521 |
|
1522 |
+
.delay-\[270ms\] {
|
1523 |
+
transition-delay: 270ms;
|
1524 |
+
}
|
1525 |
+
|
1526 |
+
.delay-\[100ms\] {
|
1527 |
+
transition-delay: 100ms;
|
1528 |
+
}
|
1529 |
+
|
1530 |
+
.delay-\[200ms\] {
|
1531 |
+
transition-delay: 200ms;
|
1532 |
+
}
|
1533 |
+
|
1534 |
.duration-300 {
|
1535 |
transition-duration: 300ms;
|
1536 |
}
|