From 22e14def5f0e2b6896220730d2084b9d1d343a72 Mon Sep 17 00:00:00 2001 From: beo3000 Date: Wed, 25 Feb 2026 08:34:11 +0100 Subject: [PATCH] feat: sidebar toggle (Ctrl+B, /sidebar command, toggle button) Co-Authored-By: Claude Sonnet 4.6 --- ka-note/VERSION | 2 +- .../src/lib/components/CommandBar.svelte | 15 +++++++++++ .../client/src/lib/stores/sidebarCollapsed.ts | 27 +++++++++++++++++++ ka-note/client/src/routes/+layout.svelte | 23 ++++++++++++++-- .../server/drizzle/0011_pages_is_favorite.sql | 2 +- 5 files changed, 65 insertions(+), 4 deletions(-) create mode 100644 ka-note/client/src/lib/stores/sidebarCollapsed.ts diff --git a/ka-note/VERSION b/ka-note/VERSION index ebb907e..b89c021 100644 --- a/ka-note/VERSION +++ b/ka-note/VERSION @@ -1 +1 @@ -1.1.71 \ No newline at end of file +1.1.73 \ No newline at end of file diff --git a/ka-note/client/src/lib/components/CommandBar.svelte b/ka-note/client/src/lib/components/CommandBar.svelte index f837380..7ba2e1e 100644 --- a/ka-note/client/src/lib/components/CommandBar.svelte +++ b/ka-note/client/src/lib/components/CommandBar.svelte @@ -5,6 +5,7 @@ import { allActiveContexts } from "$lib/stores/agenda"; import { allPages } from "$lib/stores/wiki"; import { currentScope, scopeSettings } from "$lib/stores/scopeContext"; + import { sidebarCollapsed } from "$lib/stores/sidebarCollapsed"; import { getOrCreateJournalTopic, createHistoryEntry, @@ -373,6 +374,20 @@ }); } + if ("/sidebar".startsWith(cmd)) { + actions.push({ + id: "cmd-sidebar", + type: "action", + icon: $sidebarCollapsed ? "▶" : "◀", + label: $sidebarCollapsed ? "Sidebar einblenden" : "Sidebar ausblenden", + badge: "BEFEHL", + action: () => { + sidebarCollapsed.toggle(); + closeBar(); + }, + }); + } + if ("/jf".startsWith(cmd)) { actions.push({ id: "cmd-jf", diff --git a/ka-note/client/src/lib/stores/sidebarCollapsed.ts b/ka-note/client/src/lib/stores/sidebarCollapsed.ts new file mode 100644 index 0000000..c967016 --- /dev/null +++ b/ka-note/client/src/lib/stores/sidebarCollapsed.ts @@ -0,0 +1,27 @@ +import { writable } from 'svelte/store'; + +const KEY = 'sidebarCollapsed'; + +function createSidebarCollapsed() { + const initial = typeof localStorage !== 'undefined' + ? localStorage.getItem(KEY) === 'true' + : false; + const { subscribe, set, update } = writable(initial); + + return { + subscribe, + toggle() { + update(v => { + const next = !v; + localStorage.setItem(KEY, String(next)); + return next; + }); + }, + set(value: boolean) { + localStorage.setItem(KEY, String(value)); + set(value); + }, + }; +} + +export const sidebarCollapsed = createSidebarCollapsed(); diff --git a/ka-note/client/src/routes/+layout.svelte b/ka-note/client/src/routes/+layout.svelte index 40a2c18..bc6f91b 100644 --- a/ka-note/client/src/routes/+layout.svelte +++ b/ka-note/client/src/routes/+layout.svelte @@ -5,6 +5,7 @@ import AiLockBanner from "$lib/components/AiLockBanner.svelte"; import CommandBar from "$lib/components/CommandBar.svelte"; import { commandBarOpen } from "$lib/stores/commandBar"; + import { sidebarCollapsed } from "$lib/stores/sidebarCollapsed"; import { seedIfEmpty } from "$lib/db/seed"; import { sync } from "$lib/sync/syncService"; import { refreshLockStatus } from "$lib/stores/aiLock"; @@ -81,6 +82,10 @@ e.preventDefault(); $commandBarOpen = !$commandBarOpen; } + if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "b") { + e.preventDefault(); + sidebarCollapsed.toggle(); + } } afterNavigate(({ to }) => { @@ -174,14 +179,28 @@
+ + {@render children()}
diff --git a/ka-note/server/drizzle/0011_pages_is_favorite.sql b/ka-note/server/drizzle/0011_pages_is_favorite.sql index 5a1176e..90a79f5 100644 --- a/ka-note/server/drizzle/0011_pages_is_favorite.sql +++ b/ka-note/server/drizzle/0011_pages_is_favorite.sql @@ -1 +1 @@ --- no-op: is_favorite column added in 0012_chunky_stature.sql +SELECT 1; -- no-op: is_favorite column added in 0012_chunky_stature.sql