Skip to content

Add islands filtering controls and show/hide markers#77

Merged
fityannugroho merged 2 commits intomainfrom
feat-islands-filter
Aug 26, 2025
Merged

Add islands filtering controls and show/hide markers#77
fityannugroho merged 2 commits intomainfrom
feat-islands-filter

Conversation

@fityannugroho
Copy link
Owner

@fityannugroho fityannugroho commented Aug 26, 2025

Summary

This PR adds UI controls and a small context provider to filter island markers on the Map Dashboard. The main goal is to allow users to toggle filters for "Populated" and "Outermost-small" islands and to show/hide island markers entirely. When both filters are active the logic uses OR semantics (show islands that are populated OR outermost-small).

What I changed

  • Added a small provider to manage island filter state and derived values:

    • modules/MapDashboard/IslandsFilterProvider.tsx — new
      • Exposes filter ({ populated, outermostSmall }), setFilter, filteredIslands, counts, isLoading, showMarkers, and setShowMarkers.
      • Uses the existing useIslands() hook to fetch island data and compute derived values.
  • Wired the provider into the dashboard root so both the sidebar and map can access the state:

    • modules/MapDashboard/Dashboard.tsx — now wraps DashboardLayout with IslandsFilterProvider.
  • UI updates to control filters and show counts:

    • modules/MapDashboard/IslandsInfo.tsx — updated to consume useIslandsFilter() and render three controls:
      • Populated toggle (shows count)
      • Outermost-small toggle (shows count)
      • Show/Hide markers toggle
    • Replaced previous text display with shown / total islands shown and retained the loading state.
  • Map marker rendering respects the new show toggle and filter:

    • modules/MapDashboard/IslandMarkers.tsx — now reads filteredIslands and showMarkers from provider; returns null when showMarkers is false.

Design decisions / rationale

  • Provider vs. lifting state: I added a small React context provider (IslandsFilterProvider) that uses useIslands() internally. This avoids duplicating fetch logic and keeps a single source of truth for both the sidebar and map.

  • OR semantics for both toggles: When both Populated and Outermost-small are toggled on, the filter shows islands that match either attribute. This is more intuitive for users who want to see both categories at once. If AND semantics are preferred later, the provider centralizes the change.

  • Show/Hide markers: Adding showMarkers keeps the marker rendering decision local to the provider and prevents unnecessary map marker rendering when users want a cleaner view.

Files changed

  • Added: modules/MapDashboard/IslandsFilterProvider.tsx — provider + hook
  • Updated: modules/MapDashboard/Dashboard.tsx — provider wrapper
  • Updated: modules/MapDashboard/IslandsInfo.tsx — toggles UI + counts
  • Updated: modules/MapDashboard/IslandMarkers.tsx — use filteredIslands + showMarkers

Requirements coverage

  • Toggles for populated and outermost-small in IslandsInfo: Done
  • Toggle shows the number of filtered islands (replaces previous text): Done (counts.shown / counts.total shown)
  • State is sent to IslandMarkers so markers rendered match filter: Done (IslandMarkers consumes filteredIslands from the provider)
  • New control to show/hide all markers: Done (showMarkers toggle)

@fityannugroho fityannugroho changed the title Add islands filtering controls and show/hide markers (IslandsFilterProvider) Add islands filtering controls and show/hide markers Aug 26, 2025
@fityannugroho fityannugroho added the enhancement New feature or request label Aug 26, 2025
@fityannugroho fityannugroho merged commit 3762d9b into main Aug 26, 2025
6 checks passed
@fityannugroho fityannugroho deleted the feat-islands-filter branch August 26, 2025 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant