Skip to content

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

Closed

Description

@Ardnived

Summary

Hovering an event card in a list gives no feedback on the map — the only card↔map
link happens after navigation, when frameEvent selects the pin and flies to it.
Add a hover highlight: while the pointer is over an EventCard, that event's pin
is visually emphasized on the map (no camera movement), so users can connect list
entries to locations before clicking through. Applies everywhere EventCard
renders: search results (EventsList) and the region view.

Proposed changes

  • Store (src/config/store.ts): add a hover field to useViewState
    alongside selection — same shape ({ latitude, longitude, approximate } | null)
    — with a setHover action.
  • Controller seam (src/hooks/use-map-controller.tsx): add
    highlightEvent(event: EventSlim | null) to MapController. The real provider
    derives { latitude, longitude, approximate: isOnline(event) } exactly as
    frameEvent does, but only sets hover — it must not move the camera. The
    no-op provider does nothing, so cards never branch on map=false.
  • Layers (src/components/organisms/Mapbox/layers.ts): add a
    hoveredPointLayer (+ approximate/area variant) fed by a new hover source.
    Reuse the existing selected / cluster-selected sprites with distinct
    icon-size/icon-opacity so no Mapbox style change is needed (a dedicated
    hover sprite can come with feat(map): brand-colour the map markers and cluster paints #17). Definitions live in layers.ts, not inline JSX.
  • Map (src/components/organisms/Mapbox/Map.tsx): render the hover source
    mirroring the existing selection source (its own source, so the highlight
    shows even when the pin is inside a cluster at the current zoom). Do not
    add it to interactiveLayerIds.
  • Card (src/components/molecules/EventCard/EventCard.tsx): on the root
    Link, call highlightEvent(event) on onMouseEnter/onFocus and
    highlightEvent(null) on onMouseLeave/onBlur (keyboard parity). Clear the
    hover state on unmount so no stale highlight survives navigating away.

Acceptance criteria

  • Hovering an event card highlights that event's pin on the map; the camera
    does not move
  • Un-hovering (or the card unmounting) removes the highlight; clicking
    through hands over cleanly to the existing frameEvent selection
  • Works from both render sites: search results list and region view
  • Online events show the approximate-area highlight (like frameEvent);
    events without coordinates highlight nothing and don't error
  • Highlight renders even when the pin is clustered at the current zoom
  • Keyboard focus on a card behaves like hover (focus/blur parity)
  • With map=false, hovering is a no-op through the noop controller — no
    view/card branches on the map flag
  • Layer paint/layout defined in layers.ts; interactiveLayerIds unchanged
  • Lint + typecheck + test:run pass
  • Verified in the running widget (hover cards in search results and a region
    list with the map visible)

Files affected

  • src/config/store.ts
  • src/hooks/use-map-controller.tsx
  • src/components/organisms/Mapbox/layers.ts
  • src/components/organisms/Mapbox/Map.tsx
  • src/components/molecules/EventCard/EventCard.tsx

References

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