mirror of
https://gitlab.com/ArkHost/HelixNotes.git
synced 2026-07-23 23:35:57 +02:00
Add settings to hide unused sidebar items (#153)
This commit is contained in:
@@ -1102,11 +1102,21 @@ pub fn set_general_settings(
|
||||
enable_wiki_links: bool,
|
||||
show_note_dates: 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> {
|
||||
let mut config = state.config.lock().map_err(|e| e.to_string())?;
|
||||
config.compact_notes = compact_notes;
|
||||
config.show_note_dates = show_note_dates;
|
||||
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.week_start = week_start;
|
||||
config.daily_title_format = daily_title_format;
|
||||
|
||||
@@ -99,6 +99,16 @@ pub struct AppConfig {
|
||||
pub show_line_numbers: bool,
|
||||
#[serde(default = "default_true")]
|
||||
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)]
|
||||
pub backup_enabled: bool,
|
||||
#[serde(default = "default_backup_frequency")]
|
||||
@@ -221,6 +231,11 @@ impl Default for AppConfig {
|
||||
hide_title_in_body: false,
|
||||
show_line_numbers: false,
|
||||
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_frequency: "24h".to_string(),
|
||||
backup_max_count: 10,
|
||||
|
||||
@@ -239,6 +239,11 @@ export async function setGeneralSettings(
|
||||
enableWikiLinks: boolean,
|
||||
showNoteDates: boolean,
|
||||
restoreLastSession: boolean,
|
||||
showAllNotes: boolean,
|
||||
showQuickAccess: boolean,
|
||||
showTasks: boolean,
|
||||
showDailyNotes: boolean,
|
||||
showTrash: boolean,
|
||||
): Promise<void> {
|
||||
return invoke("set_general_settings", {
|
||||
compactNotes,
|
||||
@@ -259,6 +264,11 @@ export async function setGeneralSettings(
|
||||
enableWikiLinks,
|
||||
showNoteDates,
|
||||
restoreLastSession,
|
||||
showAllNotes,
|
||||
showQuickAccess,
|
||||
showTasks,
|
||||
showDailyNotes,
|
||||
showTrash,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<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 { darkThemes } from '$lib/platform';
|
||||
|
||||
@@ -26,6 +26,16 @@
|
||||
$showSearch = true;
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'open-trash',
|
||||
label: 'Open Trash (restore deleted notes)',
|
||||
action: () => {
|
||||
$viewMode = 'trash';
|
||||
$activeNotebook = null;
|
||||
$activeTag = null;
|
||||
$showCommandPalette = false;
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'theme-light',
|
||||
label: 'Switch to Light Theme',
|
||||
|
||||
@@ -522,6 +522,13 @@
|
||||
let closeToTray = $state($appConfig?.close_to_tray ?? false);
|
||||
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 = [
|
||||
{ label: 'Small', value: 300 },
|
||||
{ label: 'Medium', value: 450 },
|
||||
@@ -579,8 +586,13 @@
|
||||
$appConfig.show_tray_icon = showTrayIcon;
|
||||
$appConfig.close_to_tray = closeToTray;
|
||||
$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));
|
||||
}
|
||||
|
||||
@@ -769,6 +781,11 @@
|
||||
pdfPreview = $appConfig.pdf_preview ?? false;
|
||||
pdfHeight = $appConfig.pdf_height ?? 600;
|
||||
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>
|
||||
|
||||
{#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">
|
||||
<h3>Time Format</h3>
|
||||
<div class="setting-options">
|
||||
|
||||
@@ -34,6 +34,16 @@
|
||||
const modKey = navigator.platform.startsWith('Mac') ? '⌘' : 'Ctrl';
|
||||
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 editValue = $state('');
|
||||
let renameInput: HTMLInputElement | null = $state(null);
|
||||
@@ -568,7 +578,7 @@
|
||||
|
||||
<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}
|
||||
<div class="sidebar-header">
|
||||
<button class="collapse-btn" onclick={() => ($sidebarCollapsed = !$sidebarCollapsed)} title="Toggle sidebar">
|
||||
@@ -592,7 +602,9 @@
|
||||
{/if}
|
||||
|
||||
{#if !$sidebarCollapsed}
|
||||
{#if anyNavItem}
|
||||
<nav class="sidebar-nav">
|
||||
{#if $appConfig?.show_all_notes !== false}
|
||||
<button
|
||||
class="nav-item"
|
||||
class:active={$viewMode === 'all'}
|
||||
@@ -604,7 +616,9 @@
|
||||
</svg>
|
||||
<span>All Notes</span>
|
||||
</button>
|
||||
{/if}
|
||||
|
||||
{#if $appConfig?.show_quick_access !== false}
|
||||
<button
|
||||
class="nav-item"
|
||||
class:active={$viewMode === 'quickaccess'}
|
||||
@@ -615,7 +629,9 @@
|
||||
</svg>
|
||||
<span>Quick Access</span>
|
||||
</button>
|
||||
{/if}
|
||||
|
||||
{#if $appConfig?.show_tasks !== false}
|
||||
<button
|
||||
class="nav-item"
|
||||
class:active={$viewMode === 'tasks'}
|
||||
@@ -627,7 +643,9 @@
|
||||
</svg>
|
||||
<span>Tasks</span>
|
||||
</button>
|
||||
{/if}
|
||||
|
||||
{#if $appConfig?.show_daily_notes !== false}
|
||||
<button
|
||||
class="nav-item"
|
||||
class:active={$viewMode === 'daily'}
|
||||
@@ -641,7 +659,9 @@
|
||||
</svg>
|
||||
<span>Daily Notes</span>
|
||||
</button>
|
||||
{/if}
|
||||
|
||||
{#if $appConfig?.show_trash !== false}
|
||||
<button
|
||||
class="nav-item"
|
||||
class:active={$viewMode === 'trash'}
|
||||
@@ -653,7 +673,9 @@
|
||||
</svg>
|
||||
<span>Trash</span>
|
||||
</button>
|
||||
{/if}
|
||||
</nav>
|
||||
{/if}
|
||||
|
||||
<div class="section">
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
@@ -1031,6 +1053,12 @@
|
||||
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
|
||||
scrolls; the section's border-top draws the divider above it, matching the Tags section. (issue #126) */
|
||||
.section > .section-header {
|
||||
|
||||
@@ -69,6 +69,11 @@ export interface AppConfig {
|
||||
hide_title_in_body: boolean;
|
||||
show_line_numbers: 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_frequency: string;
|
||||
backup_max_count: number;
|
||||
|
||||
Reference in New Issue
Block a user