From 558f3488815b644d2f898c6b81830b095168e3dd Mon Sep 17 00:00:00 2001 From: Maurice Date: Mon, 3 Aug 2026 19:40:04 +0200 Subject: [PATCH] feat(client): let the atlas hide countries you have not reached yet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Planned countries are off the map by default and come back through a switch above the globe, drawn dashed so they never read as somewhere you have been. The switch only appears once there is something planned to show, and it remembers its state. Three things that needed care: The colour palette is built from the visited countries alone. It assigns colours by index, so letting planned ones join would reshuffle the whole map every time the switch is flipped. countryMap decides both the tooltip and what a click does, so it is built from the visible countries — a hidden country has to fall through to the mark-as-visited branch or it becomes unclickable. The region layer read `data` without listing it as a dependency, which meant region colours already went stale on their own; adding the switch would have made that visible. Five copies of the optimistic mark-as-visited update have moved into withCountryMarkedVisited, which also promotes a planned country instead of adding it twice. Antarctica joins the continent row when someone has been. --- client/src/pages/AtlasPage.tsx | 50 ++++--- client/src/pages/AtlasPage.wiring.test.tsx | 51 ++++++- .../src/pages/atlas/AtlasLayerToggle.test.tsx | 39 +++++ client/src/pages/atlas/AtlasLayerToggle.tsx | 42 ++++++ client/src/pages/atlas/atlasModel.test.ts | 120 +++++++++++++++- client/src/pages/atlas/atlasModel.ts | 49 +++++++ client/src/pages/atlas/useAtlas.test.tsx | 116 ++++++++++++++- client/src/pages/atlas/useAtlas.ts | 133 +++++++++++++----- client/tests/helpers/atlas.ts | 23 ++- 9 files changed, 561 insertions(+), 62 deletions(-) create mode 100644 client/src/pages/atlas/AtlasLayerToggle.test.tsx create mode 100644 client/src/pages/atlas/AtlasLayerToggle.tsx diff --git a/client/src/pages/AtlasPage.tsx b/client/src/pages/AtlasPage.tsx index 41ae6874a..f259c9e27 100644 --- a/client/src/pages/AtlasPage.tsx +++ b/client/src/pages/AtlasPage.tsx @@ -6,10 +6,11 @@ import CustomSelect from '../components/shared/CustomSelect' import EmptyState from '../components/shared/EmptyState' import { Globe, MapPin, Briefcase, Calendar, Flag, PanelLeftOpen, PanelLeftClose, X, Star, Plus, Trash2, Search } from 'lucide-react' import type { TranslationFn } from '../types' -import { A2_TO_A3, countryCodeToFlag, type AtlasCountry, type AtlasStats, type AtlasData, type CountryDetail } from './atlas/atlasModel' +import { A2_TO_A3, countryCodeToFlag, withCountryMarkedVisited, type AtlasCountry, type AtlasStats, type AtlasData, type CountryDetail } from './atlas/atlasModel' import { continentForCountry } from '@trek/shared' import { useAtlas } from './atlas/useAtlas' import AtlasCountrySearch from './atlas/AtlasCountrySearch' +import AtlasLayerToggle from './atlas/AtlasLayerToggle' import { useToast } from '../components/shared/Toast' import { getApiErrorMessage } from '../types' import { useIsPhone } from '../mobile/useIsPhone' @@ -29,6 +30,7 @@ function AtlasPageDesktop(): React.ReactElement { mapRef, regionTooltipRef, panelRef, glareRef, borderGlareRef, handlePanelMouseMove, handlePanelMouseLeave, data, setData, stats, countries, selectedCountry, countryDetail, + showPlanned, togglePlanned, loadCountryDetail, handleUnmarkCountry, select_country_from_search, visitedRegions, setVisitedRegions, atlas_country_search, set_atlas_country_search, @@ -89,6 +91,12 @@ function AtlasPageDesktop(): React.ReactElement { options={atlas_country_options} onSelect={select_country_from_search} /> + {/* Mobile: Bottom bar */}
@@ -173,11 +181,7 @@ function AtlasPageDesktop(): React.ReactElement {