Add settings to hide unused sidebar items (#153)

This commit is contained in:
Yuri Karamian
2026-06-22 12:52:07 +02:00
parent 209585a0b4
commit 3d28665e1e
7 changed files with 138 additions and 3 deletions
+10
View File
@@ -1102,11 +1102,21 @@ pub fn set_general_settings(
enable_wiki_links: bool, enable_wiki_links: bool,
show_note_dates: bool, show_note_dates: bool,
restore_last_session: bool, restore_last_session: bool,
show_all_notes: bool,
show_quick_access: bool,
show_tasks: bool,
show_daily_notes: bool,
show_trash: bool,
) -> Result<(), String> { ) -> Result<(), String> {
let mut config = state.config.lock().map_err(|e| e.to_string())?; let mut config = state.config.lock().map_err(|e| e.to_string())?;
config.compact_notes = compact_notes; config.compact_notes = compact_notes;
config.show_note_dates = show_note_dates; config.show_note_dates = show_note_dates;
config.restore_last_session = restore_last_session; config.restore_last_session = restore_last_session;
config.show_all_notes = show_all_notes;
config.show_quick_access = show_quick_access;
config.show_tasks = show_tasks;
config.show_daily_notes = show_daily_notes;
config.show_trash = show_trash;
config.time_format = time_format; config.time_format = time_format;
config.week_start = week_start; config.week_start = week_start;
config.daily_title_format = daily_title_format; config.daily_title_format = daily_title_format;
+15
View File
@@ -99,6 +99,16 @@ pub struct AppConfig {
pub show_line_numbers: bool, pub show_line_numbers: bool,
#[serde(default = "default_true")] #[serde(default = "default_true")]
pub show_link_arrows: bool, pub show_link_arrows: bool,
#[serde(default = "default_true")]
pub show_all_notes: bool,
#[serde(default = "default_true")]
pub show_quick_access: bool,
#[serde(default = "default_true")]
pub show_tasks: bool,
#[serde(default = "default_true")]
pub show_daily_notes: bool,
#[serde(default = "default_true")]
pub show_trash: bool,
#[serde(default)] #[serde(default)]
pub backup_enabled: bool, pub backup_enabled: bool,
#[serde(default = "default_backup_frequency")] #[serde(default = "default_backup_frequency")]
@@ -221,6 +231,11 @@ impl Default for AppConfig {
hide_title_in_body: false, hide_title_in_body: false,
show_line_numbers: false, show_line_numbers: false,
show_link_arrows: true, show_link_arrows: true,
show_all_notes: true,
show_quick_access: true,
show_tasks: true,
show_daily_notes: true,
show_trash: true,
backup_enabled: false, backup_enabled: false,
backup_frequency: "24h".to_string(), backup_frequency: "24h".to_string(),
backup_max_count: 10, backup_max_count: 10,
+10
View File
@@ -239,6 +239,11 @@ export async function setGeneralSettings(
enableWikiLinks: boolean, enableWikiLinks: boolean,
showNoteDates: boolean, showNoteDates: boolean,
restoreLastSession: boolean, restoreLastSession: boolean,
showAllNotes: boolean,
showQuickAccess: boolean,
showTasks: boolean,
showDailyNotes: boolean,
showTrash: boolean,
): Promise<void> { ): Promise<void> {
return invoke("set_general_settings", { return invoke("set_general_settings", {
compactNotes, compactNotes,
@@ -259,6 +264,11 @@ export async function setGeneralSettings(
enableWikiLinks, enableWikiLinks,
showNoteDates, showNoteDates,
restoreLastSession, restoreLastSession,
showAllNotes,
showQuickAccess,
showTasks,
showDailyNotes,
showTrash,
}); });
} }
+11 -1
View File
@@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import { showCommandPalette, showSearch, theme, sourceMode } from '$lib/stores/app'; import { showCommandPalette, showSearch, theme, sourceMode, viewMode, activeNotebook, activeTag } from '$lib/stores/app';
import { setTheme, reindex } from '$lib/api'; import { setTheme, reindex } from '$lib/api';
import { darkThemes } from '$lib/platform'; import { darkThemes } from '$lib/platform';
@@ -26,6 +26,16 @@
$showSearch = true; $showSearch = true;
} }
}, },
{
id: 'open-trash',
label: 'Open Trash (restore deleted notes)',
action: () => {
$viewMode = 'trash';
$activeNotebook = null;
$activeTag = null;
$showCommandPalette = false;
}
},
{ {
id: 'theme-light', id: 'theme-light',
label: 'Switch to Light Theme', label: 'Switch to Light Theme',
+58 -1
View File
@@ -522,6 +522,13 @@
let closeToTray = $state($appConfig?.close_to_tray ?? false); let closeToTray = $state($appConfig?.close_to_tray ?? false);
let enableWikiLinks = $state($appConfig?.enable_wiki_links ?? true); let enableWikiLinks = $state($appConfig?.enable_wiki_links ?? true);
// Sidebar item visibility
let showAllNotes = $state($appConfig?.show_all_notes ?? true);
let showQuickAccess = $state($appConfig?.show_quick_access ?? true);
let showTasks = $state($appConfig?.show_tasks ?? true);
let showDailyNotes = $state($appConfig?.show_daily_notes ?? true);
let showTrash = $state($appConfig?.show_trash ?? true);
const pdfHeightPresets = [ const pdfHeightPresets = [
{ label: 'Small', value: 300 }, { label: 'Small', value: 300 },
{ label: 'Medium', value: 450 }, { label: 'Medium', value: 450 },
@@ -579,8 +586,13 @@
$appConfig.show_tray_icon = showTrayIcon; $appConfig.show_tray_icon = showTrayIcon;
$appConfig.close_to_tray = closeToTray; $appConfig.close_to_tray = closeToTray;
$appConfig.enable_wiki_links = enableWikiLinks; $appConfig.enable_wiki_links = enableWikiLinks;
$appConfig.show_all_notes = showAllNotes;
$appConfig.show_quick_access = showQuickAccess;
$appConfig.show_tasks = showTasks;
$appConfig.show_daily_notes = showDailyNotes;
$appConfig.show_trash = showTrash;
} }
setGeneralSettings(compactNotes, timeFormat, weekStart, dailyTitleFormat, gpuAcceleration, autostart, pdfPreview, pdfHeight, titleMode, hideTitleInBody, showLineNumbers, showLinkArrows, defaultViewMode, showTrayIcon, closeToTray, enableWikiLinks, showNoteDates, restoreLastSession) setGeneralSettings(compactNotes, timeFormat, weekStart, dailyTitleFormat, gpuAcceleration, autostart, pdfPreview, pdfHeight, titleMode, hideTitleInBody, showLineNumbers, showLinkArrows, defaultViewMode, showTrayIcon, closeToTray, enableWikiLinks, showNoteDates, restoreLastSession, showAllNotes, showQuickAccess, showTasks, showDailyNotes, showTrash)
.catch((e) => console.error('Failed to save general settings:', e)); .catch((e) => console.error('Failed to save general settings:', e));
} }
@@ -769,6 +781,11 @@
pdfPreview = $appConfig.pdf_preview ?? false; pdfPreview = $appConfig.pdf_preview ?? false;
pdfHeight = $appConfig.pdf_height ?? 600; pdfHeight = $appConfig.pdf_height ?? 600;
titleMode = $appConfig.title_mode ?? 'input'; titleMode = $appConfig.title_mode ?? 'input';
showAllNotes = $appConfig.show_all_notes ?? true;
showQuickAccess = $appConfig.show_quick_access ?? true;
showTasks = $appConfig.show_tasks ?? true;
showDailyNotes = $appConfig.show_daily_notes ?? true;
showTrash = $appConfig.show_trash ?? true;
} }
}); });
@@ -892,6 +909,46 @@
</div> </div>
</div> </div>
{#if !isMobile}
<div class="settings-section">
<h3>Sidebar</h3>
<p class="setting-desc" style="margin: 0 0 10px;">Hide navigation items you don't use. The notebook tree always stays.</p>
<label class="setting-toggle">
<span class="setting-label"><span class="setting-name">All Notes</span></span>
<button class="toggle-switch" class:on={showAllNotes} onclick={() => { showAllNotes = !showAllNotes; saveGeneralSettings(); }}>
<span class="toggle-knob"></span>
</button>
</label>
<label class="setting-toggle">
<span class="setting-label"><span class="setting-name">Quick Access</span></span>
<button class="toggle-switch" class:on={showQuickAccess} onclick={() => { showQuickAccess = !showQuickAccess; saveGeneralSettings(); }}>
<span class="toggle-knob"></span>
</button>
</label>
<label class="setting-toggle">
<span class="setting-label"><span class="setting-name">Tasks</span></span>
<button class="toggle-switch" class:on={showTasks} onclick={() => { showTasks = !showTasks; saveGeneralSettings(); }}>
<span class="toggle-knob"></span>
</button>
</label>
<label class="setting-toggle">
<span class="setting-label"><span class="setting-name">Daily Notes</span></span>
<button class="toggle-switch" class:on={showDailyNotes} onclick={() => { showDailyNotes = !showDailyNotes; saveGeneralSettings(); }}>
<span class="toggle-knob"></span>
</button>
</label>
<label class="setting-toggle">
<span class="setting-label">
<span class="setting-name">Trash</span>
<span class="setting-desc">Deleted notes stay recoverable from the command palette (Ctrl/Cmd+P → Open Trash).</span>
</span>
<button class="toggle-switch" class:on={showTrash} onclick={() => { showTrash = !showTrash; saveGeneralSettings(); }}>
<span class="toggle-knob"></span>
</button>
</label>
</div>
{/if}
<div class="settings-section"> <div class="settings-section">
<h3>Time Format</h3> <h3>Time Format</h3>
<div class="setting-options"> <div class="setting-options">
+29 -1
View File
@@ -34,6 +34,16 @@
const modKey = navigator.platform.startsWith('Mac') ? '⌘' : 'Ctrl'; const modKey = navigator.platform.startsWith('Mac') ? '⌘' : 'Ctrl';
const isMobile = /android|iphone|ipad|ipod/i.test(navigator.userAgent); const isMobile = /android|iphone|ipad|ipod/i.test(navigator.userAgent);
// Whether any top nav item (All Notes, Quick Access, Tasks, Daily Notes, Trash) is visible.
// When all are hidden we drop the empty <nav> and its divider so the tree sits flush.
const anyNavItem = $derived(
$appConfig?.show_all_notes !== false ||
$appConfig?.show_quick_access !== false ||
$appConfig?.show_tasks !== false ||
$appConfig?.show_daily_notes !== false ||
$appConfig?.show_trash !== false
);
let editingNotebook = $state<string | null>(null); let editingNotebook = $state<string | null>(null);
let editValue = $state(''); let editValue = $state('');
let renameInput: HTMLInputElement | null = $state(null); let renameInput: HTMLInputElement | null = $state(null);
@@ -568,7 +578,7 @@
<svelte:window onclick={handleWindowClick} /> <svelte:window onclick={handleWindowClick} />
<aside class="sidebar" class:collapsed={$sidebarCollapsed} class:mobile={isMobile} ondblclick={startNewNotebookFromSidebar}> <aside class="sidebar" class:collapsed={$sidebarCollapsed} class:mobile={isMobile} class:nav-empty={!anyNavItem} ondblclick={startNewNotebookFromSidebar}>
{#if !isMobile} {#if !isMobile}
<div class="sidebar-header"> <div class="sidebar-header">
<button class="collapse-btn" onclick={() => ($sidebarCollapsed = !$sidebarCollapsed)} title="Toggle sidebar"> <button class="collapse-btn" onclick={() => ($sidebarCollapsed = !$sidebarCollapsed)} title="Toggle sidebar">
@@ -592,7 +602,9 @@
{/if} {/if}
{#if !$sidebarCollapsed} {#if !$sidebarCollapsed}
{#if anyNavItem}
<nav class="sidebar-nav"> <nav class="sidebar-nav">
{#if $appConfig?.show_all_notes !== false}
<button <button
class="nav-item" class="nav-item"
class:active={$viewMode === 'all'} class:active={$viewMode === 'all'}
@@ -604,7 +616,9 @@
</svg> </svg>
<span>All Notes</span> <span>All Notes</span>
</button> </button>
{/if}
{#if $appConfig?.show_quick_access !== false}
<button <button
class="nav-item" class="nav-item"
class:active={$viewMode === 'quickaccess'} class:active={$viewMode === 'quickaccess'}
@@ -615,7 +629,9 @@
</svg> </svg>
<span>Quick Access</span> <span>Quick Access</span>
</button> </button>
{/if}
{#if $appConfig?.show_tasks !== false}
<button <button
class="nav-item" class="nav-item"
class:active={$viewMode === 'tasks'} class:active={$viewMode === 'tasks'}
@@ -627,7 +643,9 @@
</svg> </svg>
<span>Tasks</span> <span>Tasks</span>
</button> </button>
{/if}
{#if $appConfig?.show_daily_notes !== false}
<button <button
class="nav-item" class="nav-item"
class:active={$viewMode === 'daily'} class:active={$viewMode === 'daily'}
@@ -641,7 +659,9 @@
</svg> </svg>
<span>Daily Notes</span> <span>Daily Notes</span>
</button> </button>
{/if}
{#if $appConfig?.show_trash !== false}
<button <button
class="nav-item" class="nav-item"
class:active={$viewMode === 'trash'} class:active={$viewMode === 'trash'}
@@ -653,7 +673,9 @@
</svg> </svg>
<span>Trash</span> <span>Trash</span>
</button> </button>
{/if}
</nav> </nav>
{/if}
<div class="section"> <div class="section">
<!-- svelte-ignore a11y_no_static_element_interactions --> <!-- svelte-ignore a11y_no_static_element_interactions -->
@@ -1031,6 +1053,12 @@
border-top: 1px solid var(--border-light); border-top: 1px solid var(--border-light);
} }
/* With the top nav hidden, the header's border-bottom is the only divider needed -
drop the section's border-top so there's no doubled line under the header. */
.sidebar.nav-empty .section {
border-top: none;
}
/* Pin the Notebooks header so its collapse/expand-all button stays reachable while the tree /* Pin the Notebooks header so its collapse/expand-all button stays reachable while the tree
scrolls; the section's border-top draws the divider above it, matching the Tags section. (issue #126) */ scrolls; the section's border-top draws the divider above it, matching the Tags section. (issue #126) */
.section > .section-header { .section > .section-header {
+5
View File
@@ -69,6 +69,11 @@ export interface AppConfig {
hide_title_in_body: boolean; hide_title_in_body: boolean;
show_line_numbers: boolean; show_line_numbers: boolean;
show_link_arrows: boolean; show_link_arrows: boolean;
show_all_notes: boolean;
show_quick_access: boolean;
show_tasks: boolean;
show_daily_notes: boolean;
show_trash: boolean;
backup_enabled: boolean; backup_enabled: boolean;
backup_frequency: string; backup_frequency: string;
backup_max_count: number; backup_max_count: number;