From e6f7f7297deb660d6e862691d78f179d158bf8a0 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 12 Apr 2026 22:44:24 +0500 Subject: [PATCH] feat: add sticky sidebar to chapter reader with ToC, progress, book info, and chapter nav --- .../books/[slug]/chapters/[n]/+page.svelte | 185 +++++++++++++++++- 1 file changed, 183 insertions(+), 2 deletions(-) diff --git a/ui/src/routes/books/[slug]/chapters/[n]/+page.svelte b/ui/src/routes/books/[slug]/chapters/[n]/+page.svelte index e36d4a1..424baf9 100644 --- a/ui/src/routes/books/[slug]/chapters/[n]/+page.svelte +++ b/ui/src/routes/books/[slug]/chapters/[n]/+page.svelte @@ -68,9 +68,10 @@ focusMode: boolean; playerStyle: PlayerStyle; pageLines: PageLines; + showSidebar: boolean; } - const LAYOUT_KEY = 'reader_layout_v2'; + const LAYOUT_KEY = 'reader_layout_v3'; const LINE_HEIGHTS: Record = { compact: 1.55, normal: 1.85, relaxed: 2.2 }; const READ_WIDTHS: Record = { narrow: '58ch', normal: '72ch', wide: 'min(90ch, 100%)' }; /** @@ -79,7 +80,7 @@ * shorter so fewer lines fit per page; More (+4rem) grows it for more lines. */ const PAGE_LINES_OFFSET: Record = { less: '4rem', normal: '0rem', more: '-4rem' }; - const DEFAULT_LAYOUT: LayoutPrefs = { readMode: 'scroll', lineSpacing: 'normal', readWidth: 'normal', paraStyle: 'spaced', focusMode: false, playerStyle: 'standard', pageLines: 'normal' }; + const DEFAULT_LAYOUT: LayoutPrefs = { readMode: 'scroll', lineSpacing: 'normal', readWidth: 'normal', paraStyle: 'spaced', focusMode: false, playerStyle: 'standard', pageLines: 'normal', showSidebar: true }; function loadLayout(): LayoutPrefs { if (!browser) return DEFAULT_LAYOUT; @@ -466,6 +467,12 @@
{/if} + +
+ + +
+ {#if !layout.focusMode}
@@ -864,6 +871,169 @@
{/if} +
+ + +{#if layout.showSidebar && !layout.focusMode} + +{/if} + +
+ {#if layout.readMode === 'scroll' && !layout.focusMode} {@const atTop = scrollProgress <= 0.01} @@ -1227,6 +1397,17 @@ {layout.focusMode ? 'On — audio & nav hidden' : 'Off'} + +