mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-03 17:41:51 +00:00
fix(mobile): align the places browser's filter panel with the map control
The panel button is named "Filters" like the map control, its badge counts kinds of filter through countActivePlacesFilters (the pool, shown as chips above it, stays out), and picking a rating floor clears the selection as picking a pool does.
This commit is contained in:
@@ -23,6 +23,7 @@ import MPlacesBulkCategorySheet from './MPlacesBulkCategorySheet'
|
||||
import MPlacesSaveToCollectionSheet from './MPlacesSaveToCollectionSheet'
|
||||
import { filterPool, firstPlannedDayNumbers, plannedPlaceIds } from './placesBrowserModel'
|
||||
import { MCategoryFilterList, MRatingFloorChips, SquareCheck } from './MPlacesFilterControls'
|
||||
import { countActivePlacesFilters } from '../../../../utils/placesFilter'
|
||||
|
||||
/**
|
||||
* Fullscreen places pool (mode === 'browse'): All/Unplanned/Tracks filter
|
||||
@@ -142,8 +143,10 @@ export default function MPlacesBrowser({ planner, shell }: MPlacesBrowserProps)
|
||||
shell.openSheet('bract', { placeId: place.id, dayPicker: false })
|
||||
}
|
||||
|
||||
// The panel holds the categories and the rating floor; the badge counts both.
|
||||
const panelFilterCount = categoryFilters.size + (ratingFilter === 'all' ? 0 : 1)
|
||||
// The panel holds the categories and the rating floor; its badge counts them the
|
||||
// way the map's Filters badge does (one per kind of filter). The pool is left out:
|
||||
// its chips sit in plain sight above the panel.
|
||||
const panelFilterCount = countActivePlacesFilters({ filter: 'all', categoryFilters, ratingFilter })
|
||||
|
||||
return (
|
||||
<div className="flex h-full flex-col">
|
||||
@@ -196,7 +199,7 @@ export default function MPlacesBrowser({ planner, shell }: MPlacesBrowserProps)
|
||||
type="button"
|
||||
onClick={() => setCatOpen(v => !v)}
|
||||
aria-expanded={catOpen}
|
||||
aria-label={t('places.allCategories')}
|
||||
aria-label={t('places.filters')}
|
||||
className="relative flex w-[42px] flex-none items-center justify-center rounded-full border border-[color:var(--m-rowbr)] bg-[color:var(--m-ic)] text-m-muted"
|
||||
>
|
||||
<SlidersHorizontal size={15} strokeWidth={2} />
|
||||
@@ -289,7 +292,7 @@ export default function MPlacesBrowser({ planner, shell }: MPlacesBrowserProps)
|
||||
{catOpen && (
|
||||
<div className="mt-[6px] overflow-hidden rounded-2xl border border-[color:var(--m-rowbr)] bg-[color:var(--m-glass)]">
|
||||
<div className="border-b border-[color:var(--m-rowbr)] px-[13px] py-[10px]">
|
||||
<MRatingFloorChips />
|
||||
<MRatingFloorChips onPick={() => setSelectedIds(new Set())} />
|
||||
</div>
|
||||
<MCategoryFilterList categories={categories} places={places} />
|
||||
</div>
|
||||
|
||||
@@ -86,15 +86,19 @@ export function MCategoryFilterList({ categories, places }: { categories: Catego
|
||||
)
|
||||
}
|
||||
|
||||
/** A minimum of stars, the same floors as the desktop list and the collections bar (#1435). */
|
||||
export function MRatingFloorChips() {
|
||||
/**
|
||||
* A minimum of stars, the same floors as the desktop list and the collections bar
|
||||
* (#1435). `onPick` runs after a floor is chosen: the places browser drops its
|
||||
* selection then, as it does for a new pool.
|
||||
*/
|
||||
export function MRatingFloorChips({ onPick }: { onPick?: () => void } = {}) {
|
||||
const { t } = useTranslation()
|
||||
const ratingFilter = useTripStore(s => s.placesRatingFilter)
|
||||
const setRatingFilter = useTripStore(s => s.setPlacesRatingFilter)
|
||||
return (
|
||||
<div role="group" aria-label={t('places.filterByRating')} className="flex flex-wrap gap-[6px]">
|
||||
{RATING_FLOORS.map(floor => (
|
||||
<MChip key={String(floor)} size="tap" pressable active={ratingFilter === floor} onClick={() => setRatingFilter(floor)}>
|
||||
<MChip key={String(floor)} size="tap" pressable active={ratingFilter === floor} onClick={() => { setRatingFilter(floor); onPick?.() }}>
|
||||
{floor === 'all' ? t('common.all') : (
|
||||
<>
|
||||
<Star size={12} strokeWidth={2.2} fill="currentColor" className="flex-none" />
|
||||
|
||||
Reference in New Issue
Block a user