Skip to content

feat(map): highlight an event's pin when hovering its card - #49

Merged
Ardnived merged 5 commits into
mainfrom
feat/card-hover-highlight
Jul 14, 2026
Merged

Ardnived merged 5 commits into
mainfrom
feat/card-hover-highlight

Conversation

@Ardnived

Copy link
Copy Markdown
Contributor

Summary

  • Hovering (or keyboard-focusing) an event card now emphasizes that event's pin on the map — with no camera movement — so users can connect a list entry to its location before clicking through.
  • Works at every EventCard render site (search results + region / online views) with no per-site wiring, driven through the existing MapController seam — so it's a clean no-op when the widget renders without a map (map=false), and no card branches on the map flag.

Changes

  • src/config/store.ts — add a transient hover slice to useViewState (mirrors selection); extract the shared MapPoint type.
  • src/hooks/use-map-controller.tsx — add highlightEvent(event) to the MapController seam; derive the point via a shared eventPoint() helper (identical to frameEvent), but set hover only — never the camera.
  • src/components/organisms/Mapbox/layers.ts — hoveredPointLayer / hoveredAreaLayer reuse the selected / cluster-selected sprites (enlarged, slightly translucent) from a dedicated hover source; not added to interactiveLayerIds.
  • src/components/organisms/Mapbox/Map.tsx — render the hover source; the near-identical selection and hover sources are collapsed into one module-private PointSource. The hover source is independent of the clustered events source, so the highlight shows even when the pin is clustered.
  • src/components/molecules/EventCard/EventCard.tsx — onMouseEnter/onFocus → highlight, onMouseLeave/onBlur + unmount cleanup → clear.

Verification

  • Lint: ✓ (pnpm lint)
  • Types: ✓ (pnpm typecheck)
  • Tests: ✓ 163, incl. a new setHover store test (pnpm test:run)
  • Build: N/A locally — CI runs pnpm build + ladle:build.

Manual / visual verification

Driven in the running widget (Playwright, live data) from the region view (/italy/lazio/rome):

  1. Hovering an offline card renders its pin as the enlarged selected sprite at the event's coordinates; the map camera does not move (center/zoom unchanged).
  2. Un-hovering (or moving to a non-card element) removes the highlight.
  3. Keyboard focus on a card highlights its pin; blur clears it (focus/blur parity).
  4. The highlight renders even though the event sits in a clustered feed at that zoom (the hover source is separate from the clustered events source).
  5. Clicking through clears the hover and hands over cleanly to the existing frameEvent selection (selection pin renders at zoom 15).
  6. Online events in the dataset carry no coordinates → they highlight nothing and don't error (same as frameEvent).

Notes for reviewer

  • Online / approximate-area path: highlightEvent uses the same approximate → area sprite logic as frameEvent. In the current data all 28 online events lack coordinates, so neither frames nor highlights them (correct "no coords → nothing"); the hoveredAreaLayer branch is therefore not visually exercised but is symmetric to the verified point path.
  • Unmount cleanup reads highlightEvent through a ref with [] deps so it fires only on real unmount — highlightEvent's identity changes when a breakpoint-driven padding update rebuilds the controller, and depending on it would wipe a live highlight mid-hover (caught in code review; fixed in its own commit).
  • Dismissed review finding (low): after closing an event drawer, vaul restores focus to the clicked card → onFocus re-shows the highlight with no pointer present. This is the intended focus-parity behavior and self-clears on blur, so it's left as-is.
  • Sprite emphasis reuses the existing selected sprites (enlarged + icon-opacity); a dedicated hover sprite can land with feat(map): brand-colour the map markers and cluster paints #17.

Closes #44

🤖 Generated with Claude Code

Ardnived and others added 3 commits July 14, 2026 15:48
Hovering (or keyboard-focusing) an EventCard now emphasizes that event's
pin on the map without moving the camera, so users can connect list
entries to locations before clicking through. Works at every EventCard
render site (search results + region views).

- store: add a transient `hover` slice to useViewState (mirrors
  `selection`), with `setHover`; extract the shared `MapPoint` shape.
- controller: add `highlightEvent(event)` to the MapController seam,
  deriving the point via a shared `eventPoint` helper (identical to
  `frameEvent`) but setting `hover` only — never the camera. The no-op
  provider does nothing, so cards don't branch on `map=false`.
- layers: `hoveredPointLayer` + `hoveredAreaLayer` reuse the
  `selected` / `cluster-selected` sprites (enlarged, slightly
  translucent) fed by a dedicated `hover` source — no style change.
- Map: render the `hover` source mirroring `selection` (its own source,
  so the highlight shows even when the pin is clustered); not added to
  `interactiveLayerIds`.
- EventCard: wire onMouseEnter/onFocus -> highlight, onMouseLeave/onBlur
  + unmount cleanup -> clear, so no stale highlight survives navigation.

Closes #44

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Collapse the near-identical `selection` and `hover` map sources into one
module-private `PointSource` component (export the shared `MapPoint`
type), so the single-point GeoJSON build lives in one place and the two
can't drift. No behavior change.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Per code review: the unmount-cleanup effect depended on `highlightEvent`,
whose identity changes when a breakpoint-driven map-padding update
rebuilds the MapController. That re-ran the cleanup mid-hover and wiped
the live highlight (and every mounted card cleared the shared hover
slot). Read `highlightEvent` through a ref and depend on `[]`, so the
cleanup fires only when the card actually unmounts.

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

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

Copy link
Copy Markdown

Deploying sahajatlas with  Cloudflare Pages  Cloudflare Pages

Latest commit: d16daaf
Status:⚡️  Build in progress...

View logs

Ardnived and others added 2 commits July 14, 2026 17:08
Set the map's fadeDuration to 0 so the card-hover highlight pin appears
immediately instead of fading in over Mapbox's default ~300ms. That is a
global map option (no per-layer control), so it also drops the fade on
the base pins/clusters and the selection pin — a snappier, consistent
appearance.

Refs #44

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…-off

Default the skill to implementing in an isolated git worktree (step 4:
EnterWorktree + branch rename + node_modules/.env.local setup notes),
remove it once the PR is open and CI is green (step 8: ExitWorktree), and
close with a required final-summary template (step 9) that links the PR
and gives a copy/paste command to switch the branch into the main
checkout for local review.

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

Copy link
Copy Markdown

Deploying sahajatlas-design with  Cloudflare Pages  Cloudflare Pages

Latest commit: d16daaf
Status: ✅  Deploy successful!
Preview URL: https://c9777060.sahajatlas-design.pages.dev
Branch Preview URL: https://feat-card-hover-highlight.sahajatlas-design.pages.dev

View logs

@Ardnived
Ardnived merged commit da4f43f into main Jul 14, 2026
3 of 4 checks passed
@Ardnived
Ardnived deleted the feat/card-hover-highlight branch July 14, 2026 16:16
Ardnived added a commit that referenced this pull request Jul 14, 2026
Brings in #49 (pin-hover highlight) and #50 (date-range filter). Two
conflicts, resolved by combining both sides:
- Map.tsx `filtered` memo + fetch.ts `getEvents`: keep #50's `today` arg to
  matchesFilters AND this branch's geometry-only toMapSource trim /
  per-locale titles join.

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(map): highlight an event's pin when hovering its card

1 participant