Repository navigation
Closed
Description
Summary
Add a filter button to the drawer headers of CountriesView and SearchView, sitting beside the geocoder search field and styled identically to the existing close button. Clicking it opens a filter panel (popover) whose settings narrow the events shown in the SearchView list and the event pins/clusters on the map. Today the widget has no way to narrow events by format, schedule, or language — useSearchState.onlineOnly exists but no UI sets it.
Proposed changes
Shared header icon-button atom
- Extract the
iconButtonchrome shared byCloseButton/CollapseToggle(src/views/shared.tsx:41-42) into anIconButtonatom (src/components/atoms/Button/), so the close, collapse, and new filter buttons render identically side by side. Migrate the two existing callers. - Add a
FilterIcon(funnel or sliders glyph) tosrc/components/atoms/Icons/actions.tsx.
Filter button + panel (new component, not part of MapSearch)
- Keep
MapSearcha thin Geocoder wrapper; build a newSearchFiltersmolecule (src/components/molecules/SearchFilters/) = trigger button + panel, and render it in both headers betweenSearchFieldand the close/collapse control (src/views/SearchView/SearchView.tsx:49-52,src/views/CountriesView/CountriesView.tsx:47-50). - Panel opens via the shared floating-ui
Dropdownatom withrole="dialog"+ariaLabel(the pattern from issue refactor(ui): unify dropdowns on a shared floating-ui Dropdown #12;SettingsMenuis the reference). Controls inside use Radix primitives per the issue refactor(ui): migrate components from NextUI to Radix UI #22 direction. If the popover proves cramped on small screens, the implementer may present the same panel content in a modal (@radix-ui/react-dialog, already a dep) belowmdinstead. - The trigger shows an active-filter indicator (count badge or dot) when any filter is non-default, and the panel has a "clear all" reset.
Filter options (fields all exist on FeedEvent, src/types/event.ts:82-94):
- Format — any / in-person / online (
eventType). Radix ToggleGroup or Select; replaces the booleanonlineOnly. - Time of day — one range with two handles (e.g. 0–24h in 30-min steps) over the event's local start–end time. Needs a new
Slideratom wrapping@radix-ui/react-slider(new dep, fits the existing Radix family). - Day of week — multi-select of the 7 weekdays (toggle pills;
@radix-ui/react-toggle-groupor the existingCheckbox). Weekday-name labels viaIntl/ luxon, honouring the active locale. - Language — multi-select checkbox list of the distinct
languagescodes present in the geojson feed (not hardcoded), labelled viaIntl.DisplayNames(locale, { type: 'language' }). - Cadence (suggested extra, optional) — weekly class / one-time or monthly event, from
schedule.recurrenceType.
State + shared predicate
- Extend
useSearchState(src/config/store.ts:30-43): replaceonlineOnlywithformat, addtimeOfDay: [number, number],daysOfWeek: number[],languages: string[](empty = no restriction), plus setters and aclearFiltersaction. Read with selectors/useShallowper the store conventions. - One pure, unit-tested predicate
matchesFilters(event, filters)insrc/lib/shape/shared by the list and the map. Semantics:- Day + time are evaluated together per occurrence: an event matches if any
schedule.upcomingDatesoccurrence falls on a selected weekday and starts within the time range (range treated as start-time window; useendTimeonly if trivially available). - Times evaluate in the event's own frame via
eventTimeZone(src/lib/shape/event.ts:22-23): the event's zone for in-person, the viewer's zone for online, UTC fallback for nullfirstDate_tz. - When a day/time filter is active, events with no
upcomingDatesare excluded (can't verify a match); with all filters at defaults every event passes.
- Day + time are evaluated together per occurrence: an event matches if any
Wiring
- List:
DynamicEventsList(src/components/organisms/EventsList/EventsList.tsx:31-49) reads the filter state from the store, includes it in the['events', …]queryKey, and applies the predicate — replacing theonlineOnlyplumbing throughgetEvents(src/config/api/fetch.ts:278-291). - Map:
Map.tsxderives auseMemo-filtered FeatureCollection from the cached geojson + the same predicate before feeding theevents<Source>(src/components/organisms/Mapbox/Map.tsx:139-151), so cluster counts reflect the filters (a layer-levelfilterwould leave stale cluster counts). Read filters via auseShallowselector — the map is the hot render path. - i18n: all new labels from
public/locales/<lng>/common.json(en + the other hand-maintained locales),%{var}interpolation.
Non-goals (follow-ups, out of scope)
- Region/country
eventCountbadges and RegionView children lists do not react to filters. - No URL persistence of filter state (zustand-only, matching
useSearchStatetoday); a?filters=param can be a follow-up.
Acceptance criteria
- Filter button appears beside the search field in both
CountriesViewandSearchViewheaders, visually identical to the close button (both render the sharedIconButtonatom) - Clicking it opens the filter panel; Escape / click-outside dismisses; controls are keyboard-accessible with labels
- Format, time-of-day (two-handle range), day-of-week, and language filters all narrow the SearchView list
- Map pins and cluster counts update to the same filtered set as filters change
- Trigger shows an active-filter indicator when any filter is non-default; "clear all" restores defaults (full list + all pins)
- Day/time filters evaluate in the event's local timezone (viewer's for online events); events without occurrence data are excluded only while a day/time filter is active
- Language options are derived from the feed and labelled per the active locale; new UI strings come from locale JSON (en + other locales in sync)
- Unit tests cover
matchesFiltersand the extended store; Ladle stories exist for the new atoms + panel - Lint + typecheck +
test:run+ build pass - Verified in the running widget (mobile bottom-sheet + desktop panel)
Files affected
src/views/shared.tsx— extractIconButton, add filter button to header compositionsrc/components/atoms/Button/— newIconButtonatom;src/components/atoms/Icons/actions.tsx—FilterIconsrc/components/atoms/Slider/— new Radix slider atom (@radix-ui/react-sliderdep)src/components/molecules/SearchFilters/— new filter button + panelsrc/views/CountriesView/CountriesView.tsx,src/views/SearchView/SearchView.tsx— header wiringsrc/config/store.ts— extendeduseSearchStatesrc/lib/shape/—matchesFilterspredicate (+ tests)src/components/organisms/EventsList/EventsList.tsx,src/config/api/fetch.ts— list wiringsrc/components/organisms/Mapbox/Map.tsx— filtered FeatureCollectionpublic/locales/*/common.json— new filter strings
References
- Radix migration: refactor(ui): migrate components from NextUI to Radix UI #22 · shared Dropdown: refactor(ui): unify dropdowns on a shared floating-ui Dropdown #12 · drawer-shell follow-ups: fix(ui): follow-up fixes for the nested-drawer navigation UI #35
- Filter fields:
FeedEventSchema(src/types/event.ts:82); tz helpereventTimeZone(src/lib/shape/event.ts:22)
Metadata
Metadata
Assignees
Labels
No labels
Type
Fields
Hold Until
None yet
Activity
feat(search): event filters — drawer, shared predicate, pills, distan…