diff --git a/components/FlowEditor/Flow.tsx b/components/FlowEditor/Flow.tsx index 5088b77..81e6024 100644 --- a/components/FlowEditor/Flow.tsx +++ b/components/FlowEditor/Flow.tsx @@ -5,10 +5,21 @@ import ReactFlow, { Controls, ReactFlowInstance, } from "react-flow-renderer"; -import useStore from "../../lib/FlowEditor/FlowEditorStore"; -import { GenericNode } from "./nodes/Node"; -const nodeTypes = { generic: GenericNode }; +import useStore from "../../lib/FlowEditor/FlowEditorStore"; + +import LedNode from "./nodes/IO/LedNode"; +import SensorNode from "./nodes/IO/SensorNode"; + +import DelayNode from "./nodes/Logic/DelayNode"; +import MathNode from "./nodes/Logic/MathNode"; + +const nodeTypes = { + led: LedNode, + sensor: SensorNode, + delay: DelayNode, + math: MathNode, +}; const Flow = () => { const [reactFlowInstance, setReactFlowInstance] = diff --git a/components/FlowEditor/Panel.tsx b/components/FlowEditor/Panel.tsx index 2110af5..a5bde22 100644 --- a/components/FlowEditor/Panel.tsx +++ b/components/FlowEditor/Panel.tsx @@ -1,6 +1,7 @@ import { VscArrowLeft, VscArrowRight } from "react-icons/vsc"; import useStore from "../../lib/FlowEditor/FlowEditorStore"; -import { GenericNodeComponent } from "./nodes/Node"; +import { LedNodeComponent, SensorNodeComponent } from "./nodes/IO/IO"; +import { DelayNodeComponent, MathNodeComponent } from "./nodes/Logic/Logic"; const Panel = () => { const { panelClosed, togglePanelState } = useStore(); @@ -22,9 +23,13 @@ const Panel = () => { > {!panelClosed && ( - <> - - +
+ + + + + +
)} ); diff --git a/components/FlowEditor/nodes/IO/IO.tsx b/components/FlowEditor/nodes/IO/IO.tsx new file mode 100644 index 0000000..8bd11ee --- /dev/null +++ b/components/FlowEditor/nodes/IO/IO.tsx @@ -0,0 +1,27 @@ +import Draggable from "../../../DragNDrop/Draggable"; + +const groupColor = "bg-red-700"; + +const SensorNodeComponent = () => { + return ( + +
+
+ Сенсор +
+ + ); +}; + +const LedNodeComponent = () => { + return ( + +
+
+ Светодиод +
+ + ); +}; + +export { SensorNodeComponent, LedNodeComponent }; diff --git a/components/FlowEditor/nodes/IO/LedNode.tsx b/components/FlowEditor/nodes/IO/LedNode.tsx new file mode 100644 index 0000000..64785eb --- /dev/null +++ b/components/FlowEditor/nodes/IO/LedNode.tsx @@ -0,0 +1,27 @@ +import { Handle, Position } from "react-flow-renderer"; +import { bottomBigStyle, topBigStyle } from "../styles"; + +type LedNodeProps = {}; + +const LedNode = (props: LedNodeProps) => { + return ( +
+ + +
+ Светодиод +
+ +
+ +
+ + +
+ ); +}; + +export default LedNode; diff --git a/components/FlowEditor/nodes/IO/SensorNode.tsx b/components/FlowEditor/nodes/IO/SensorNode.tsx new file mode 100644 index 0000000..f953b55 --- /dev/null +++ b/components/FlowEditor/nodes/IO/SensorNode.tsx @@ -0,0 +1,25 @@ +import { Handle, Position } from "react-flow-renderer"; +import { bottomBigStyle, topBigStyle } from "../styles"; + +type SensorNodeProps = {}; + +const SensorNode = (props: SensorNodeProps) => { + return ( +
+ +
+ Сенсор +
+
+ +
+ + +
+ ); +}; + +export default SensorNode; diff --git a/components/FlowEditor/nodes/Logic/DelayNode.tsx b/components/FlowEditor/nodes/Logic/DelayNode.tsx new file mode 100644 index 0000000..a26293e --- /dev/null +++ b/components/FlowEditor/nodes/Logic/DelayNode.tsx @@ -0,0 +1,25 @@ +import { Handle, Position } from "react-flow-renderer"; +import { bottomBigStyle, topBigStyle } from "../styles"; + +type DelayNodeProps = {}; + +const DelayNode = (props: DelayNodeProps) => { + return ( +
+ +
+ Задержка +
+
+ +
+ + +
+ ); +}; + +export default DelayNode; diff --git a/components/FlowEditor/nodes/Logic/Logic.tsx b/components/FlowEditor/nodes/Logic/Logic.tsx new file mode 100644 index 0000000..1dec350 --- /dev/null +++ b/components/FlowEditor/nodes/Logic/Logic.tsx @@ -0,0 +1,27 @@ +import Draggable from "../../../DragNDrop/Draggable"; + +const groupColor = "bg-blue-800"; + +const DelayNodeComponent = () => { + return ( + +
+
+ Задержка +
+ + ); +}; + +const MathNodeComponent = () => { + return ( + +
+
+ Математика +
+ + ); +}; + +export { DelayNodeComponent, MathNodeComponent }; diff --git a/components/FlowEditor/nodes/Logic/MathNode.tsx b/components/FlowEditor/nodes/Logic/MathNode.tsx new file mode 100644 index 0000000..9b11fca --- /dev/null +++ b/components/FlowEditor/nodes/Logic/MathNode.tsx @@ -0,0 +1,46 @@ +import { Handle, Position } from "react-flow-renderer"; +import { + bottomBigStyle, + topDoubleLeftStyle, + topDoubleRightStyle, +} from "../styles"; + +type MathNodeProps = {}; + +const MathNode = (props: MathNodeProps) => { + return ( +
+ + + +
+ Математика +
+ +
+ +
+ + +
+ ); +}; + +export default MathNode; diff --git a/components/FlowEditor/nodes/Node.tsx b/components/FlowEditor/nodes/Node.tsx index f8ded1e..8c0fdae 100644 --- a/components/FlowEditor/nodes/Node.tsx +++ b/components/FlowEditor/nodes/Node.tsx @@ -33,8 +33,8 @@ const GenericNode = (props: GenericNodeProps) => { const GenericNodeComponent = () => { return ( -
-
+
+
Тест
diff --git a/components/FlowEditor/nodes/basic/InputNode.tsx b/components/FlowEditor/nodes/basic/InputNode.tsx deleted file mode 100644 index 06844f4..0000000 --- a/components/FlowEditor/nodes/basic/InputNode.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import styles from "./Node.module.css"; -import { Handle, Position } from "react-flow-renderer"; - -type InputNodeProps = {}; - -const InputNode = (props: InputNodeProps) => { - return ( - // Базовый класс generic-node - прописана ширина и положение, цвет текста и фона - - // Nandle - ручка для коннекта. Можно задать оформление при помощи className, тип (target / source) и позицию - - // Label - подпись ноды. Можно стилизовать - - // Select - DropDown меню, можно стилизовать. Стоит класс nodrag для предотвращения залипания - -
- - -
- - - - -
- - -
- ); -}; - -export default InputNode; \ No newline at end of file diff --git a/components/FlowEditor/nodes/basic/MathNode.tsx b/components/FlowEditor/nodes/basic/MathNode.tsx deleted file mode 100644 index 65e37dc..0000000 --- a/components/FlowEditor/nodes/basic/MathNode.tsx +++ /dev/null @@ -1,38 +0,0 @@ -import styles from "./Node.module.css"; -import { Handle, Position } from "react-flow-renderer"; - -type MathNodeProps = {}; - -const MathNode = (props: MathNodeProps) => { - return ( - // Базовый класс generic-node - прописана ширина и положение, цвет текста и фона - - // Nandle - ручка для коннекта. Можно задать оформление при помощи className, тип (target / source) и позицию - - // Label - подпись ноды. Можно стилизовать - - // Select - DropDown меню, можно стилизовать. Стоит класс nodrag для предотвращения залипания - -
- - -
- - первое число - - второе число -
- - -
- ); -}; - -export default MathNode; \ No newline at end of file diff --git a/components/FlowEditor/nodes/basic/OutputNode.tsx b/components/FlowEditor/nodes/basic/OutputNode.tsx deleted file mode 100644 index 8d9e03e..0000000 --- a/components/FlowEditor/nodes/basic/OutputNode.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import styles from "./Node.module.css"; -import { Handle, Position } from "react-flow-renderer"; - -type OutputNodeProps = {}; - -const OutputNode = (props: OutputNodeProps) => { - return ( - // Базовый класс generic-node - прописана ширина и положение, цвет текста и фона - - // Nandle - ручка для коннекта. Можно задать оформление при помощи className, тип (target / source) и позицию - - // Label - подпись ноды. Можно стилизовать - - // Select - DropDown меню, можно стилизовать. Стоит класс nodrag для предотвращения залипания - -
- - -
- - - -
- - -
- ); -}; - -export default OutputNode; \ No newline at end of file diff --git a/components/FlowEditor/nodes/basic/TimerNode.tsx b/components/FlowEditor/nodes/basic/TimerNode.tsx deleted file mode 100644 index 2461fb0..0000000 --- a/components/FlowEditor/nodes/basic/TimerNode.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import styles from "./Node.module.css"; -import { Handle, Position } from "react-flow-renderer"; - -type TimerNodeProps = {}; - -const TimerNode = (props: TimerNodeProps) => { - return ( - // Базовый класс generic-node - прописана ширина и положение, цвет текста и фона - - // Nandle - ручка для коннекта. Можно задать оформление при помощи className, тип (target / source) и позицию - - // Label - подпись ноды. Можно стилизовать - - // Select - DropDown меню, можно стилизовать. Стоит класс nodrag для предотвращения залипания - -
- - -
- - - Время задержки - -
- - -
- ); -}; - -export default TimerNode; \ No newline at end of file diff --git a/components/FlowEditor/nodes/styles.ts b/components/FlowEditor/nodes/styles.ts new file mode 100644 index 0000000..f63ad4e --- /dev/null +++ b/components/FlowEditor/nodes/styles.ts @@ -0,0 +1,46 @@ +const topDoubleLeftStyle = { + width: "20px", + height: "20px", + border: "none", + borderTopLeftRadius: "10px", + borderTopRightRadius: "10px", + borderBottomLeftRadius: "0px", + borderBottomRightRadius: "0px", + top: "-20px", + left: "20px", +}; + +const topDoubleRightStyle = { + width: "20px", + height: "20px", + border: "none", + borderTopLeftRadius: "10px", + borderTopRightRadius: "10px", + borderBottomLeftRadius: "0px", + borderBottomRightRadius: "0px", + top: "-20px", +}; + +const topBigStyle = { + width: "100%", + height: "10px", + border: "none", + borderTopLeftRadius: "10px", + borderTopRightRadius: "10px", + borderBottomLeftRadius: "0px", + borderBottomRightRadius: "0px", + top: "-10px", +}; + +const bottomBigStyle = { + width: "100%", + height: "10px", + border: "none", + borderTopLeftRadius: "0px", + borderTopRightRadius: "0px", + borderBottomLeftRadius: "10px", + borderBottomRightRadius: "10px", + bottom: "-10px", +}; + +export { topBigStyle, bottomBigStyle, topDoubleLeftStyle, topDoubleRightStyle }; diff --git a/styles/globals.css b/styles/globals.css index 5ed3db6..4f33c48 100644 --- a/styles/globals.css +++ b/styles/globals.css @@ -61,23 +61,39 @@ rounded-xl cursor-pointer; } - .flow { + .node-layout { + @apply flex flex-col items-center + w-[150px] h-fit bg-gray-700 + p-[4px]; } - .generic-node { - @apply flex flex-row items-center justify-center - w-[150px] h-auto bg-white - rounded-sm; + .node-handle-big { + @apply w-[150px] h-[20px]; + } + + .node-header { + @apply flex flex-row w-full h-[20px] justify-between items-center + mb-1 px-[4px] + border-b border-b-gray-500; + } + + .node-title { + @apply text-white text-xs font-bold; + } + + .node-content { + @apply flex flex-col w-full h-fit + mb-[4px]; } .node-component { @apply relative flex flex-row h-fit rounded-md bg-gray-600 - pr-2 my-2 py-1 mx-2 + pr-2 my-1 mx-2 text-white align-middle; } .node-component-handle { - @apply left-0 w-[12px] h-full mr-2 rounded-tl-md rounded-bl-md; + @apply left-0 w-[12px] h-[30px] mr-2 rounded-tl-md rounded-bl-md; } }