/** * Workspace is the right-hand panel: the file tree next to the Preview / * Editor / Terminal tabs. Panes are hidden rather than unmounted when * another tab is active — the terminal's shell session and the editor's * unsaved state survive tab switches (and the panel being collapsed). * The file tree column is resizable: its width lives in the workspace * store and reaches the CSS through the `--filetree-width` custom property. * * @example * // visibility is driven by the workspace store */ import { type CSSProperties, type ReactNode, useEffect, useState } from "react"; import { MAX_FILE_TREE_WIDTH, MIN_FILE_TREE_WIDTH, type WorkspaceTab, resetFileTreeWidth, setFileTreeWidth, showTab, useWorkspace, } from "../workspace"; import { EditorPane } from "./EditorPane"; import { FileTree } from "./FileTree"; import { PreviewPane } from "./PreviewPane"; import { ResizeHandle } from "./ResizeHandle"; import { TerminalPane } from "./TerminalPane"; const tabs: { id: WorkspaceTab; label: string }[] = [ { id: "preview", label: "Preview" }, { id: "editor", label: "Editor" }, { id: "terminal", label: "Terminal" }, ]; export function Workspace() { const workspace = useWorkspace(); // The terminal (and its shell) starts on first activation only. const [terminalStarted, setTerminalStarted] = useState(false); useEffect(() => { if (workspace.open && workspace.tab === "terminal") { setTerminalStarted(true); } }, [workspace.open, workspace.tab]); const style = { "--filetree-width": `${workspace.fileTreeWidth}px`, } as CSSProperties; return ( ); } /** Pane hides its children without unmounting them. */ function Pane({ visible, children, }: { visible: boolean; children: ReactNode }) { return (
{children}
); }