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 f23ee6e66a
commit a2fc2613b4
5 changed files with 302 additions and 0 deletions
+1
View File
@@ -21,6 +21,7 @@ import "./events";
import "./header";
import "./index";
import "./library";
import "./library-switcher";
import "./linking";
import "./login";
import "./password_validation";