mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-05 18:34:09 +00:00
fix(mobile): refine places sheets and restore the round dock
Put the category icon beside place names, shorten translated tab labels, and give tab counts their own badges. Bring the save-to-list dialog and trip badges in line with mobile sheets, and restore the icon-only dock.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Bookmark, BookmarkCheck, Check, CheckCircle2, Loader2, Plus, X } from 'lucide-react'
|
||||
import { Bookmark, BookmarkCheck, Check, CheckCircle2, Loader2, Plus } from 'lucide-react'
|
||||
import MSheet from '../../mobile/components/MSheet'
|
||||
import MIconBtn from '../../mobile/components/MIconBtn'
|
||||
import { FormSheetBody, FormSheetHeader, FormSheetSection } from '../../mobile/screens/trip/sheets/PlSheetChrome'
|
||||
import { useTranslation } from '../../i18n'
|
||||
import { STATUS_META, nextStatus } from '../../pages/collections/collectionsModel'
|
||||
import { VISITED_EVERYWHERE_BUSY, useSaveToCollection } from './useSaveToCollection'
|
||||
@@ -14,46 +14,35 @@ import { VISITED_EVERYWHERE_BUSY, useSaveToCollection } from './useSaveToCollect
|
||||
export default function MSaveToCollectionSheet() {
|
||||
const { target, close, lists, loading, busyId, savedByCollection, unvisited, handleStatus, handleVisitedEverywhere, handleToggle, openCollections } = useSaveToCollection()
|
||||
const { t } = useTranslation()
|
||||
const title = t('collections.pickList')
|
||||
|
||||
return (
|
||||
<MSheet open={!!target} onClose={close} variant="card" material="glass" ariaLabel={t('collections.pickList')}>
|
||||
{/* Header — mirrors the place detail sheet: icon + title + target name + close */}
|
||||
<div className="flex-none px-[18px] pt-4">
|
||||
<div className="flex items-start gap-3">
|
||||
<span className="flex h-10 w-10 flex-none items-center justify-center rounded-[13px] bg-[color:var(--m-ic)] text-m-ink">
|
||||
<Bookmark size={18} strokeWidth={2} />
|
||||
</span>
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="text-[1rem] font-bold leading-snug">{t('collections.pickList')}</div>
|
||||
{target?.name && (
|
||||
<div className="mt-[2px] truncate font-geist text-[0.6875rem] text-m-muted">{target.name}</div>
|
||||
)}
|
||||
</div>
|
||||
<MIconBtn variant="neutral" size={34} onClick={close} ariaLabel={t('common.close')}>
|
||||
<X size={15} strokeWidth={2.2} />
|
||||
</MIconBtn>
|
||||
</div>
|
||||
</div>
|
||||
<MSheet open={!!target} onClose={close} variant="card" material="glass" ariaLabel={title} form>
|
||||
<FormSheetHeader
|
||||
icon={Bookmark}
|
||||
title={title}
|
||||
subtitle={<bdi>{target?.name}</bdi>}
|
||||
onClose={close}
|
||||
closeLabel={t('common.close')}
|
||||
/>
|
||||
|
||||
<div className="min-h-0 flex-1 overflow-y-auto px-[14px] pb-[16px] pt-2">
|
||||
<FormSheetBody className="space-y-2">
|
||||
{loading ? (
|
||||
<div className="flex items-center justify-center py-10 text-m-faint">
|
||||
<Loader2 size={20} className="animate-spin" />
|
||||
</div>
|
||||
) : lists.length === 0 ? (
|
||||
<div className="flex flex-col items-center px-4 py-10 text-center">
|
||||
<span className="mb-3 flex h-11 w-11 items-center justify-center rounded-2xl bg-[color:var(--m-ic)] text-m-faint">
|
||||
<Bookmark size={20} strokeWidth={2} />
|
||||
</span>
|
||||
<p className="mb-3 font-geist text-[0.75rem] text-m-faint">{t('collections.noListsYet')}</p>
|
||||
<FormSheetSection>
|
||||
<p className="m-0 mb-3 text-control text-m-muted">{t('collections.noListsYet')}</p>
|
||||
<button
|
||||
type="button"
|
||||
onClick={openCollections}
|
||||
className="inline-flex items-center gap-1.5 rounded-full bg-m-act px-4 py-[9px] text-[0.75rem] font-semibold text-m-actfg"
|
||||
className="flex min-h-11 w-full items-center justify-center gap-2 rounded-xl bg-m-act px-3 text-control font-semibold text-m-actfg"
|
||||
>
|
||||
<Plus size={14} strokeWidth={2.2} /> {t('collections.newList')}
|
||||
<Plus size={16} aria-hidden />
|
||||
{t('collections.newList')}
|
||||
</button>
|
||||
</div>
|
||||
</FormSheetSection>
|
||||
) : (
|
||||
lists.map(list => {
|
||||
const entry = savedByCollection.get(list.id)
|
||||
@@ -67,20 +56,21 @@ export default function MSaveToCollectionSheet() {
|
||||
type="button"
|
||||
onClick={() => handleToggle(list)}
|
||||
disabled={busyId != null}
|
||||
className={`mt-2 flex w-full items-center gap-[11px] rounded-[14px] border px-3 py-[10px] text-start disabled:opacity-60 ${
|
||||
aria-pressed={saved}
|
||||
className={`flex min-h-12 w-full items-center gap-2.5 rounded-[14px] border px-3 py-2 text-start disabled:opacity-60 ${
|
||||
saved
|
||||
? 'border-[color:var(--m-act)] bg-[color:var(--m-inner)]'
|
||||
: 'border-[color:var(--m-rowbr)] bg-[color:var(--m-ic)]'
|
||||
? 'border-m-rowbr bg-m-sheetop'
|
||||
: 'border-transparent bg-m-ic'
|
||||
}`}
|
||||
>
|
||||
<span
|
||||
className="flex h-9 w-9 flex-none items-center justify-center rounded-xl text-white"
|
||||
style={{ background: list.color || '#6366f1' }}
|
||||
className="grid size-9 flex-none place-items-center rounded-lg bg-m-sheetop text-m-muted"
|
||||
style={{ color: list.color || undefined }}
|
||||
>
|
||||
<Bookmark size={15} strokeWidth={2} />
|
||||
<Bookmark size={15} strokeWidth={2} aria-hidden />
|
||||
</span>
|
||||
<span className="min-w-0 flex-1">
|
||||
<span className="block truncate text-[0.8125rem] font-semibold text-m-ink">{list.name}</span>
|
||||
<span dir="auto" className="block truncate text-control font-semibold text-m-ink">{list.name}</span>
|
||||
{/* Saved lists show their own status here instead of the place
|
||||
count — that number matters when picking a list, the status
|
||||
matters once the place is in it (#1469). */}
|
||||
@@ -91,26 +81,26 @@ export default function MSaveToCollectionSheet() {
|
||||
aria-label={t(statusMeta.labelKey)}
|
||||
onClick={entry.can_edit ? e => { e.preventDefault(); e.stopPropagation(); void handleStatus(entry, nextStatus(entry.status)) } : undefined}
|
||||
onKeyDown={entry.can_edit ? e => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); e.stopPropagation(); void handleStatus(entry, nextStatus(entry.status)) } } : undefined}
|
||||
className="mt-[3px] inline-flex items-center gap-1 rounded-full bg-[color:var(--m-inner)] px-2 py-[3px] font-geist text-[0.65625rem] font-semibold"
|
||||
className="mt-0.5 inline-flex items-center gap-1 rounded-lg bg-m-ic px-2 py-0.5 text-caption font-medium"
|
||||
style={{ color: statusMeta.color }}
|
||||
>
|
||||
<StatusIcon size={11} strokeWidth={2.4} />
|
||||
{t(statusMeta.labelKey)}
|
||||
</span>
|
||||
) : (
|
||||
<span className="mt-px block font-geist text-[0.65625rem] text-m-muted">
|
||||
<span className="mt-px block text-caption text-m-muted">
|
||||
{t('collections.placeCount', { count: list.place_count ?? 0 })}
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
{list.is_owner === false && (
|
||||
<span className="flex-none font-geist text-[0.5625rem] font-bold uppercase tracking-[.05em] text-m-faint">
|
||||
<span className="flex-none text-caption text-m-muted">
|
||||
{t('collections.shared')}
|
||||
</span>
|
||||
)}
|
||||
<span
|
||||
className={`flex h-[26px] w-[26px] flex-none items-center justify-center rounded-full ${
|
||||
saved ? 'bg-m-act text-m-actfg' : 'border border-[color:var(--m-rowbr)] text-m-faint'
|
||||
saved ? 'bg-m-act text-m-actfg' : 'border border-m-rowbr text-m-muted'
|
||||
}`}
|
||||
>
|
||||
{busy ? <Loader2 size={14} className="animate-spin" /> : saved ? <BookmarkCheck size={14} strokeWidth={2} /> : <Check size={14} strokeWidth={2} />}
|
||||
@@ -119,15 +109,15 @@ export default function MSaveToCollectionSheet() {
|
||||
)
|
||||
})
|
||||
)}
|
||||
</div>
|
||||
</FormSheetBody>
|
||||
|
||||
{unvisited.length > 0 && (
|
||||
<div className="flex-none px-[14px] pb-1">
|
||||
<div className="flex-none px-[18px] pb-2">
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleVisitedEverywhere}
|
||||
disabled={busyId != null}
|
||||
className="flex w-full items-center justify-center gap-1.5 rounded-[14px] border border-[color:var(--m-rowbr)] bg-[color:var(--m-ic)] py-[10px] text-[0.78125rem] font-semibold text-m-ink disabled:opacity-60"
|
||||
className="flex min-h-11 w-full items-center justify-center gap-2 rounded-xl bg-m-ic px-3 text-control font-semibold text-m-ink disabled:opacity-60"
|
||||
>
|
||||
{busyId === VISITED_EVERYWHERE_BUSY
|
||||
? <Loader2 size={14} className="animate-spin" />
|
||||
@@ -138,18 +128,18 @@ export default function MSaveToCollectionSheet() {
|
||||
)}
|
||||
|
||||
{lists.length > 0 && (
|
||||
<div className="flex flex-none items-center justify-between gap-2 border-t border-[color:var(--m-rowbr)] px-[18px] py-3">
|
||||
<div className="flex flex-none items-center justify-between gap-2 border-t border-m-rowbr px-[18px] py-3">
|
||||
<button
|
||||
type="button"
|
||||
onClick={openCollections}
|
||||
className="text-[0.78125rem] font-semibold text-[color:var(--m-act)]"
|
||||
className="min-h-11 text-control font-semibold text-m-ink"
|
||||
>
|
||||
{t('collections.viewInCollection')}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={close}
|
||||
className="rounded-full bg-[color:var(--m-ic)] px-4 py-[8px] text-[0.78125rem] font-semibold text-m-ink"
|
||||
className="min-h-11 rounded-xl bg-m-ic px-4 text-control font-semibold text-m-ink"
|
||||
>
|
||||
{t('common.close')}
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user