diff --git a/frontend/components/editor/index.tsx b/frontend/components/editor/index.tsx index 39af65a..6b6b644 100644 --- a/frontend/components/editor/index.tsx +++ b/frontend/components/editor/index.tsx @@ -18,7 +18,7 @@ import { ResizablePanel, ResizablePanelGroup, } from "@/components/ui/resizable" -import { FileJson, Loader2, Sparkles, TerminalSquare } from "lucide-react" +import { FileJson, Loader2, Sparkles, TerminalSquare, ArrowDownToLine, ArrowRightToLine } from "lucide-react" import Tab from "../ui/tab" import Sidebar from "./sidebar" import GenerateInput from "./generate" @@ -145,7 +145,7 @@ export default function CodeEditor({ const generateRef = useRef(null) const suggestionRef = useRef(null) const generateWidgetRef = useRef(null) - const { previewPanelRef } = usePreview(); + const { previewPanelRef } = usePreview(); const editorPanelRef = useRef(null) const previewWindowRef = useRef<{ refreshIframe: () => void }>(null) @@ -416,7 +416,7 @@ export default function CodeEditor({ }) } }, [generate.show]) - + // Suggestion widget effect useEffect(() => { if (!suggestionRef.current || !editorRef) return @@ -686,9 +686,9 @@ export default function CodeEditor({ const selectFile = (tab: TTab) => { if (tab.id === activeFileId) return; - + setGenerate((prev) => ({ ...prev, show: false })); - + // Check if the tab already exists in the list of open tabs const exists = tabs.find((t) => t.id === tab.id); setTabs((prev) => { @@ -700,7 +700,7 @@ export default function CodeEditor({ // If the tab doesn't exist, add it to the list of tabs and make it active return [...prev, tab]; }); - + // If the file's content is already cached, set it as the active content if (fileContents[tab.id]) { setActiveFileContent(fileContents[tab.id]); @@ -711,7 +711,7 @@ export default function CodeEditor({ setActiveFileContent(response); }); } - + // Set the editor language based on the file type setEditorLanguage(processFileType(tab.name)); // Set the active file ID to the new tab @@ -837,6 +837,12 @@ export default function CodeEditor({ } }; + const [isHorizontalLayout, setIsHorizontalLayout] = useState(false); + + const toggleLayout = () => { + setIsHorizontalLayout(prev => !prev); + }; + // On disabled access for shared users, show un-interactable loading placeholder + info modal if (disableAccess.isDisabled) return ( @@ -972,12 +978,12 @@ export default function CodeEditor({ /> {/* Shadcn resizeable panels: https://ui.shadcn.com/docs/components/resizable */} - +
@@ -1022,7 +1028,7 @@ export default function CodeEditor({ onChange={(value) => { // If the new content is different from the cached content, update it if (value !== fileContents[activeFileId]) { - setActiveFileContent(value ?? ""); // Update the active file content + setActiveFileContent(value ?? ""); // Update the active file content // Mark the file as unsaved by setting 'saved' to false setTabs((prev) => prev.map((tab) => @@ -1068,24 +1074,38 @@ export default function CodeEditor({
- - + + setIsPreviewCollapsed(true)} onExpand={() => setIsPreviewCollapsed(false)} > - +
+ + +
+ {!isPreviewCollapsed && ( +
+