mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-05 18:34:09 +00:00
558f348881
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.
43 lines
1.6 KiB
TypeScript
43 lines
1.6 KiB
TypeScript
import React from 'react'
|
|
import ToggleSwitch from '../../components/Settings/ToggleSwitch'
|
|
import type { TranslationFn } from '../../types'
|
|
|
|
interface AtlasLayerToggleProps {
|
|
t: TranslationFn
|
|
showPlanned: boolean
|
|
onToggle: () => void
|
|
plannedCount: number
|
|
}
|
|
|
|
// Floating switch that reveals the countries you only plan to visit (#1048). Hidden
|
|
// entirely when there is nothing planned — an always-present control for an empty set
|
|
// is just clutter over the globe. Sits on the desktop map only; the mobile atlas has
|
|
// its own compact toggle in MAtlas.
|
|
export default function AtlasLayerToggle({ t, showPlanned, onToggle, plannedCount }: AtlasLayerToggleProps): React.ReactElement | null {
|
|
if (plannedCount <= 0) return null
|
|
|
|
return (
|
|
<div
|
|
className="absolute z-20 hidden md:flex"
|
|
style={{ top: 'calc(env(safe-area-inset-top, 0px) + 14px)', right: 18 }}
|
|
>
|
|
<div
|
|
className="flex items-center gap-3 rounded-full border border-edge"
|
|
style={{
|
|
padding: '8px 14px',
|
|
background: 'var(--bg-elevated)',
|
|
boxShadow: 'var(--shadow-popover)',
|
|
backdropFilter: 'blur(18px) saturate(180%)',
|
|
WebkitBackdropFilter: 'blur(18px) saturate(180%)',
|
|
}}
|
|
>
|
|
<span className="text-caption font-semibold text-content whitespace-nowrap">
|
|
{t('atlas.showPlanned')}
|
|
</span>
|
|
<span className="text-caption font-bold tabular-nums text-content-muted">{plannedCount}</span>
|
|
<ToggleSwitch on={showPlanned} onToggle={onToggle} label={t('atlas.showPlanned')} />
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|