Decision 3 correction and the owner's ribbon direction of 2026-10-28. - One bar at the bottom of the side pane holds the workspace switcher, Help, and Settings, as in Obsidian. The switcher opens the workspace list above it. The header has no workspace button. - While the side pane is closed, the workspace switcher, Help, and Settings move to the bottom of the left ribbon, so they stay reachable. - New browser tab, Terminal, Plug-in views, and Commands moved from the header to the top of the left ribbon, so the tabs have more room. Their menus open at the right of the ribbon. The header keeps Save, the outline toggle, and the window controls. A detached tab window has no ribbon and keeps these tools in its header. - Docs: decision 3 and the ribbon tools in UI-050, ui-design.md, and the user guide. Tests: layout/titleBar checks the bottom bar, the ribbon fallback, and the header buttons. workspace/openAndCreate uses the ribbon switcher in a narrow window. tree/renameUndo reads the tools in the ribbon.
142 lines
5.9 KiB
Svelte
142 lines
5.9 KiB
Svelte
<script lang="ts">
|
|
// The workbench header: the side pane buttons, the working tabs, Save, the outline toggle, and the window controls.
|
|
// The other tools are in the left ribbon (PluginRibbon.svelte). A detached tab window has no ribbon, so its header keeps them.
|
|
import type { ComponentProps } from "svelte";
|
|
import { t } from "$lib/i18n";
|
|
import IconButton from "$lib/ui/IconButton.svelte";
|
|
import WindowControls from "$lib/ui/WindowControls.svelte";
|
|
import PluginTools from "$lib/plugins/PluginTools.svelte";
|
|
import PluginAccessMenu from "$lib/plugins/PluginAccessMenu.svelte";
|
|
import { openPluginView, pluginSidebar } from "$lib/plugins/external";
|
|
import TabBar from "./TabBar.svelte";
|
|
import { commandShortcut } from "./workbenchKeys";
|
|
|
|
type LeftView = "files" | "search" | "bookmarks";
|
|
type Props = {
|
|
detached: boolean;
|
|
desktop: boolean;
|
|
leftOpen: boolean;
|
|
leftView: LeftView;
|
|
sidebarNavigation: { owner: string; id: string; title: string; icon?: string }[];
|
|
onSelectLeft: (view: LeftView) => void;
|
|
tabBar: ComponentProps<typeof TabBar>;
|
|
onNewTab: () => void;
|
|
canOpenBrowser: boolean;
|
|
browserOpening: boolean;
|
|
onOpenBrowser: () => void;
|
|
saveDisabled: boolean;
|
|
onSave: () => void;
|
|
terminalEnabled: boolean;
|
|
terminalOpen: boolean;
|
|
onToggleTerminal: () => void;
|
|
rightOpen: boolean;
|
|
onToggleRight: () => void;
|
|
onError: (message: string) => void;
|
|
};
|
|
let { detached, desktop, leftOpen, leftView, sidebarNavigation, onSelectLeft, tabBar, onNewTab, canOpenBrowser, browserOpening, onOpenBrowser,
|
|
saveDisabled, onSave, terminalEnabled, terminalOpen, onToggleTerminal, rightOpen, onToggleRight, onError }: Props = $props();
|
|
</script>
|
|
|
|
<header class="header" data-tauri-drag-region>
|
|
<div class="header-left" data-tauri-drag-region>
|
|
{#if !detached}
|
|
<IconButton icon="files" label={$t("Files")} active={leftOpen && !$pluginSidebar && leftView === "files"} onclick={() => onSelectLeft("files")} />
|
|
<IconButton icon="search" label={$t("Search")} active={leftOpen && !$pluginSidebar && leftView === "search"} onclick={() => onSelectLeft("search")} />
|
|
<IconButton icon="bookmark" label={$t("Bookmarks")} active={leftOpen && !$pluginSidebar && leftView === "bookmarks"} onclick={() => onSelectLeft("bookmarks")} />
|
|
{#each sidebarNavigation as item (`${item.owner}:${item.id}`)}
|
|
<IconButton
|
|
icon={item.icon === "list" || item.icon === "kanban" || item.icon === "globe" || item.icon === "git" ? item.icon : "puzzle"}
|
|
label={item.title}
|
|
active={leftOpen && $pluginSidebar?.owner === item.owner && $pluginSidebar?.id === item.id}
|
|
onclick={() => openPluginView(item.owner, item.id)}
|
|
/>
|
|
{/each}
|
|
{/if}
|
|
</div>
|
|
<div class="header-center" data-tauri-drag-region>
|
|
<TabBar {...tabBar} />
|
|
<IconButton icon="plus" label={$t("New tab ({shortcut})", { shortcut: commandShortcut("new-tab") })} onclick={onNewTab} />
|
|
{#if desktop}<div class="window-drag-space" data-tauri-drag-region aria-hidden="true"></div>{/if}
|
|
</div>
|
|
<div class="header-right" data-tauri-drag-region>
|
|
{#if detached}
|
|
{#if canOpenBrowser}<IconButton icon="globe" label={$t("New browser tab")} disabled={browserOpening} onclick={onOpenBrowser} />{/if}
|
|
<PluginAccessMenu surface="open" compact />
|
|
<PluginAccessMenu surface="commands" compact />
|
|
{#if terminalEnabled}<IconButton icon="terminal" label={$t("Terminal")} active={terminalOpen} onclick={onToggleTerminal} />{/if}
|
|
{/if}
|
|
<PluginTools />
|
|
<IconButton icon="save" label={$t("Save")} disabled={saveDisabled} onclick={onSave} />
|
|
{#if !detached}<IconButton icon="panel-right" label={rightOpen ? $t("Hide outline") : $t("Show outline")} active={rightOpen} onclick={onToggleRight} />{/if}
|
|
{#if desktop}<WindowControls {onError} />{/if}
|
|
</div>
|
|
</header>
|
|
|
|
<style>
|
|
.header {
|
|
grid-column: 1 / -1;
|
|
display: grid;
|
|
grid-template-columns: auto minmax(0, 1fr) auto;
|
|
align-items: center;
|
|
gap: 0;
|
|
padding: 0;
|
|
background: var(--rs-bg-elevated);
|
|
box-shadow: inset 0 -1px var(--rs-border);
|
|
user-select: none;
|
|
}
|
|
|
|
.header-left,
|
|
.header-right {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
gap: 2px;
|
|
min-width: 0;
|
|
padding: 0 4px;
|
|
}
|
|
/* The macOS traffic lights sit at the start of the header (src/lib/theme/tokens.css). */
|
|
.header-left { justify-content: flex-start; padding-left: calc(4px + var(--rs-titlebar-inset-start)); }
|
|
|
|
/* In a window below the minimum width, the center clips its content instead of drawing under the right group. */
|
|
.header-center {
|
|
overflow: hidden;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: flex-start;
|
|
gap: 6px;
|
|
min-width: 0;
|
|
padding: 0;
|
|
border-left: 1px solid var(--rs-border);
|
|
border-right: 1px solid var(--rs-border);
|
|
}
|
|
|
|
.header-left, .header-center, .header-right { height: 100%; }
|
|
/* The left group spans the ribbon and the open left pane (the shell sets the widths). */
|
|
:global(.shell.left-open) .header-left { width: calc(var(--ribbon-width) + var(--left) + 1px); }
|
|
.header-left :global(.icon-btn), .header-right :global(.icon-btn) { flex-shrink: 0; }
|
|
.header-right { justify-content: flex-end; }
|
|
/* A drag area keeps the window movable when the tabs fill the header: 120 pixels, and at least 48 in a narrow header. */
|
|
.window-drag-space { flex: 0 1 120px; min-width: 48px; align-self: stretch; }
|
|
|
|
/* The tab strip keeps room for one readable tab. It shrinks first, so the drag area shrinks only after it. */
|
|
.header-center :global(.tabs) {
|
|
flex: 0 1000 auto;
|
|
align-self: stretch;
|
|
min-width: 120px;
|
|
min-height: 28px;
|
|
background: transparent;
|
|
border-bottom: 0;
|
|
}
|
|
.header-center :global(.tab) {
|
|
flex: 0 1 180px;
|
|
width: 180px;
|
|
min-width: 120px;
|
|
max-width: 180px;
|
|
background: transparent;
|
|
}
|
|
|
|
.header-center :global(.tab.active) {
|
|
background: var(--rs-bg);
|
|
}
|
|
</style>
|