Give way in narrow windows and use one icon for each action

Phase 5-6.

- Side panes give way when the window becomes narrow: the outline
  below 1100 pixels, the side pane below 800 pixels. They come back
  when the window grows. A pane that the user opens in a narrow window
  stays open, and the saved layout keeps the wide-window choice.
- One function has one icon. The SDK icon set gets duplicate, template,
  and tab. The reveal action has one label for each platform (Show in
  Explorer, Show in Finder, Show in file manager).
- The file menu follows one order: open, clipboard, organize, show and
  copy path, history, then Delete and Delete permanently in the error
  color after a separator. The tree copies paths through a Copy path
  submenu, as the tab menu does.
- The tree uses the shared chevron. Search hits come in groups by file,
  with counts and marked matches. Bookmarks show the name, the folder,
  and a remove button.
- All boolean settings use one switch design (src/lib/ui/switch.css).
  Browser settings apply at once, and the Save button is gone. The
  Settings window opens with the focus on its search.
- Targets of at least 24 pixels: the tab close button, outline rows,
  switches, and the settings search.
- Catalog rows in French, Japanese, and Simplified Chinese.
- Docs: UI-052, ui-design.md, and the user guide.

Tests: the new layout/panesAndSettings. Tests that closed or opened
panes by hand around narrow windows now rely on the new behavior, or
wait for the panes to give way before they reopen one. Tests that read
the old menu labels or the browser Save button use the new ones.
This commit is contained in:
Knotty Wyvern
2026-10-28 21:31:36 -07:00
parent b7a9784f55
commit 0fdc991b2e
46 changed files with 590 additions and 351 deletions
+32 -6
View File
@@ -23,6 +23,7 @@
import { tabsToClose, type TabCloseScope } from "$lib/workspace/tabActions";
import { orderWorkbenchTabs, type WorkbenchTab } from "$lib/workspace/workbenchTabs";
import { actionMenu, type ActionMenuItem } from "$lib/ui/actionMenu";
import { revealLabel } from "$lib/ui/menuItems";
import { createNote, noteTemplates, saveNoteTemplate, type NoteTemplate } from "$lib/workspace/templates";
import { requestText } from "$lib/workspace/dialogs.svelte";
import TextDialog from "./TextDialog.svelte";
@@ -678,7 +679,7 @@
const items: ActionMenuItem[] = [];
if (tab.kind === "text" && isMarkdownPath(tab.relPath)) {
items.push(
{ label: $t("Save as template"), icon: "copy", run: () => { void saveTemplate({ name: tab.name, rel_path: tab.relPath, kind: "file" }); } },
{ label: $t("Save as template"), icon: "template", run: () => { void saveTemplate({ name: tab.name, rel_path: tab.relPath, kind: "file" }); } },
{ label: $t("View"), icon: "book", children: [
{ label: $t("Write"), icon: "paragraph", radio: true, checked: viewMode === "write", run: () => setDocumentView(documentPanes.active, "write") },
{ label: $t("Source"), icon: "code", radio: true, checked: viewMode === "source", run: () => setDocumentView(documentPanes.active, "source") },
@@ -691,13 +692,13 @@
items.push({ separator: true },
{ label: $t("Rename…"), icon: "rename", run: () => { void renameActive(); } },
);
if (tab.kind === "text") items.push({ label: $t("Save a copy…"), icon: "copy", run: () => { void saveCopy(); } });
if (tab.kind === "text") items.push({ label: $t("Save a copy…"), icon: "duplicate", run: () => { void saveCopy(); } });
items.push({ separator: true },
{ label: $t("Copy path"), icon: "copy", children: [
{ label: $t("Workspace path"), icon: "copy", run: () => { void copyTabPath(tab.relPath, false); } },
{ label: $t("System path"), icon: "copy", run: () => { void copyTabPath(tab.relPath, true); } },
] },
{ label: $t("Show in system explorer"), icon: "folder", run: () => { void workspaceReveal(tab.relPath).catch(err => { error = String(err); }); } },
{ label: $t(revealLabel()), icon: "folder", run: () => { void workspaceReveal(tab.relPath).catch(err => { error = String(err); }); } },
);
return items;
}
@@ -1041,7 +1042,7 @@
if (valid()) status = $t("Bookmarked {name}", { name: file.name });
}) },
{ label: $t("Open in default app"), icon: "external", run: run(file => workspaceOpenDefault(file.rel_path)) },
{ label: $t("Show in system explorer"), icon: "folder", run: run(file => workspaceReveal(file.rel_path)) },
{ label: $t(revealLabel()), icon: "folder", run: run(file => workspaceReveal(file.rel_path)) },
{ label: $t("Reveal file in navigation"), icon: "folder", run: run(async file => { closePluginSidebar(); leftView = "files"; leftOpen = true; await tick(); await fileTree?.revealPath(file.rel_path); }) },
];
}
@@ -1132,9 +1133,34 @@
} catch { error = $t("Could not read your layout. Default layout applies for this window."); }
});
// Side panes give way when the window becomes narrow: the outline below 1100 pixels, and the side pane below 800 pixels.
// They come back when the window grows again. A pane that the user opens in a narrow window stays open.
// At startup the saved layout applies as it is.
let windowWidth = $state(window.innerWidth);
let measured = false;
const narrow = { left: false, right: false };
const wide = { left: true, right: true };
$effect(() => {
if (!layoutReady || transferredWindow) return;
try { saveWorkbenchLayout(localStorage, { leftOpen, rightOpen, leftWidth, rightWidth, leftView }); }
const left = windowWidth < 800, right = windowWidth < 1100;
untrack(() => {
if (!measured) { measured = true; Object.assign(narrow, { left, right }); Object.assign(wide, { left: leftOpen, right: rightOpen }); return; }
if (right !== narrow.right) {
if (right) { wide.right = rightOpen; rightOpen = false; } else rightOpen = wide.right;
narrow.right = right;
}
if (left !== narrow.left) {
if (left) { wide.left = leftOpen; leftOpen = false; } else leftOpen = wide.left;
narrow.left = left;
}
});
});
// The saved layout keeps the choice of a wide window.
$effect(() => {
if (!layoutReady || transferredWindow) return;
const saved = { leftOpen: narrow.left ? wide.left : leftOpen, rightOpen: narrow.right ? wide.right : rightOpen };
try { saveWorkbenchLayout(localStorage, { ...saved, leftWidth, rightWidth, leftView }); }
catch { error = $t("Could not save your layout. Layout changes apply for this window only."); }
});
@@ -1209,7 +1235,7 @@
</script>
<svelte:window onkeydown={onKeydown} onbeforeunload={(event) => { if (hasDirty) { event.preventDefault(); event.returnValue = ""; } }} />
<svelte:window bind:innerWidth={windowWidth} onkeydown={onKeydown} onbeforeunload={(event) => { if (hasDirty) { event.preventDefault(); event.returnValue = ""; } }} />
<TextDialog />
<WorkspacePicker bind:this={workspacePicker} currentRoot={workspace?.root} anchor={workspaceAnchor} onOpen={openPath} />
{#if preferences}<SettingsDialog {settings} help={preferences === "help"} onSave={updateSettings} onClose={() => preferences = null} />{/if}