From 3f8a920fc4239c1e20d202f0e8ae19a5744268ac Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Sun, 19 Feb 2023 23:56:19 -0300 Subject: [PATCH] boiller code for tabs on reactFlow, need to think and structure first the logic --- space_flow/package-lock.json | 13 +++++ space_flow/package.json | 1 + .../src/pages/FlowPage/flowManager/index.tsx | 49 +++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 space_flow/src/pages/FlowPage/flowManager/index.tsx diff --git a/space_flow/package-lock.json b/space_flow/package-lock.json index 737d5c7de..7d4ffaedd 100644 --- a/space_flow/package-lock.json +++ b/space_flow/package-lock.json @@ -28,6 +28,7 @@ "react-laag": "^2.0.5", "react-router-dom": "^6.8.1", "react-scripts": "5.0.1", + "react-tabs": "^6.0.0", "reactflow": "^11.5.5", "tailwindcss": "^3.2.6", "typescript": "^4.9.5", @@ -15070,6 +15071,18 @@ } } }, + "node_modules/react-tabs": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/react-tabs/-/react-tabs-6.0.0.tgz", + "integrity": "sha512-8jKLKrlwxmn5/+xsa76yi27ZdB8E/WhlhQZw739O5UlOeUGtVoVeWnpqIewv/KbjTw7gQf/uA51zWUNt4IVygQ==", + "dependencies": { + "clsx": "^1.1.0", + "prop-types": "^15.5.0" + }, + "peerDependencies": { + "react": "^18.0.0" + } + }, "node_modules/react-transition-group": { "version": "4.4.5", "resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.4.5.tgz", diff --git a/space_flow/package.json b/space_flow/package.json index 2009ca52d..28891fac9 100644 --- a/space_flow/package.json +++ b/space_flow/package.json @@ -23,6 +23,7 @@ "react-laag": "^2.0.5", "react-router-dom": "^6.8.1", "react-scripts": "5.0.1", + "react-tabs": "^6.0.0", "reactflow": "^11.5.5", "tailwindcss": "^3.2.6", "typescript": "^4.9.5", diff --git a/space_flow/src/pages/FlowPage/flowManager/index.tsx b/space_flow/src/pages/FlowPage/flowManager/index.tsx new file mode 100644 index 000000000..7d615833a --- /dev/null +++ b/space_flow/src/pages/FlowPage/flowManager/index.tsx @@ -0,0 +1,49 @@ +import { useState } from 'react'; +import { Tab, Tabs, TabList, TabPanel } from 'react-tabs'; +import FlowPage from '..'; +import 'react-tabs/style/react-tabs.css'; + +interface FlowTabProps { + flow:any; +} + +function FlowTab() { + return ( + + ); +} + +function App() { + const [flows, setFlows] = useState([]); // Start with one flow + const [activeIndex, setActiveIndex] = useState(0); + + function onElementsChange(flowIndex: number, elements: any[]) { + setFlows((prevFlows) => { + const newFlows = [...prevFlows]; + newFlows[flowIndex] = elements; + return newFlows; + }); + } + + function addTab() { + setFlows([...flows, []]); // Add a new flow to the state + setActiveIndex(flows.length); // Activate the new tab + } + + return ( + + + {flows.map((flow, index) => ( + Flow {index + 1} + ))} + {/* Render the plus button */} + + + {flows.map((flow, index) => ( + + + + ))} + + ); +}