From ef126e139e9ce17dad6866e416c93e87ca2536fb Mon Sep 17 00:00:00 2001 From: Arpandeep Khatua Date: Thu, 21 Nov 2024 20:57:11 -0800 Subject: [PATCH] Adding Sidebar and empty scene context --- .../nodes/frontend/package-lock.json | 57 ++++++++++++ .../experimental/nodes/frontend/package.json | 3 + .../experimental/nodes/frontend/src/App.tsx | 28 ++++-- .../src/components/CodeEditor/FileSystem.css | 33 ++++++- .../src/components/CodeEditor/FileSystem.tsx | 86 +++++++++++++++---- .../src/components/Sidebar/SceneContext.css | 8 ++ .../src/components/Sidebar/SceneContext.tsx | 11 +++ .../src/components/Sidebar/Sidebar.css | 24 ++++++ .../src/components/Sidebar/Sidebar.tsx | 21 +++++ 9 files changed, 242 insertions(+), 29 deletions(-) create mode 100644 examples/experimental/nodes/frontend/src/components/Sidebar/SceneContext.css create mode 100644 examples/experimental/nodes/frontend/src/components/Sidebar/SceneContext.tsx create mode 100644 examples/experimental/nodes/frontend/src/components/Sidebar/Sidebar.css create mode 100644 examples/experimental/nodes/frontend/src/components/Sidebar/Sidebar.tsx diff --git a/examples/experimental/nodes/frontend/package-lock.json b/examples/experimental/nodes/frontend/package-lock.json index 6caed8a0..8253eb3a 100644 --- a/examples/experimental/nodes/frontend/package-lock.json +++ b/examples/experimental/nodes/frontend/package-lock.json @@ -19,6 +19,7 @@ "@types/node": "^16.18.119", "@types/react": "^18.3.12", "@types/react-dom": "^18.3.1", + "@types/react-resizable": "^3.0.8", "@uiw/codemirror-theme-github": "^4.23.6", "@uiw/react-codemirror": "^4.23.6", "class-variance-authority": "^0.7.0", @@ -27,6 +28,8 @@ "lucide-react": "^0.460.0", "react": "^18.3.1", "react-dom": "^18.3.1", + "react-icons": "^5.3.0", + "react-resizable": "^3.0.5", "react-scripts": "5.0.1", "socket.io-client": "^4.8.1", "tailwind-merge": "^2.5.4", @@ -4157,6 +4160,15 @@ "@types/react": "*" } }, + "node_modules/@types/react-resizable": { + "version": "3.0.8", + "resolved": "https://registry.npmjs.org/@types/react-resizable/-/react-resizable-3.0.8.tgz", + "integrity": "sha512-Pcvt2eGA7KNXldt1hkhVhAgZ8hK41m0mp89mFgQi7LAAEZiaLgm4fHJ5zbJZ/4m2LVaAyYrrRRv1LHDcrGQanA==", + "license": "MIT", + "dependencies": { + "@types/react": "*" + } + }, "node_modules/@types/resolve": { "version": "1.17.1", "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.17.1.tgz", @@ -14346,12 +14358,44 @@ "react": "^18.3.1" } }, + "node_modules/react-draggable": { + "version": "4.4.6", + "resolved": "https://registry.npmjs.org/react-draggable/-/react-draggable-4.4.6.tgz", + "integrity": "sha512-LtY5Xw1zTPqHkVmtM3X8MUOxNDOUhv/khTgBgrUvwaS064bwVvxT+q5El0uUFNx5IEPKXuRejr7UqLwBIg5pdw==", + "license": "MIT", + "dependencies": { + "clsx": "^1.1.1", + "prop-types": "^15.8.1" + }, + "peerDependencies": { + "react": ">= 16.3.0", + "react-dom": ">= 16.3.0" + } + }, + "node_modules/react-draggable/node_modules/clsx": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/clsx/-/clsx-1.2.1.tgz", + "integrity": "sha512-EcR6r5a8bj6pu3ycsa/E/cKVGuTgZJZdsyUYHOksG/UHIiKfjxzRxYJpyVBwYaQeOvghal9fcc4PidlgzugAQg==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/react-error-overlay": { "version": "6.0.11", "resolved": "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.0.11.tgz", "integrity": "sha512-/6UZ2qgEyH2aqzYZgQPxEnz33NJ2gNsnHA2o5+o4wW9bLM/JYQitNP9xPhsXwC08hMMovfGe/8retsdDsczPRg==", "license": "MIT" }, + "node_modules/react-icons": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/react-icons/-/react-icons-5.3.0.tgz", + "integrity": "sha512-DnUk8aFbTyQPSkCfF8dbX6kQjXA9DktMeJqfjrg6cK9vwQVMxmcA3BfP4QoiztVmEHtwlTgLFsPuH2NskKT6eg==", + "license": "MIT", + "peerDependencies": { + "react": "*" + } + }, "node_modules/react-is": { "version": "17.0.2", "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", @@ -14367,6 +14411,19 @@ "node": ">=0.10.0" } }, + "node_modules/react-resizable": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/react-resizable/-/react-resizable-3.0.5.tgz", + "integrity": "sha512-vKpeHhI5OZvYn82kXOs1bC8aOXktGU5AmKAgaZS4F5JPburCtbmDPqE7Pzp+1kN4+Wb81LlF33VpGwWwtXem+w==", + "license": "MIT", + "dependencies": { + "prop-types": "15.x", + "react-draggable": "^4.0.3" + }, + "peerDependencies": { + "react": ">= 16.3" + } + }, "node_modules/react-scripts": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/react-scripts/-/react-scripts-5.0.1.tgz", diff --git a/examples/experimental/nodes/frontend/package.json b/examples/experimental/nodes/frontend/package.json index 4be66871..f22fa3a1 100644 --- a/examples/experimental/nodes/frontend/package.json +++ b/examples/experimental/nodes/frontend/package.json @@ -14,6 +14,7 @@ "@types/node": "^16.18.119", "@types/react": "^18.3.12", "@types/react-dom": "^18.3.1", + "@types/react-resizable": "^3.0.8", "@uiw/codemirror-theme-github": "^4.23.6", "@uiw/react-codemirror": "^4.23.6", "class-variance-authority": "^0.7.0", @@ -22,6 +23,8 @@ "lucide-react": "^0.460.0", "react": "^18.3.1", "react-dom": "^18.3.1", + "react-icons": "^5.3.0", + "react-resizable": "^3.0.5", "react-scripts": "5.0.1", "socket.io-client": "^4.8.1", "tailwind-merge": "^2.5.4", diff --git a/examples/experimental/nodes/frontend/src/App.tsx b/examples/experimental/nodes/frontend/src/App.tsx index 61f84e2a..ceb7a2b1 100644 --- a/examples/experimental/nodes/frontend/src/App.tsx +++ b/examples/experimental/nodes/frontend/src/App.tsx @@ -6,10 +6,9 @@ import { FileSystem } from './components/CodeEditor/FileSystem'; import { Terminal } from './components/Terminal/Terminal'; import { ChatInterface } from './components/ChatInterface/ChatInterface'; import { Browser } from './components/Browser/Browser'; +import { Sidebar } from './components/Sidebar/Sidebar'; +import { SceneContext } from './components/Sidebar/SceneContext'; -// const socket = io(); - -// Add this to your frontend code const socket = io('http://localhost:8000', { transports: ['websocket'], reconnection: true @@ -27,6 +26,8 @@ type FilesType = { [key: string]: string; }; +type PanelOption = 'fileSystem' | 'sceneContext'; + const App: React.FC = () => { const [files, setFiles] = useState({ "/workspace/index.html": "\n\n\n \n Document\n\n\n

Hello World

\n\n", @@ -40,6 +41,7 @@ const App: React.FC = () => { const [terminalMessages, setTerminalMessages] = useState([]); const [activeTab, setActiveTab] = useState<'editor' | 'browser'>('editor'); const [browserUrl, setBrowserUrl] = useState('https://example.com'); + const [activePanel, setActivePanel] = useState('fileSystem'); useEffect(() => { const handleNewMessage = (data: any) => { @@ -100,12 +102,24 @@ const App: React.FC = () => { } }; + const handleSidebarSelect = (option: PanelOption) => { + setActivePanel(option); + }; + return (
+
-
- -
+ {activePanel === 'fileSystem' && ( +
+ +
+ )} + {activePanel === 'sceneContext' && ( +
+ +
+ )}
+ + {/* Add more icons as needed */} +
+ ); +}; \ No newline at end of file