Files
RuneStone/src/lib/layout/LeftPane.svelte
T
Knotty Wyvern 9fc1490988 Make menus and hover fills translucent over a background image
With a background image, menus use the surface transparency of Appearance
(82% by default) instead of at least 92%, and they keep the blur.
Hovered rows and controls in the work area, hovered menu rows, and the
workspace button use the new --rs-hover-bg token. With an image, it is a
6% veil of the strong text color. The image stays visible, and the hover
shows over light and dark image areas. Without an image, nothing changes.

Silver Serpent dim text is now #c2c6cc. It keeps 4.5:1 contrast on a
hovered row over a white image.

UI-061 replaces the image rule of UI-043. Card 05b9bfa1.
2026-10-30 13:38:47 -07:00

179 lines
5.7 KiB
Svelte

<script lang="ts">
// The left pane: a plugin sidebar view, or the files, search, and bookmarks views, and the bar at its bottom with
// the workspace switcher, Help, and Settings. When the pane is closed, the left ribbon shows these three (PluginRibbon.svelte).
import { t } from "$lib/i18n";
import Icon from "$lib/ui/Icon.svelte";
import IconButton from "$lib/ui/IconButton.svelte";
import { attachTooltip } from "$lib/ui/tooltip";
import { commandShortcut } from "./workbenchKeys";
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?: HTMLElement;
onChooseWorkspace: () => void;
onHelp: () => void;
onSettings: () => void;
onOpenFile: (entry: TreeEntry, line?: number, target?: "current" | "new") => void;
onCreated: (entry: TreeEntry) => void;
onSaveTemplate: (entry: TreeEntry) => void;
onManageTemplates: () => void;
onStatus: (message: string) => void;
};
let { workspace, session, leftView, keysActive, showInternal, activePath, searchRequest, fileTree = $bindable(), workspaceAnchor = $bindable(),
onOpenFile, onCreated, onSaveTemplate, onManageTemplates, onStatus, onChooseWorkspace, onHelp, onSettings }: Props = $props();
function tooltip(node: HTMLElement, text: string) {
let current = text;
const dispose = attachTooltip(node, () => current);
return { update(value: string) { current = value; }, destroy: dispose };
}
</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">
<button class="workspace-button" bind:this={workspaceAnchor} onclick={onChooseWorkspace}
use:tooltip={$t("Open folder ({shortcut})", { shortcut: commandShortcut("open-workspace") })}>
<Icon icon="chevrons-up-down" /><span class="ws">{workspace ? workspace.name : $t("Open folder")}</span>
</button>
<IconButton icon="help" label={$t("Help and about ({shortcut})", { shortcut: commandShortcut("help") })} onclick={onHelp} />
<IconButton icon="settings" label={$t("Settings ({shortcut})", { shortcut: commandShortcut("settings") })} onclick={onSettings} />
</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;
}
.placeholder {
margin: 12px;
color: var(--rs-text-dim);
}
.left-footer {
display: flex;
flex: 0 0 auto;
align-items: center;
gap: 4px;
padding: 6px;
border-top: 1px solid var(--rs-border);
}
.workspace-button {
display: flex;
flex: 1;
align-items: center;
gap: 8px;
min-width: 0;
min-height: 32px;
padding: 0 10px;
border: 1px solid transparent;
border-radius: var(--rs-control-radius);
background: var(--rs-hover-bg);
color: var(--rs-text-strong);
font: 600 13px var(--rs-font-ui);
text-align: left;
}
.workspace-button:hover { border-color: var(--rs-border); }
.workspace-button :global(svg) { width: 16px; height: 16px; flex-shrink: 0; color: var(--rs-text-dim); }
.ws { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.left-footer :global(.icon-btn) { width: 32px; height: 32px; flex-basis: 32px; }
</style>