@@ -142,37 +142,66 @@ function CountryRow({
142142 if ( hit ) useUi . getState ( ) . openCity ( hit . id ) ;
143143 } ;
144144
145+ // Tapping a metric drills into Places, scoped to THIS country + the tier — and the
146+ // filter is the shared store, so it survives leaving and returning to the list.
147+ const drill = ( view : "cities" | "monuments" , minPop : number ) => ( ) => {
148+ useFilters . getState ( ) . set ( { country : c . iso2 , minPop, listOnly : false } ) ;
149+ useUi . getState ( ) . openPlaces ( view ) ;
150+ } ;
151+ // Cities coverage is a sliver of a huge denominator, so it often rounds to 0 —
152+ // floor a real, non-zero share to "<1%" so it never reads as "nothing seen".
153+ const pctText = ( p : number ) => {
154+ const s = formatPercent ( p ) ;
155+ return p > 0 && s === formatPercent ( 0 ) ? "<1%" : s ;
156+ } ;
157+
145158 // Slim summary meter: a tiny label + percentage + bar.
146159 const meter = ( labelKey : MessageKey , ariaKey : MessageKey , pctVal : number , color ?: string ) => (
147160 < div className = "cmeter" >
148161 < span className = "cmeter-cap" >
149- { t ( labelKey ) } < b > { formatPercent ( pctVal ) } </ b >
162+ { t ( labelKey ) } < b > { pctText ( pctVal ) } </ b >
150163 </ span >
151164 < Bar value = { pctVal } label = { t ( ariaKey , { name : c . name } ) } color = { color } />
152165 </ div >
153166 ) ;
154- // Full metric row (expanded): label, "x/y · pct" detail, bar.
167+ // Full metric row (expanded): label, "x/y · pct" detail, bar. With an onClick it
168+ // renders as a button that opens the matching, country-scoped Places list.
155169 const metric = (
156170 labelKey : MessageKey ,
157171 detailKey : MessageKey ,
158172 ariaKey : MessageKey ,
159173 visited : number ,
160174 total : number ,
161175 pctVal : number ,
162- color ?: string ,
163- ) => (
164- < div className = "metric" >
165- < div className = "metric-label" >
166- < span > { t ( labelKey ) } </ span >
167- < span className = "muted" > { t ( detailKey , { pct : formatPercent ( pctVal ) , visited, total } ) } </ span >
168- </ div >
169- < Bar value = { pctVal } label = { t ( ariaKey , { name : c . name } ) } color = { color } />
170- </ div >
171- ) ;
176+ color : string | undefined ,
177+ onClick ?: ( ) => void ,
178+ ) => {
179+ const body = (
180+ < >
181+ < div className = "metric-label" >
182+ < span > { t ( labelKey ) } </ span >
183+ < span className = "muted" > { t ( detailKey , { pct : pctText ( pctVal ) , visited, total } ) } </ span >
184+ </ div >
185+ < Bar value = { pctVal } label = { t ( ariaKey , { name : c . name } ) } color = { color } />
186+ </ >
187+ ) ;
188+ if ( ! onClick ) return < div className = "metric" > { body } </ div > ;
189+ return (
190+ < button
191+ type = "button"
192+ className = "metric metric-btn"
193+ onClick = { onClick }
194+ title = { t ( "stats.country.exploreHint" , { label : t ( labelKey ) , name : c . name } ) }
195+ >
196+ { body }
197+ </ button >
198+ ) ;
199+ } ;
172200
173201 const hasMega = c . megaCitiesTotal > 0 ;
174202 const MEGA_COLOR = "var(--stat-fav)" ;
175203 const BIG_COLOR = "var(--stat-been)" ;
204+ const CITY_COLOR = "var(--stat-air)" ;
176205 const REGION_COLOR = "var(--accent)" ;
177206
178207 return (
@@ -188,13 +217,16 @@ function CountryRow({
188217 < span className = "country-caret" aria-hidden >
189218 ›
190219 </ span >
191- { /* Only the meaningful tiers — mega (1M+), big (100k+), regions. Hidden once
192- open (the body shows the same, with counts) so nothing is duplicated. */ }
193- { ( hasMega || c . bigCitiesTotal > 0 || c . regionsTotal > 0 ) && (
220+ { /* Coverage tiers at a glance — cities (all), big (100k+), mega (1M+) and
221+ regions. Hidden once open (the body shows the same, with counts and as
222+ tappable drill-downs) so nothing is duplicated. */ }
223+ { ( c . citiesTotal > 0 || c . regionsTotal > 0 ) && (
194224 < div className = "country-meters" >
195- { hasMega && meter ( "stats.country.metricMega" , "stats.country.megaCityBarAria" , c . megaCityPct , MEGA_COLOR ) }
225+ { c . citiesTotal > 0 &&
226+ meter ( "stats.country.metricCities" , "stats.country.cityBarAria" , c . cityPct , CITY_COLOR ) }
196227 { c . bigCitiesTotal > 0 &&
197228 meter ( "stats.country.metricBigCities" , "stats.country.bigCityBarAria" , c . bigCityPct , BIG_COLOR ) }
229+ { hasMega && meter ( "stats.country.metricMega" , "stats.country.megaCityBarAria" , c . megaCityPct , MEGA_COLOR ) }
198230 { c . regionsTotal > 0 &&
199231 meter ( "stats.country.metricRegions" , "stats.country.regionBarAria" , c . regionPct , REGION_COLOR ) }
200232 </ div >
@@ -211,15 +243,19 @@ function CountryRow({
211243 { t ( "stats.country.openPage" ) } < span aria-hidden > ↗</ span >
212244 </ button >
213245
214- { hasMega &&
246+ { /* Each tier is tappable — it opens Places filtered to this country + tier,
247+ so you can browse (and add) exactly what it counts. Regions have no
248+ Places list of their own, so that one opens the country's full page. */ }
249+ { c . citiesTotal > 0 &&
215250 metric (
216- "stats.country.metricMega" ,
217- "stats.country.metricMegaDetail" ,
218- "stats.country.megaCityBarAria" ,
219- c . megaCitiesVisited ,
220- c . megaCitiesTotal ,
221- c . megaCityPct ,
222- MEGA_COLOR ,
251+ "stats.country.metricCities" ,
252+ "stats.country.metricCitiesDetail" ,
253+ "stats.country.cityBarAria" ,
254+ c . citiesVisited ,
255+ c . citiesTotal ,
256+ c . cityPct ,
257+ CITY_COLOR ,
258+ drill ( "cities" , 0 ) ,
223259 ) }
224260 { c . bigCitiesTotal > 0 &&
225261 metric (
@@ -230,6 +266,18 @@ function CountryRow({
230266 c . bigCitiesTotal ,
231267 c . bigCityPct ,
232268 BIG_COLOR ,
269+ drill ( "cities" , 100_000 ) ,
270+ ) }
271+ { hasMega &&
272+ metric (
273+ "stats.country.metricMega" ,
274+ "stats.country.metricMegaDetail" ,
275+ "stats.country.megaCityBarAria" ,
276+ c . megaCitiesVisited ,
277+ c . megaCitiesTotal ,
278+ c . megaCityPct ,
279+ MEGA_COLOR ,
280+ drill ( "cities" , 1_000_000 ) ,
233281 ) }
234282 { c . regionsTotal > 0 &&
235283 metric (
@@ -240,6 +288,7 @@ function CountryRow({
240288 c . regionsTotal ,
241289 c . regionPct ,
242290 REGION_COLOR ,
291+ ( ) => useUi . getState ( ) . openCountry ( c . iso2 ) ,
243292 ) }
244293 { c . heritageTotal > 0 &&
245294 metric (
@@ -250,6 +299,7 @@ function CountryRow({
250299 c . heritageTotal ,
251300 c . heritagePct ,
252301 "var(--stat-want)" ,
302+ drill ( "monuments" , 0 ) ,
253303 ) }
254304
255305 { detail && (
@@ -316,7 +366,9 @@ export function StatsView() {
316366 // 100k = big cities, 1M = megacities) via the app's ONE shared filter, so the
317367 // tile drills into exactly the cities it counts.
318368 function openCitiesFiltered ( minPop : number ) {
319- useFilters . getState ( ) . set ( { minPop } ) ;
369+ // A world-level tile: clear any country drill-down a card left set, so this
370+ // shows the tier across every country, not just the last one you opened.
371+ useFilters . getState ( ) . set ( { minPop, country : "" } ) ;
320372 useUi . getState ( ) . openPlaces ( "visited" ) ;
321373 }
322374 function flyToRegion ( iso2 : string ) {
0 commit comments