Split the workbench markup into region components
Phase 5-1. Workbench.svelte keeps the state and the commands. Six components now draw its regions, each with its own styles: - WorkbenchHeader: the side pane buttons, the working tabs, the actions, and the window controls. - PluginRibbon: the ribbon of plugin views. - LeftPane: the plugin sidebar, files, search, bookmarks, and the workspace footer. - DocumentArea: the plugin editor panes, the document panes, and the save conflict banners. - RightPane: the outline and the backlinks. - StatusBar: the status line. Each component keeps the root element of its region, so the shell grid places them as before. Workbench.svelte has about 450 fewer lines. There is no visible change. pnpm check passes. pnpm test: 451 of 451 pass. Full smoke suite: 95 passed, 2 known. plugins/access failed one time and passed on retry and 3 of 3 times alone.
This commit is contained in:
@@ -0,0 +1,171 @@
|
||||
<script lang="ts">
|
||||
// The left pane: a plugin sidebar view, or the files, search, and bookmarks views, and the workspace footer.
|
||||
import { t } from "$lib/i18n";
|
||||
import IconButton from "$lib/ui/IconButton.svelte";
|
||||
import PluginEditor from "$lib/plugins/PluginEditor.svelte";
|
||||
import BrowserSlot from "$lib/plugins/BrowserSlot.svelte";
|
||||
import { pluginSidebar } from "$lib/plugins/external";
|
||||
import type { WorkspaceSession } from "$lib/workspace/session.svelte";
|
||||
import type { TreeEntry, WorkspaceInfo } from "$lib/workspace/types";
|
||||
import FileTree from "./FileTree.svelte";
|
||||
import SearchPane from "./SearchPane.svelte";
|
||||
import BookmarksPane from "./BookmarksPane.svelte";
|
||||
|
||||
type Props = {
|
||||
workspace: WorkspaceInfo | null;
|
||||
session: WorkspaceSession;
|
||||
leftView: "files" | "search" | "bookmarks";
|
||||
keysActive: boolean;
|
||||
showInternal: boolean;
|
||||
activePath: string | null;
|
||||
searchRequest: { text: string; id: number } | null;
|
||||
fileTree?: FileTree;
|
||||
workspaceAnchor?: HTMLDivElement;
|
||||
onOpenFile: (entry: TreeEntry, line?: number, target?: "current" | "new") => void;
|
||||
onCreated: (entry: TreeEntry) => void;
|
||||
onSaveTemplate: (entry: TreeEntry) => void;
|
||||
onManageTemplates: () => void;
|
||||
onStatus: (message: string) => void;
|
||||
onChooseWorkspace: () => void;
|
||||
onHelp: () => void;
|
||||
onSettings: () => void;
|
||||
};
|
||||
let { workspace, session, leftView, keysActive, showInternal, activePath, searchRequest, fileTree = $bindable(), workspaceAnchor = $bindable(),
|
||||
onOpenFile, onCreated, onSaveTemplate, onManageTemplates, onStatus, onChooseWorkspace, onHelp, onSettings }: Props = $props();
|
||||
</script>
|
||||
|
||||
<aside class="left">
|
||||
<div class="left-body">
|
||||
{#if $pluginSidebar}
|
||||
{#key $pluginSidebar.key}<PluginEditor view={$pluginSidebar} />{/key}
|
||||
{/if}
|
||||
<div class="native-left" class:sidebar-covered={!!$pluginSidebar}>
|
||||
{#if !workspace}
|
||||
{#if leftView === "bookmarks"}<BrowserSlot kind="bookmarks" />{:else}<p class="placeholder">{$t("No folder is open.")}</p>{/if}
|
||||
{:else}
|
||||
<div class="left-stack">
|
||||
<div class="left-layer" class:shown={leftView === "files"}>
|
||||
<FileTree
|
||||
bind:this={fileTree}
|
||||
workspaceRoot={workspace.root}
|
||||
{showInternal}
|
||||
{onSaveTemplate}
|
||||
{onManageTemplates}
|
||||
{activePath}
|
||||
onOpenFile={(entry, newTab) => onOpenFile(entry, undefined, newTab ? "new" : "current")}
|
||||
{session}
|
||||
{keysActive}
|
||||
{onCreated}
|
||||
{onStatus}
|
||||
/>
|
||||
</div>
|
||||
{#if leftView === "search"}
|
||||
<SearchPane {searchRequest} onOpen={(entry, line) => onOpenFile(entry, line)} />
|
||||
{:else if leftView === "bookmarks"}
|
||||
<BookmarksPane {session} onOpen={(entry) => onOpenFile(entry)} />
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
<div class="left-footer">
|
||||
<div class="footer-start" bind:this={workspaceAnchor}>
|
||||
<IconButton icon="folder-open" label={$t("Open folder")} onclick={onChooseWorkspace} />
|
||||
<span class="ws">{workspace ? workspace.name : $t("No workspace")}</span>
|
||||
</div>
|
||||
<div class="footer-actions">
|
||||
<IconButton icon="help" label={$t("Help and about (F1)")} onclick={onHelp} />
|
||||
<IconButton icon="settings" label={$t("Settings (Ctrl+,)")} onclick={onSettings} />
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<style>
|
||||
.left {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
background: var(--rs-workarea-sidebar-bg);
|
||||
}
|
||||
|
||||
.left-body {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.left-body > :global(*) {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.native-left { display: flex; flex-direction: column; min-height: 0; }
|
||||
.native-left.sidebar-covered { display: none; }
|
||||
|
||||
.left-stack {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.left-layer {
|
||||
display: none;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.left-layer.shown {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.left-layer.shown > :global(*) {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.left-stack > :global(.pane) {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.left-footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
padding: 4px 6px;
|
||||
border-top: 1px solid var(--rs-border);
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
.footer-start {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.footer-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
|
||||
.footer-actions :global(.icon-btn) { width: 32px; height: 32px; flex-basis: 32px; }
|
||||
|
||||
.ws {
|
||||
color: var(--rs-text-dim);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.placeholder {
|
||||
margin: 12px;
|
||||
color: var(--rs-text-dim);
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user