From bfc687a3e6a52509167f3622d33121a693d3a8d9 Mon Sep 17 00:00:00 2001 From: Akhileshrangani4 Date: Mon, 14 Oct 2024 13:51:17 -0400 Subject: [PATCH] fix: aichat and preview/terminal layout --- frontend/components/editor/index.tsx | 307 ++++++++++++++------------- 1 file changed, 160 insertions(+), 147 deletions(-) diff --git a/frontend/components/editor/index.tsx b/frontend/components/editor/index.tsx index bf4eecc..d3baf21 100644 --- a/frontend/components/editor/index.tsx +++ b/frontend/components/editor/index.tsx @@ -970,7 +970,6 @@ export default function CodeEditor({ /> ) : null} - {/* Main editor components */} addNew(name, type, setFiles, sandboxData)} deletingFolderId={deletingFolderId} /> - - {/* Shadcn resizeable panels: https://ui.shadcn.com/docs/components/resizable */} - - -
- {/* File tabs */} - {tabs.map((tab) => ( - { - selectFile(tab) - }} - onClose={() => closeTab(tab.id)} - > - {tab.name} - - ))} -
- {/* Monaco editor */} -
- {!activeFileId ? ( - <> -
- - No file selected. -
- - ) : // Note clerk.loaded is required here due to a bug: https://github.com/clerk/javascript/issues/1643 - clerk.loaded ? ( - <> - {provider && userInfo ? ( - - ) : null} - { - // If the new content is different from the cached content, update it - if (value !== fileContents[activeFileId]) { - setActiveFileContent(value ?? ""); // Update the active file content - // Mark the file as unsaved by setting 'saved' to false - setTabs((prev) => - prev.map((tab) => - tab.id === activeFileId - ? { ...tab, saved: false } - : tab - ) - ) - } else { - // If the content matches the cached content, mark the file as saved - setTabs((prev) => - prev.map((tab) => - tab.id === activeFileId - ? { ...tab, saved: true } - : tab - ) - ) - } + {/* Outer ResizablePanelGroup for main layout */} + + {/* Left side: Editor and Preview/Terminal */} + + + +
+ {/* File tabs */} + {tabs.map((tab) => ( + { + selectFile(tab) }} - options={{ - tabSize: 2, - minimap: { - enabled: false, - }, - padding: { - bottom: 4, - top: 4, - }, - scrollBeyondLastLine: false, - fixedOverflowWidgets: true, - fontFamily: "var(--font-geist-mono)", - }} - theme="vs-dark" - value={activeFileContent} - /> - - ) : ( -
- - Waiting for Clerk to load... -
- )} -
-
- - - {isAIChatOpen ? ( - - ) : ( - - setIsPreviewCollapsed(true)} - onExpand={() => setIsPreviewCollapsed(false)} + onClose={() => closeTab(tab.id)} + > + {tab.name} + + ))} +
+ {/* Monaco editor */} +
-
- - -
- {!isPreviewCollapsed && ( -
-