From 533760e0d858c821cee602377a15b692e1b94519 Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Sat, 28 Mar 2026 00:46:10 -0400 Subject: [PATCH] feat: implement 3-state has_cover filter and filter item component MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Template changes for bookshelf page: Cover filter (tristate button): - Replace checkbox with 3-state button: Any (null) → Has Cover → No Cover - Add Alpine state management for hasCoverState (true/false/null) - Button shows dynamic icon and label based on state: - ○ Cover: Any - ✓ Has Cover - ✗ No Cover - Hidden input conditionally rendered by Alpine (x-if="hasCoverState !== null") - Only submits "true"/"false" or not at all, never empty string - Theme-aware styling using CSS variables and color-mix() Filter management improvements: - Add name="library" attribute to library select for proper form submission - Create filter_item.templ component for rendering individual filter items - Add Load Filter and Delete Filter buttons with Alpine event handlers - Update save filter form to use HTMX attributes: - hx-post, hx-target, hx-swap, hx-include for AJAX submission - @htmx:afterRequest event for modal cleanup This fixes issues where: - Library wasn't being submitted with search/filter requests - has_cover was sending empty string causing no results - Saved filters couldn't be loaded or deleted --- templates/bookshelf.templ | 58 ++++++++++++++++++++--------- templates/bookshelf_templ.go | 28 +++++++------- templates/filter_item.templ | 28 ++++++++++++++ templates/filter_item_templ.go | 67 ++++++++++++++++++++++++++++++++++ 4 files changed, 149 insertions(+), 32 deletions(-) create mode 100644 templates/filter_item.templ create mode 100644 templates/filter_item_templ.go diff --git a/templates/bookshelf.templ b/templates/bookshelf.templ index 29fbca5..307969b 100644 --- a/templates/bookshelf.templ +++ b/templates/bookshelf.templ @@ -46,6 +46,7 @@ templ BookShelf( -
+
@@ -173,19 +176,31 @@ templ BookShelf( />
- -
-