feat(facets+ui): clickable facet values everywhere, genre prettify, active-filter chips
Frontend half of the faceted-navigation Phase 2. 'Everything filterable should be clickable': every displayed facet value links to the bookshelf pre-filtered by its raw stored value; display forms are prettified at render, never in the DB. - templates/facet_links.templ: FacetLink (inline links) + FacetBadge (badge links) to /bookshelf?<facet>_filter=<value>; the raw value rides the param while the shown text is prettified, so matching and display can never disagree. Series/tags keep their dedicated pages by design; the card media-type icon stays unlinked (a derived kind, not a column value — deep-linking it would send wrong values). - book_detail.templ: publisher, language, edition, genre, imprint cells + narrators line + age-rating/story-arc badges are now links. - prettifyGenre (templates/utils.go + unit tests): title-cases only entirely-lowercase values; small words stay down except first position; & preserved. TS port for chip labels documents the twin. - bookshelf.templ + bookshelf.ts: active-filter chips bar — Alpine renders chips from client-local form state (sanctioned island); one bubbled htmx:afterRequest hook keeps chips + shareable URL in sync; removeFilterChip clears the facet and re-applies. URL deep links now accept all 18 facet params (hidden inputs where the drawer has no field). Pins changelog: Batch B/C entry in docs/contract_pins.md. Rendering ownership guard (make lint-rendering) green.
This commit is contained in:
1 parent
7e586df48a
commit
bbedbfb13f
10 files changed
+990
-545
No files matched your search
@@ -95,3 +95,27 @@ func TestLibraryTypeDisplayName(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestPrettifyGenre(t *testing.T) {
|
||||
cases := []struct{ in, want string }{
|
||||
{"science fiction", "Science Fiction"},
|
||||
{"sword & sorcery", "Sword & Sorcery"},
|
||||
{"action & adventure", "Action & Adventure"},
|
||||
{"war & military", "War & Military"},
|
||||
{"historical fiction", "Historical Fiction"},
|
||||
{"children's", "Children's"},
|
||||
{"middle grade", "Middle Grade"},
|
||||
{"fiction", "Fiction"},
|
||||
// Small words stay down except in first position.
|
||||
{"towers of midnight", "Towers of Midnight"},
|
||||
// Mixed case = user-authored; verbatim.
|
||||
{"Science Fiction", "Science Fiction"},
|
||||
{"HardSF", "HardSF"},
|
||||
{"", ""},
|
||||
}
|
||||
for _, c := range cases {
|
||||
if got := prettifyGenre(c.in); got != c.want {
|
||||
t.Errorf("prettifyGenre(%q) = %q, want %q", c.in, got, c.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user