mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-27 23:27:31 +00:00
c204a25a9c
The app shows the touch shell at every size now, an iPad's and an unfolded foldable's included, instead of switching to the desktop pages from 768px. One route tree survives rotation, Split View, Stage Manager and folding, and the app's own features (Wallet, sharing into a trip, the edge swipe back) are there on the big screen too. Two size classes drive the layout (hooks/sizeClass.ts, Tailwind variants wide: and split:): - wide (600pt and taller than a phone on its side): a glass navigation rail on the leading edge replaces the dock and holds every destination with its name; sheets become centred form sheets; the trip's More menu is a popover beside the rail; lists keep a readable measure; dashboard, journey and vacay get columns; full-bleed maps run under the floating rail. - split (900pt): the trip's plan, places or road trip chain sit in a pane beside the map, which follows the plan's day; the list/map switch hides and shows the pane like a sidebar; on a foldable that reports its fold the pane ends at the fold. Settings show their sections beside the page and the dashboard keeps its widgets in a column of their own. A hardware keyboard gets the shortcuts an iPad app has (⌘1 to ⌘9 for the sections, ⌘N, ⌘, , ⌥←/⌥→ through the days, ⌃⌘S for the pane, ⌘[ back), answered by the page or, with a binary that has the keyCommands feature, handed to it as native key commands. The day strip fades at an edge that runs on, journey cards grow on a wide window and a card without a photo takes the day's colour, and the Leaflet map measures itself again when its box changes size.
60 lines
2.6 KiB
TypeScript
60 lines
2.6 KiB
TypeScript
import MStatusDot, { MStatus } from './MStatusDot'
|
|
import { useToastQueue, type QueuedToast, type ToastType } from '../../components/shared/useToastQueue'
|
|
|
|
const EXIT_MS = 220
|
|
|
|
// Roughly what one line of the pill holds on a 375px phone. Longer messages
|
|
// (the geolocation permission hint runs ~150 characters) render as a wrapping
|
|
// card instead, or the actionable half disappears behind the ellipsis.
|
|
const PILL_CHARS = 42
|
|
|
|
// info stays the plain act-pill; the other types get a status dot.
|
|
const TYPE_DOT: Partial<Record<ToastType, MStatus>> = {
|
|
success: 'confirmed',
|
|
error: 'danger',
|
|
warning: 'pending',
|
|
}
|
|
|
|
function MToastPill({ toast, onDismiss }: { toast: QueuedToast; onDismiss: (id: number) => void }) {
|
|
const dot = TYPE_DOT[toast.type]
|
|
const wraps = toast.message.length > PILL_CHARS
|
|
// duration <= 0: no auto-dismiss, the pill closes on tap instead.
|
|
const sticky = toast.duration <= 0
|
|
return (
|
|
<div
|
|
role={sticky ? 'button' : undefined}
|
|
tabIndex={sticky ? 0 : undefined}
|
|
onClick={sticky ? () => onDismiss(toast.id) : undefined}
|
|
onKeyDown={sticky ? (e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); onDismiss(toast.id) } } : undefined}
|
|
className={`flex max-w-full gap-2 bg-m-act px-4 py-2 text-[0.75rem] font-semibold text-m-actfg shadow-[0_10px_30px_-8px_rgba(0,0,0,.5)] ${
|
|
wraps ? 'items-start rounded-2xl' : 'items-center rounded-full'
|
|
} ${sticky ? 'pointer-events-auto cursor-pointer' : ''} ${toast.removing ? 'm-toast-out' : 'm-toast-in'}`}
|
|
>
|
|
{dot && <MStatusDot status={dot} size={6} className={wraps ? 'mt-[0.45rem]' : ''} />}
|
|
{/* No display utility next to line-clamp: Tailwind emits it later and kills the clamp. */}
|
|
<span className={`min-w-0 ${wraps ? 'line-clamp-4 leading-[1.45]' : 'truncate'}`}>{toast.message}</span>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
/**
|
|
* Mobile toast presenter. Takes over the global `window.__addToast` bridge
|
|
* (fed by useToast / store/notify) while the mobile shell is mounted, so every
|
|
* existing toast call renders above the bottom nav, as the design's act-pill or,
|
|
* for a message too long for one line, as a wrapping card.
|
|
* The desktop ToastContainer handler is restored on unmount.
|
|
*/
|
|
export default function MToastHost() {
|
|
const { toasts, dismissToast } = useToastQueue({ exitMs: EXIT_MS, restorePrevious: true })
|
|
|
|
if (toasts.length === 0) return null
|
|
|
|
return (
|
|
<div className="m-span-x pointer-events-none fixed bottom-[calc(var(--bottom-nav-h,84px)+16px)] z-[90] flex flex-col-reverse items-center gap-2 px-6">
|
|
{toasts.map((toast) => (
|
|
<MToastPill key={toast.id} toast={toast} onDismiss={dismissToast} />
|
|
))}
|
|
</div>
|
|
)
|
|
}
|