Skip to content

feat(calendar): add full-width CalendarView with region filter #76

Closed

Description

@Ardnived

Summary

Add a CalendarView — a full-width calendar surface for browsing events by date, complementing the map/list. Unlike the other drawer views (a narrow ≤22rem left panel on ≥md), the calendar spans the full width of the widget (minus the margins we already establish for the floating drawer) so a month grid is legible. It switches between Month / Week / Schedule (agenda) modes, reads the same URL-driven event filters as the rest of the app, and clicking an event navigates into the existing EventView. To support "what's on in this region", we also add a Region filter (a searchable single-select over all loaded regions) to the shared FilterView, plus a calendar entry-point button on the RegionView header that opens the calendar pre-scoped to that region.

Library: Schedule-X (@schedule-x/react + @schedule-x/calendar) — MIT, lightweight (this is a public embeddable bundle), built-in light/dark theming, and month-grid / week / agenda(list) views. Events are a controlled array we derive from the cached feed, which fits our filter-driven data model.

Proposed changes

Grouped into workstreams; land as coordinated PRs but tracked here as one feature.

1. Add Schedule-X + a full-width calendar surface

  • Add @schedule-x/react, @schedule-x/calendar, and the theme package (deps scope). Confirm the exact view constructors (month-grid / week / agenda-or-list) during implementation.
  • Theme Schedule-X's CSS variables (--sx-*) to our design tokens so it matches light/dark + accent; drive dark via useTheme().
  • Introduce a full-width variant of the drawer surface for this one view: on ≥md the calendar fills the widget container minus the established floating-drawer insets (lg:inset-y-4 lg:start-4), not the --sy-drawer-w (~22rem) left panel; on mobile it's the bottom sheet at the near-full snap. DrawerStack peek-strip/narrow-panel geometry must not assume the narrow width for this view.

2. CalendarView + routing

  • New src/views/CalendarView/ (view + story), dispatched by DrawerStack's TopView.
  • Route it as a top-level view like /search: add calendar to RESERVED_SLUGS, a { kind: 'calendar' } StackEntry, and resolveStack/TopView handling (src/lib/shape/path.ts, src/views/DrawerStack/DrawerStack.tsx).
  • Header mirrors SearchView: title + the FilterButton and CloseButton in the same right-aligned group and order. A Month/Week/Schedule switcher lives in the header/toolbar.

3. Event data → calendar entries (occurrences, timezone-correct)

  • Source events from the cached ['geojson'] feed joined with ['event-titles', locale] (same source as list/map), including online/placeless events — a calendar isn't geographic.
  • Expand each event's schedule.upcomingDates into one entry per occurrence in the visible range (events recur — DAILY/WEEKLY/MONTHLY), each linking back to the same event.
  • Place each occurrence with the app's existing timezone rule (eventTimeZone — event's own zone, viewer's zone for online, UTC when firstDate_tz is null), not naive JS-local time.
  • Apply the active URL filters via matchesFilters so calendar, list, and map agree.
  • Clicking an entry navigates to the event (event.path → EventView) via the atlas Link/navigate (camera/depth stamping).

4. Region filter (global) + searchable select

  • Extend EventFilters with region: string | null (slug); wire through DEFAULT_FILTERS, filtersToParams/filtersFromParams (?region=<slug>, validated against the loaded region set — unknown slug ⇒ no restriction), FILTER_PARAM_KEYS, filtersKey, activeFilterCount, and ActiveFilterPills.
  • Region-aware matching: an event matches when its region equals the selected region or is a descendant of it. matchesFilters today only sees FilterableEvent (eventType/languages/schedule); thread region ancestry in without regressing the map's hot path — resolve via the ['regions'] tree / feed region.id + ancestorIds. Decide the seam (optional ancestry-resolver arg, or apply the region cut where the index is already in hand).
  • New searchable-select atom: we have no combobox (the Select atom is Radix Select; the language filter is Dropdown+Checkbox). Add a searchable single-select atom (Radix Popover + filter input + filtered list, or cmdk) and use it for Region in SearchFilters. Options are the loaded regions restricted to those present in the feed; disambiguate same-named regions (show level/breadcrumb). New atoms/<Name>/ folder + story.
  • Scope: global — Region is a normal URL filter, so SearchView, the events list, the map, and the calendar all honor it (new pill + header badge everywhere).

5. FilterView origin-awareness

  • FilterView.commit currently hardcodes navigate('/search', …), so applying from the calendar would jump to Search. Make commit return to the origin view (calendar or search), preserving its query (region/center/bbox/q). The FilterButton already stacks <current>/filters (so /calendar/filters works); the fix is on apply/clear.

6. RegionView entry point

  • Add a calendar button to RegionView's header control group (next to Close, alongside SearchButton), reusing the existing CalendarIcon (src/components/atoms/Icons/symbols.tsx). Clicking opens /calendar?region=<slug> (pre-sets the Region filter).

7. i18n

  • Add labels across all locales via pnpm i18n:add (not en-only — these drift): calendar title, three view-mode labels, region filter label + search placeholder + empty state, and the calendar empty state. Weekday/month names come from luxon/Schedule-X locale.

Acceptance criteria

  • CalendarView opens at /calendar and, from the RegionView button, at /calendar?region=<slug> with the Region filter pre-set.
  • On ≥md the calendar spans full widget width minus the established floating-drawer margins; on mobile it's the bottom sheet at the near-full snap; it also works map-less/standalone (fills the container).
  • The view switches between Month, Week, and Schedule (agenda) modes.
  • Entries reflect event occurrences (recurring events show every upcoming occurrence in view), each placed in the correct timezone; online events appear.
  • The calendar honors the active URL filters (format/day/time/date/language/cadence and region) — its set matches list/map for the same filters.
  • Clicking a calendar entry opens the corresponding EventView.
  • The header shows FilterButton + CloseButton in the same position/order as SearchView; opening filters stacks /calendar/filters.
  • Applying/clearing filters from the calendar returns to the calendar (query preserved), not /search; from search it still returns to search.
  • FilterView has a Region filter: a searchable single-select over the loaded regions; typing filters the list; selecting sets ?region=<slug>; it contributes to the active count/badge + shows an ActiveFilterPill; "Clear" resets it.
  • Region matching includes the selected region's descendants (selecting a country shows its regions/areas/venues' events).
  • Schedule-X is themed to our tokens and follows light/dark (+ accent).
  • New/updated i18n keys exist in every locale.
  • Unit tests: region filter URL codec, activeFilterCount with region, region-aware matchesFilters (self + descendant + non-match). Node-only SSR for presentational atoms; calendar interaction exercised in Ladle/browser.
  • Lint + typecheck + test:run + build + ladle:build pass.
  • Verified in the running widget (map + map-less, mobile + ≥md; region-scoped open; event click → EventView).

Files affected

  • src/views/CalendarView/ (new), src/views/DrawerStack/DrawerStack.tsx, src/views/shared.tsx
  • src/lib/shape/path.ts (reserved slug, StackEntry, resolveStack), src/lib/shape/filters.ts (region filter + codec + matchesFilters)
  • src/components/molecules/SearchFilters/SearchFilters.tsx, src/components/molecules/ActiveFilterPills/
  • src/components/atoms/<SearchableSelect>/ (new) + atoms/index.ts
  • src/views/FilterView/FilterView.tsx (origin-aware commit), src/views/RegionView/RegionView.tsx (entry button)
  • src/hooks/use-filters.ts (if region plumbing needed), public/locales/*/common.json (+ events.json), package.json

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Hold Until

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions