Skip to content

feat(list): move filters to a list toolbar with a sort selector - #77

Merged
Ardnived merged 13 commits into
mainfrom
feat/list-toolbar-sort
Jul 26, 2026
Merged

Ardnived merged 13 commits into
mainfrom
feat/list-toolbar-sort

Conversation

@Ardnived

@Ardnived Ardnived commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Surfaces sorting (previously a hardcoded relevance score with no UI) and makes filter access legible, via a labeled toolbar on the search results.

  • SearchView (results): a ListToolbar above the list with a Filters button (opens the existing FilterView, active count in the label) and a Sort by menu — Recommended (default) / Closest / Soonest — persisted in the URL as ?sort=.
  • CountriesView (root browse index): filter access is an icon-only funnel in the header (with the active-count badge, matching the close/collapse controls) — no toolbar and no sort menu (sorting a country index is meaningless).
  • Sort is presentation, not a predicate: it re-sorts the already-fetched list client-side (never a refetch), stays out of filtersToParams/filtersKey/matchesFilters, and never lights the filter badge.

Changes

  • src/lib/shape/sort.ts — ?sort= codec (SortOrder, sortFromParams/sortToParams), separate from the filter codec; byDistance comparator added to event.ts.
  • src/hooks/use-sort.ts — useSortOrder/useSetSortOrder, mirroring useSetFilters.
  • src/components/organisms/EventsList/DynamicEventsList.tsx — the sort runs in useMemo(() => sortEvents(events, order), [events, order]) on the fetched list, so changing sort re-sorts without a refetch.
  • src/components/molecules/{SortMenu,ListToolbar}/ — new molecules (+ stories + barrel). SortMenu is a Radix DropdownMenu radio group opened modal={false} so it doesn't fight the vaul drawer.
  • src/views/shared.tsx — FilterButton gained an iconOnly variant (icon + count badge for the CountriesView header) alongside the labeled ghost button (SearchView toolbar), sharing one nav + count; preserveSearchState carries filters + sort through the place-search / nearby-prompt URL rebuilds.
  • src/views/{SearchView,CountriesView} — toolbar on Search; header icon filter on Countries.
  • public/locales/*/common.json — sort.* labels across all 10 locales.

Merged with main

Merged main (#74 UI bug-sweep) into the branch and resolved the conflicts: re-applied the sort feature onto main's split-out DynamicEventsList.tsx, combined the NearbySuggestion→GeolocationSuggestion rename with the toolbar, and kept both my sort.* keys and main's new search/back/close/explore/settings label keys across the 9 non-en locales.

Verification

  • Lint ✓ · Typecheck ✓ · 389 unit tests ✓ (incl. sort.test.ts) · pnpm build ✓ · ladle:build ✓ (all re-run post-merge).
  • Verified in the running widget (pre-merge) against the seeded backend: header funnel gone on Search; Closest → strictly ascending distances; Recommended ≠ Closest; deep-link ?sort= + Filters round-trip preserve the sort; no refetch.

Notes for reviewer

  • Sort ⟂ filters is deliberate (own URL slice, never keys the events query or the filter badge). Documented in .claude/rules/i18n-and-state.md.
  • Per-view filter divergence is intentional: SearchView (a results list) gets the labeled Filters + Sort toolbar; CountriesView (a browse index) gets a compact header filter icon.
  • Worth a touch-device check of the sort menu inside the drawer (the reason it uses modal={false}), and of main's updated Alert/drawer styling under the new toolbar.
  • The recent finalize commits are unsigned (the local ssh-agent dropped its identity mid-session); they collapse into the signed squash-merge, so it's cosmetic.

Closes #75

🤖 Generated with Claude Code

Ardnived and others added 7 commits July 24, 2026 08:03
Sort/label keys for the upcoming list toolbar sort menu
(Recommended / Closest / Soonest), added to every locale so they
don't ship en-only.

Refs #75

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Add the `?sort=` codec (SortOrder + sortFromParams/sortToParams, kept
separate from the filter codec so sort never keys the events query or
lights the filter badge), the useSortOrder/useSetSortOrder hook pair
(mirrors useSetFilters — replace nav, preserves other params, omits the
default), and a `byDistance` comparator for the "Closest" ordering.

Refs #75

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
ListToolbar is a thin justify-between controls row above a results list;
SortMenu is the ghost `Sort: <current>` trigger + Radix DropdownMenu
radio group (Recommended / Closest / Soonest), mirroring the SettingsMenu
selectable-menu pattern and reading/writing `?sort=`. Both get Ladle
stories and tier-barrel exports.

Refs #75

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Move the results sort out of the cached queryFn into a memo keyed on the
fetched list + `useSortOrder()`, so picking Recommended / Closest /
Soonest re-sorts client-side with no refetch (sort stays out of the
query key). Recommended keeps the existing relevance score; Closest uses
byDistance; Soonest uses byNextOccurrence.

Refs #75

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Drop the icon-only funnel from the Search and Countries drawer headers and
render a labeled list toolbar above the results instead: a ghost Filters
button (count in the label) on both views, plus a Sort menu (Recommended /
Closest / Soonest) on Search only. FilterButton becomes a labeled ghost
control, and searching a place / accepting the nearby prompt now carries
the current `?sort=` through the URL rebuild.

Closes #75

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Extract the duplicated "carry the URL-only filters + sort across a
re-search" round-trip in SearchField + NearbySuggestion into a single
named preserveSearchState helper.

Refs #75

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Address /code-review findings: open the sort DropdownMenu with
modal={false} so Radix's scroll-lock / pointer-events trap doesn't fight
the draggable vaul drawer, and drop the non-functional `truncate` on the
trigger label (it had no width bound, so it never ellipsized).

Refs #75

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 24, 2026 •

Copy link
Copy Markdown

Deploying sahajatlas with  Cloudflare Pages  Cloudflare Pages

Latest commit: a8599c1
Status: ✅  Deploy successful!
Preview URL: https://fa89b427.sahajatlas.pages.dev
Branch Preview URL: https://feat-list-toolbar-sort.sahajatlas.pages.dev

View logs

- i18n-and-state rule: sort is a third URL-derived slice (useSortOrder/
  useSetSortOrder, ?sort=), kept separate from filters (presentation, not
  a predicate — never refetches, never lights the badge).
- DESIGN_SYSTEM: add the ListToolbar + SortMenu molecule rows.
- CLAUDE.md: note the list sort order lives in the URL alongside filters.

Refs #75

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@Ardnived
Ardnived force-pushed the feat/list-toolbar-sort branch from a1cd57a to 4ad0315 Compare July 24, 2026 16:29
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 24, 2026 •

Copy link
Copy Markdown

Deploying sahajatlas-design with  Cloudflare Pages  Cloudflare Pages

Latest commit: a8599c1
Status: ✅  Deploy successful!
Preview URL: https://452e7fde.sahajatlas-design.pages.dev
Branch Preview URL: https://feat-list-toolbar-sort.sahajatlas-design.pages.dev

View logs

Ardnived and others added 5 commits July 25, 2026 14:43
Resolve conflicts against main's refactors:
- EventsList split: re-apply the sort feature (sortEvents / useSortOrder,
  no-refetch memo, byDistance/byNextOccurrence) onto main's new
  DynamicEventsList.tsx; EventsList.tsx keeps main's presentational-only form.
- SearchView / CountriesView: combine main's GeolocationSuggestion rename
  (was NearbySuggestion) with the new ListToolbar (+ SortMenu on search).
- locales: keep BOTH the sort.* block and main's search/back/close/explore/
  settings label keys across all 9 non-en common.json files.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
- ListToolbar: drop the vertical padding and bump horizontal to px-3 so the
  ghost buttons' content lands on the px-6 (listRow) gutter — aligning the
  Filters button with EventListItem (search) and ListItem (countries) content.
- CountriesView: add the SearchButton (jump to /search) to the header between
  the search field and the collapse/close control, matching RegionView.

Refs #75

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The country browse index gets its filter access back in the header as an
icon-only funnel (with the active-count badge), matching the close/collapse
controls, and drops the single-button ListToolbar. Add an `iconOnly` variant
to FilterButton so the header (icon) and SearchView's toolbar (labeled) share
one nav + count. SearchView's Filters + Sort toolbar is unchanged.

Refs #75

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
ListToolbar is now the SearchView results toolbar only; CountriesView (a
browse index) filters via a header icon and has no sort.

Refs #75

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@Ardnived
Ardnived merged commit 8ef8c61 into main Jul 26, 2026
4 checks passed
@Ardnived
Ardnived deleted the feat/list-toolbar-sort branch July 26, 2026 17:13
Ardnived added a commit that referenced this pull request Jul 26, 2026
Reconcile with #77 (filters → list toolbar + sort selector), which landed
on main after the previous merge. Source files (shared.tsx FilterButton
toolbar refactor, the new sort module) auto-merged cleanly; only the 10
locale files conflicted (both append a top-level object — my `calendar`
vs #77's `sort`), resolved to keep both.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(list): move filters to a list toolbar with a sort selector

1 participant