feat(library-switcher): add shared library switcher component and module

Add reusable library switcher infrastructure that can be used across
dashboard, collections list, and collection detail pages.

New files:
- templates/library_switcher.templ: Shared LibrarySwitcher component
  with variadic actions slot for page-specific buttons (e.g. dashboard
  settings/refresh). Includes DashboardActions sub-component.
- web/src/library-switcher.ts: Shared module providing:
  - initLibrarySwitcher(): syncs dropdown with localStorage, attaches
    change listener with configurable onSwitch callback
  - switchWithTransition(): generic fade-out -> spinner -> fetch ->
    fade-in transition used by all pages
  - getCurrentLibraryId(): reads "selectedLibrary" from localStorage

Modified:
- web/src/main.ts: import new library-switcher module
- web/src/types/api.d.ts: add book_count field to CollectionData
This commit is contained in:
2026-05-17 21:11:47 -04:00
parent 158fcb510b
commit 59cb0e3439
5 changed files with 302 additions and 0 deletions
+1
View File
@@ -90,6 +90,7 @@ interface CollectionData {
icon: string;
auto_assign_rules?: unknown;
created_at: string;
book_count?: number;
}
// Matches handlers.BookInfo JSON response (internal/handlers/collections.go:66-71)