Skip to content

Commit e09405a

Browse files
committed
Places: keep the view tabs on collections; filter lists by place kind
- Opening Moments / Photos / Passport no longer wipes the header: the Visited / Favorites / Wishlist / Monuments / Countries tabs stay visible in every view, so a collection is one tap from the lists instead of a whole-page swap. - Add a place-kind filter (All / Cities / Monuments / Airports) to the Visited, Favorites and Wishlist lists, backed by the app's ONE shared "mode" so the map agrees. placeMatches now honours it ("Cities" also covers your own custom pins), and it's wired into the list-filter deps so switching kind re-filters live. tsc + 406 unit + e2e (filter-panel, a11y, smoke, wishlist) green.
1 parent ac16342 commit e09405a

2 files changed

Lines changed: 42 additions & 20 deletions

File tree

‎apps/postcards/src/features/filter/applyFilters.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ export function placeMatches(v: Visit, ref: ReferenceData, s: FilterState): bool
2828
// selected ones (empty = all). A saved record is never "unvisited", so a filter
2929
// of only "unvisited" excludes every saved place.
3030
if (s.status.length > 0 && !s.status.includes(v.status as FilterStatus)) return false;
31+
// Kind filter — the shared map "mode". "cities" also covers your own custom pins
32+
// (they ride with cities on the map); "monuments" = heritage sites; "airports" =
33+
// airports. "all" (the default) filters nothing by kind.
34+
if (s.mode === "cities" && v.place.kind !== "city" && v.place.kind !== "custom") return false;
35+
if (s.mode === "monuments" && v.place.kind !== "heritage") return false;
36+
if (s.mode === "airports" && v.place.kind !== "airport") return false;
3137
if (!mapDateMatches(v.date, s.date)) return false;
3238
if (s.folder && v.folder !== s.folder) return false;
3339
if (s.favoritesOnly && !v.favorite) return false;

‎apps/postcards/src/features/visits/PlacesScreen.tsx‎

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { PassportScreen } from "../passport/PassportScreen";
1818
import { ExperiencesScreen } from "../experiences/ExperiencesScreen";
1919
import { PhotoWall } from "./PhotoWall";
2020
import { ListPager } from "../../ui/ListPager";
21-
import { useFilters, currentFilters, type FilterStatus } from "../../lib/store/useFilters";
21+
import { useFilters, currentFilters, type FilterStatus, type FilterMode } from "../../lib/store/useFilters";
2222
import { placeMatches, sortPlaces, activeChips } from "../filter/applyFilters";
2323
import { FilterPanel } from "../../ui/FilterPanel";
2424
import { FilterSummary } from "../../ui/FilterSummary";
@@ -434,6 +434,7 @@ export function PlacesScreen() {
434434
filters.folder,
435435
filters.minPop,
436436
filters.sort,
437+
filters.mode,
437438
filters.favoritesOnly,
438439
filters.hasPhoto,
439440
filters.hasNote,
@@ -594,31 +595,30 @@ export function PlacesScreen() {
594595
setShown(100);
595596
};
596597

597-
// Moments / Photos / Passport are self-contained collections: the view-switcher
598-
// tabs (Visited/Wishlist/…) do nothing there, and Moments/Passport render their
599-
// own heading — so drop that double chrome and reclaim a header band on mobile.
600-
const isCollection = view === "moments" || view === "photos" || view === "passport";
598+
// Moments / Passport render their own heading, so hide the "Places" title there
599+
// to avoid a double heading — but the view-switcher tabs stay (see the header).
601600
const hideTitle = view === "moments" || view === "passport";
602601

603602
return (
604603
<section aria-label={t("places.aria")}>
605604
<div className="section-head">
606605
{!hideTitle && <h2>{t("places.title")}</h2>}
607-
{!isCollection && (
608-
<div className="segmented wrap" role="group" aria-label={t("places.viewAria")}>
609-
{TABS.map((t) => (
610-
<button
611-
key={t.id}
612-
type="button"
613-
aria-pressed={view === t.id}
614-
className={view === t.id ? "seg-on" : ""}
615-
onClick={() => switchView(t.id)}
616-
>
617-
{t.label}
618-
</button>
619-
))}
620-
</div>
621-
)}
606+
{/* The view tabs stay visible in EVERY view — including the Moments/Photos/
607+
Passport collections — so opening a collection doesn't wipe the page and
608+
strand you; one tap on Visited/Favorites/… is always the way back. */}
609+
<div className="segmented wrap" role="group" aria-label={t("places.viewAria")}>
610+
{TABS.map((t) => (
611+
<button
612+
key={t.id}
613+
type="button"
614+
aria-pressed={view === t.id}
615+
className={view === t.id ? "seg-on" : ""}
616+
onClick={() => switchView(t.id)}
617+
>
618+
{t.label}
619+
</button>
620+
))}
621+
</div>
622622
<div
623623
className="segmented wrap places-collections"
624624
role="group"
@@ -679,6 +679,22 @@ export function PlacesScreen() {
679679
sort / growth are shared, so both screens agree. */}
680680
{isListView && (
681681
<div className="places-filter-row">
682+
{/* Filter the list by place kind (the app's ONE shared "mode", so the map
683+
agrees): All / Cities / Monuments / Airports — "Cities" also covers your
684+
own custom pins. */}
685+
<div className="segmented wrap places-kind" role="group" aria-label={t("filter.mode.title")}>
686+
{(["all", "cities", "monuments", "airports"] as FilterMode[]).map((m) => (
687+
<button
688+
key={m}
689+
type="button"
690+
aria-pressed={filters.mode === m}
691+
className={filters.mode === m ? "seg-on" : ""}
692+
onClick={() => filters.set({ mode: m })}
693+
>
694+
{t(`filter.mode.${m}` as const)}
695+
</button>
696+
))}
697+
</div>
682698
<button
683699
type="button"
684700
className={"chip filter-open-chip" + (placesFilterActive ? " chip-on" : "")}

0 commit comments

Comments
 (0)