From 453e708e3f33cdf60527cec2c7afca89772b9cb2 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 15 Jul 2022 06:32:00 +0300 Subject: [PATCH] Add start/finish logic --- components/FlowEditor/Flow.tsx | 4 +++ components/FlowEditor/Panel.tsx | 5 +++- .../FlowEditor/nodes/Logic/FinishNode.tsx | 24 +++++++++++++++++ components/FlowEditor/nodes/Logic/Logic.tsx | 24 ++++++++++++++++- .../FlowEditor/nodes/Logic/StartNode.tsx | 26 +++++++++++++++++++ 5 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 components/FlowEditor/nodes/Logic/FinishNode.tsx create mode 100644 components/FlowEditor/nodes/Logic/StartNode.tsx diff --git a/components/FlowEditor/Flow.tsx b/components/FlowEditor/Flow.tsx index 81e6024..5b1985c 100644 --- a/components/FlowEditor/Flow.tsx +++ b/components/FlowEditor/Flow.tsx @@ -12,13 +12,17 @@ import LedNode from "./nodes/IO/LedNode"; import SensorNode from "./nodes/IO/SensorNode"; import DelayNode from "./nodes/Logic/DelayNode"; +import FinishNode from "./nodes/Logic/FinishNode"; import MathNode from "./nodes/Logic/MathNode"; +import StartNode from "./nodes/Logic/StartNode"; const nodeTypes = { led: LedNode, sensor: SensorNode, delay: DelayNode, math: MathNode, + finish: FinishNode, + start: StartNode, }; const Flow = () => { diff --git a/components/FlowEditor/Panel.tsx b/components/FlowEditor/Panel.tsx index a5bde22..1d576af 100644 --- a/components/FlowEditor/Panel.tsx +++ b/components/FlowEditor/Panel.tsx @@ -1,7 +1,7 @@ import { VscArrowLeft, VscArrowRight } from "react-icons/vsc"; import useStore from "../../lib/FlowEditor/FlowEditorStore"; import { LedNodeComponent, SensorNodeComponent } from "./nodes/IO/IO"; -import { DelayNodeComponent, MathNodeComponent } from "./nodes/Logic/Logic"; +import { DelayNodeComponent, MathNodeComponent , StartNodeComponent, FinishNodeComponent } from "./nodes/Logic/Logic"; const Panel = () => { const { panelClosed, togglePanelState } = useStore(); @@ -29,6 +29,9 @@ const Panel = () => { + + + )} diff --git a/components/FlowEditor/nodes/Logic/FinishNode.tsx b/components/FlowEditor/nodes/Logic/FinishNode.tsx new file mode 100644 index 0000000..90e219c --- /dev/null +++ b/components/FlowEditor/nodes/Logic/FinishNode.tsx @@ -0,0 +1,24 @@ +import { Handle, Position } from "react-flow-renderer"; +import { + topDoubleRightStyle, +} from "../styles"; + +type FinishNodeProps = {}; + +const FinishNode = (props: FinishNodeProps) => { + return ( +
+ +
+ Конец программы +
+ +
+ ); +}; + +export default FinishNode; \ No newline at end of file diff --git a/components/FlowEditor/nodes/Logic/Logic.tsx b/components/FlowEditor/nodes/Logic/Logic.tsx index 1dec350..bd4d7dc 100644 --- a/components/FlowEditor/nodes/Logic/Logic.tsx +++ b/components/FlowEditor/nodes/Logic/Logic.tsx @@ -24,4 +24,26 @@ const MathNodeComponent = () => { ); }; -export { DelayNodeComponent, MathNodeComponent }; +const FinishNodeComponent = () => { + return ( + +
+
+ Конец программы +
+ + ); +}; + +const StartNodeComponent = () => { + return ( + +
+
+ Начало программы +
+ + ); +}; + +export { StartNodeComponent, FinishNodeComponent, DelayNodeComponent, MathNodeComponent }; diff --git a/components/FlowEditor/nodes/Logic/StartNode.tsx b/components/FlowEditor/nodes/Logic/StartNode.tsx new file mode 100644 index 0000000..e0a3a2f --- /dev/null +++ b/components/FlowEditor/nodes/Logic/StartNode.tsx @@ -0,0 +1,26 @@ +import { Handle, Position } from "react-flow-renderer"; +import { + bottomBigStyle, + bottomSmallStyle, +} from "../styles"; + +type StartNodeProps = {}; + +const StartNode = (props: StartNodeProps) => { + return ( +
+ +
+ Начало программы +
+ + +
+ ); +}; + +export default StartNode; \ No newline at end of file