diff --git a/client/scripts/feature-pairs.json b/client/scripts/feature-pairs.json
index 0c54f2796..8bab0af42 100644
--- a/client/scripts/feature-pairs.json
+++ b/client/scripts/feature-pairs.json
@@ -1018,6 +1018,8 @@
"src/mobile/screens/settings/MSettingsUi.tsx": "Phone only settings UI primitives (card, row, input, button, segments, hint).",
"src/mobile/screens/settings/MTileCacheUsage.tsx": "Phone only: the native tile cache size and clear action, which the browser build has no counterpart for.",
"src/mobile/screens/settings/MWebPushCard.tsx": "Already shares hooks/useWebPush with components/Settings/WebPushCard.tsx.",
+ "src/mobile/screens/trip/MTripRail.tsx": "Phone shell only; the trip's sections on the leading edge of a wide window in place of the dock, with the tabs and handlers MTripShell hands in.",
+ "src/mobile/screens/trip/MTripShellParts.tsx": "Markup only; small pieces of MTripShell's top controls (segment pill, compact toggle, document sync button), with the state and handlers MTripShell hands in.",
"src/mobile/screens/trip/dockTabs.ts": "Phone only helper that picks which trip tabs get a seat in the mobile dock.",
"src/mobile/screens/trip/lib/dayNotes.ts": "Phone only helper that splits a leading time off a day note for the plan timeline.",
"src/mobile/screens/trip/map/MMapArea.tsx": "Phone map stage framing; already shares usePoiExplore and useMergedMapPois with the desktop trip planner.",
diff --git a/client/scripts/rtl-baseline.json b/client/scripts/rtl-baseline.json
index 1ee1892cb..c57ded24b 100644
--- a/client/scripts/rtl-baseline.json
+++ b/client/scripts/rtl-baseline.json
@@ -87,7 +87,6 @@
"mobile/screens/trip/map/MMapArea.tsx": 3,
"mobile/screens/trip/tabs/MCollabPolls.tsx": 1,
"mobile/screens/trip/tabs/MFileLightbox.tsx": 2,
- "mobile/screens/vacay/MVacay.tsx": 1,
"mobile/screens/vacay/MVacayMonth.tsx": 1,
"pages/AtlasPage.tsx": 2,
"pages/JourneyDetailPage.tsx": 1,
diff --git a/client/scripts/size-baseline.json b/client/scripts/size-baseline.json
index bf73a550e..d5cf76cf4 100644
--- a/client/scripts/size-baseline.json
+++ b/client/scripts/size-baseline.json
@@ -5,7 +5,7 @@
"src/components/Admin/AdminPluginsPanel.tsx": 1266,
"src/components/Budget/CostsPanel.test.tsx": 2730,
"src/components/Budget/CostsPanel.tsx": 1798,
- "src/components/Map/MapView.tsx": 1214,
+ "src/components/Map/MapView.tsx": 1202,
"src/components/Map/MapViewGL.test.tsx": 2919,
"src/components/Map/MapViewGL.tsx": 2127,
"src/components/Planner/DayDetailPanel.test.tsx": 2333,
diff --git a/client/scripts/theme-baseline.json b/client/scripts/theme-baseline.json
index d7eeccb32..675191e2f 100644
--- a/client/scripts/theme-baseline.json
+++ b/client/scripts/theme-baseline.json
@@ -40,7 +40,7 @@
"components/Journey/JourneyDetailPageProviderPicker.tsx": 163,
"components/Journey/JourneyDetailPageScrollTrigger.tsx": 4,
"components/Journey/JourneyDetailPageVerdictSection.tsx": 51,
- "components/Journey/JourneyEntryCover.tsx": 15,
+ "components/Journey/JourneyEntryCover.tsx": 13,
"components/Journey/JourneyMap.tsx": 3,
"components/Journey/JourneyMapGL.tsx": 5,
"components/Journey/MobileEntryView.tsx": 94,
diff --git a/client/src/components/Journey/JourneyEntryCover.tsx b/client/src/components/Journey/JourneyEntryCover.tsx
index 1f5934ff9..38ea2bab3 100644
--- a/client/src/components/Journey/JourneyEntryCover.tsx
+++ b/client/src/components/Journey/JourneyEntryCover.tsx
@@ -62,6 +62,11 @@ interface Props {
/** The public journey page serves photos through a share token. */
photoUrlFor?: (photoId: number) => string
tone?: 'app' | 'mobile'
+ /**
+ * large: the card a wide window shows (an iPad, a foldable unfolded), with
+ * the room for a two-line name and the whole place under it.
+ */
+ size?: 'regular' | 'large'
}
export default function JourneyEntryCover({
@@ -73,7 +78,9 @@ export default function JourneyEntryCover({
showWeather = true,
photoUrlFor,
tone = 'app',
+ size = 'regular',
}: Props) {
+ const large = size === 'large'
const { t, locale } = useTranslation()
const isSuggestion = entry.type === 'skeleton'
@@ -108,7 +115,9 @@ export default function JourneyEntryCover({
// growing its box moved every card after it once a swipe had landed, and the
// snap then pulled the strip again, which read as a jolt (carousels keep the
// room for it with their gap and top padding).
- className={`relative h-[152px] w-[136px] flex-none origin-bottom overflow-hidden rounded-[18px] text-start transition-[transform,box-shadow] duration-200 ease-[cubic-bezier(.2,.8,.2,1)] motion-reduce:transition-none ${
+ // White on the root: every mark and line on the card is white, over a photo or
+ // over the day's colour alike.
+ className={`relative text-white ${large ? 'h-[196px] w-[176px]' : 'h-[152px] w-[136px]'} flex-none origin-bottom overflow-hidden rounded-[18px] text-start transition-[transform,box-shadow] duration-200 ease-[cubic-bezier(.2,.8,.2,1)] motion-reduce:transition-none ${
isActive ? 'z-[1] scale-[1.18] shadow-[0_18px_40px_-16px_rgba(0,0,0,.55)]' : 'scale-100 shadow-[0_10px_24px_-14px_rgba(0,0,0,.5)]'
} ${src ? '' : emptyGround} ${isSuggestion ? 'opacity-90' : ''}`}
// backgroundImage, not background: the shorthand would drop the opaque colour
@@ -122,7 +131,9 @@ export default function JourneyEntryCover({
// ring lost its top edge to that clip.
style={{
boxShadow: `inset 0 0 0 ${isActive ? 2.5 : 1.5}px ${dayColor}${isActive ? '' : 'b3'}`,
- ...(src ? null : { backgroundImage: `linear-gradient(160deg, ${dayColor}2e, ${dayColor}0d)` }),
+ // Without a photograph the card is the day's colour, deep enough to carry
+ // the white name like a photo does, rather than a grey that read as empty.
+ ...(src ? null : { backgroundImage: `linear-gradient(160deg, ${dayColor}d9, ${dayColor}8c 55%, ${dayColor}59)` }),
}}
>
{src ? (
@@ -130,8 +141,8 @@ export default function JourneyEntryCover({
) : (
{posterless
- ?
- : }
+ ?
+ : }
)}
@@ -155,7 +166,7 @@ export default function JourneyEntryCover({
italic, dimmed title carries the rest. */}
{isSuggestion && (
@@ -172,7 +183,7 @@ export default function JourneyEntryCover({
)}
{weather && (
-
+
)}
@@ -181,11 +192,11 @@ export default function JourneyEntryCover({
{/* Bottom: the name gets the room the thumbnail layout never had. */}
-
+
{title}
{place && (
-
+
{place}
)}
diff --git a/client/src/components/Map/ContainerResizeWatcher.test.tsx b/client/src/components/Map/ContainerResizeWatcher.test.tsx
new file mode 100644
index 000000000..f1e507ac7
--- /dev/null
+++ b/client/src/components/Map/ContainerResizeWatcher.test.tsx
@@ -0,0 +1,59 @@
+import { render } from '@testing-library/react';
+import { afterEach, describe, expect, it, vi } from 'vitest';
+
+// FE-MAP-RESIZE-001 onwards
+
+const map = vi.hoisted(() => ({
+ container: {} as HTMLElement,
+ invalidateSize: vi.fn(),
+ getContainer: vi.fn(),
+ getCenter: vi.fn(() => ({ lat: 35, lng: 135.7 })),
+ getZoom: vi.fn(() => 12),
+ whenReady: vi.fn((fn: () => void) => fn()),
+ on: vi.fn(),
+ off: vi.fn(),
+}));
+vi.mock('react-leaflet', () => ({ useMap: () => map }));
+
+import ContainerResizeWatcher, { MapCameraSnapshot } from './ContainerResizeWatcher';
+
+const realObserver = globalThis.ResizeObserver;
+
+describe('ContainerResizeWatcher', () => {
+ afterEach(() => {
+ globalThis.ResizeObserver = realObserver;
+ vi.clearAllMocks();
+ });
+
+ it('FE-MAP-RESIZE-001: the map measures itself again whenever its box changes size', () => {
+ const element = document.createElement('div');
+ map.getContainer.mockReturnValue(element);
+ let fire: () => void = () => {};
+ const observe = vi.fn();
+ const disconnect = vi.fn();
+ globalThis.ResizeObserver = class {
+ constructor(cb: () => void) {
+ fire = cb;
+ }
+ observe = observe;
+ unobserve = vi.fn();
+ disconnect = disconnect;
+ } as unknown as typeof ResizeObserver;
+
+ const { unmount } = render();
+ expect(observe).toHaveBeenCalledWith(element);
+ fire();
+ expect(map.invalidateSize).toHaveBeenCalledWith();
+ unmount();
+ expect(disconnect).toHaveBeenCalled();
+ });
+
+ it('FE-MAP-RESIZE-002: the camera snapshot reports where the map looks and stops on unmount', () => {
+ const onChange = vi.fn();
+ const { unmount } = render();
+ expect(onChange).toHaveBeenCalledWith([35, 135.7], 12);
+ expect(map.on).toHaveBeenCalledWith('moveend zoomend', expect.any(Function));
+ unmount();
+ expect(map.off).toHaveBeenCalledWith('moveend zoomend', expect.any(Function));
+ });
+});
diff --git a/client/src/components/Map/ContainerResizeWatcher.tsx b/client/src/components/Map/ContainerResizeWatcher.tsx
new file mode 100644
index 000000000..b38a514b4
--- /dev/null
+++ b/client/src/components/Map/ContainerResizeWatcher.tsx
@@ -0,0 +1,38 @@
+import { useEffect } from 'react';
+import { useMap } from 'react-leaflet';
+
+/**
+ * Leaflet measures its container on window resizes only. The touch shell on a
+ * wide window resizes the map without one: the trip's plan pane opens and
+ * closes beside it, and a foldable folds. Without a fresh measure the map kept
+ * its old size, with grey bands or tiles cut off at the old edge.
+ */
+export default function ContainerResizeWatcher() {
+ const map = useMap();
+ useEffect(() => {
+ if (typeof ResizeObserver === 'undefined') return;
+ // Leaflet's default keeps the centre where it was, so what the map framed stays
+ // in the middle of the room it now has.
+ const observer = new ResizeObserver(() => map.invalidateSize());
+ observer.observe(map.getContainer());
+ return () => observer.disconnect();
+ }, [map]);
+ return null;
+}
+
+/** Reports where the map looks after every move, so a remount can come back to it. */
+export function MapCameraSnapshot({ onChange }: { onChange: (center: [number, number], zoom: number) => void }) {
+ const map = useMap();
+ useEffect(() => {
+ const save = () => {
+ const center = map.getCenter();
+ onChange([center.lat, center.lng], map.getZoom());
+ };
+ map.whenReady(save);
+ map.on('moveend zoomend', save);
+ return () => {
+ map.off('moveend zoomend', save);
+ };
+ }, [map, onChange]);
+ return null;
+}
diff --git a/client/src/components/Map/MapView.tsx b/client/src/components/Map/MapView.tsx
index fb89a3196..605aabd58 100644
--- a/client/src/components/Map/MapView.tsx
+++ b/client/src/components/Map/MapView.tsx
@@ -2,6 +2,7 @@ import { useEffect, useRef, useState, useMemo, useCallback, memo, type Component
import DOM from 'react-dom'
import { categoryIconSvg } from './categoryIconSvg'
import { MapContainer, TileLayer, Marker, Polyline, CircleMarker, Circle, useMap, Tooltip } from 'react-leaflet'
+import ContainerResizeWatcher, { MapCameraSnapshot } from './ContainerResizeWatcher'
import MarkerClusterGroup from 'react-leaflet-cluster'
import { makeMarkerDraggable } from './markerDrag'
import { CLUSTER_OPTIONS, createClusterIcon, revealInCluster, type ClusterGroupLike } from './markerCluster'
@@ -244,20 +245,6 @@ function CameraHoverGuard({ movingRef, onMoveStart, onZoom }: { movingRef: { cur
return null
}
-function MapCameraSnapshot({ onChange }: { onChange: (center: [number, number], zoom: number) => void }) {
- const map = useMap()
- useEffect(() => {
- const save = () => {
- const center = map.getCenter()
- onChange([center.lat, center.lng], map.getZoom())
- }
- map.whenReady(save)
- map.on('moveend zoomend', save)
- return () => { map.off('moveend zoomend', save) }
- }, [map, onChange])
- return null
-}
-
interface MapControllerProps {
center: [number, number]
zoom: number
@@ -952,6 +939,7 @@ export const MapView = memo(function MapView({
{/* First, so a fit or a camera request in the same commit starts from the trip's world copy. */}
+
{hasViewBaseLayer && }
0 ? dayPlaces : places} routeCoords={dayPlaces.length > 0 ? routeCoords : []} fitKey={fitKey} paddingOpts={paddingOpts} framedOnMount={initialView.framed} focusPoints={focusPoints} focusKey={focusKey} fitPadding={fitPadding} follow={followSelection} />
diff --git a/client/src/hooks/sizeClass.ts b/client/src/hooks/sizeClass.ts
new file mode 100644
index 000000000..84a48357a
--- /dev/null
+++ b/client/src/hooks/sizeClass.ts
@@ -0,0 +1,59 @@
+import { useSyncExternalStore } from 'react';
+
+/**
+ * The touch shell's size classes, the web's answer to UIKit's compact and
+ * regular widths.
+ *
+ * compact every phone, upright or on its side, and the narrow Split View and
+ * Stage Manager windows. The shell as it has always been: the dock at
+ * the bottom, sheets rising from below, one column.
+ * wide from 600pt across and taller than a phone on its side: an iPad in
+ * any orientation or window above a third of the screen, a foldable
+ * unfolded. A navigation rail on the leading edge takes the dock's
+ * place, sheets become centred form sheets, lists get columns.
+ * split from 900pt across: room for two panes, so the trip's plan sits next
+ * to its map and settings show their sections beside the page.
+ *
+ * The height bound keeps a phone on its side compact: no phone is taller than
+ * 500pt in landscape, no tablet or unfolded foldable is shorter.
+ *
+ * `tailwind.config.js` registers the same two queries as the `wide:` and
+ * `split:` variants, and `index.css` reads them for the shell's own variables;
+ * keep the three in step (sizeClass.test.ts holds them together).
+ */
+export const WIDE_QUERY = '(min-width: 600px) and (min-height: 501px)';
+export const SPLIT_QUERY = '(min-width: 900px) and (min-height: 501px)';
+
+function matches(query: string): boolean {
+ return typeof window !== 'undefined' && typeof window.matchMedia === 'function' && window.matchMedia(query).matches;
+}
+
+function subscribe(query: string) {
+ return (onChange: () => void) => {
+ if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') return () => {};
+ const mq = window.matchMedia(query);
+ mq.addEventListener('change', onChange);
+ return () => mq.removeEventListener('change', onChange);
+ };
+}
+
+const subscribeWide = subscribe(WIDE_QUERY);
+const subscribeSplit = subscribe(SPLIT_QUERY);
+const readWide = () => matches(WIDE_QUERY);
+const readSplit = () => matches(SPLIT_QUERY);
+const never = () => false;
+
+/** Whether the touch shell is laid out for a wide window right now, outside React. */
+export function isWideViewport(): boolean {
+ return readWide();
+}
+
+/** True while the window is in the wide size class. Follows rotation, folding and resizing. */
+export function useIsWide(): boolean {
+ return useSyncExternalStore(subscribeWide, readWide, never);
+}
+
+/** True while the window has room for two panes side by side. */
+export function useIsSplit(): boolean {
+ return useSyncExternalStore(subscribeSplit, readSplit, never);
+}
diff --git a/client/src/mobile/MobileShell.tsx b/client/src/mobile/MobileShell.tsx
index 2b7cd3704..af6b25037 100644
--- a/client/src/mobile/MobileShell.tsx
+++ b/client/src/mobile/MobileShell.tsx
@@ -3,6 +3,10 @@ import { useMatch } from 'react-router'
import BottomNav from '../components/Layout/BottomNav'
import ErrorBoundary from '../components/shared/ErrorBoundary'
import MBottomNav from './components/MBottomNav'
+import MNavRail from './components/MNavRail'
+import { useIsWide } from '../hooks/sizeClass'
+import MKeyboardHost from './keyboard/MKeyboardHost'
+import MShellShortcuts from './keyboard/MShellShortcuts'
import MToastHost from './components/MToastHost'
import MEdgeBack from './components/MEdgeBack'
import { useNativeCapabilities } from '../native/capabilities'
@@ -39,6 +43,9 @@ export default function MobileShell({ isPhone, children }: MobileShellProps) {
const { caps } = useNativeCapabilities()
const pageRef = useRef(null)
const edgeBack = isNativeIos() && caps.features.includes('edgeBack')
+ // On a wide window (an iPad, a foldable unfolded) the rail on the leading edge
+ // replaces the dock, and the page column starts after it.
+ const wide = useIsWide()
if (!isPhone) {
return (
@@ -52,7 +59,7 @@ export default function MobileShell({ isPhone, children }: MobileShellProps) {
return (
// min-h-svh, not min-h-dvh: dvh grows while Safari's toolbar retracts, so a
// dvh page length would chase the animation it just triggered.
-
+
{/* Background and screen gradient live on their own viewport-sized layer.
The shell root is as tall as the document now, and --m-scr is a radial
gradient measured against its element box, so on it the light cone would
@@ -66,10 +73,17 @@ export default function MobileShell({ isPhone, children }: MobileShellProps) {
layer to be visible, body must not paint over it, which index.css handles
for this breakpoint. */}
-
)
diff --git a/client/src/mobile/components/MGlassBar.tsx b/client/src/mobile/components/MGlassBar.tsx
index 455bb5724..5669a281f 100644
--- a/client/src/mobile/components/MGlassBar.tsx
+++ b/client/src/mobile/components/MGlassBar.tsx
@@ -12,7 +12,7 @@ export default function MGlassBar({ floating = true, className = '', children }:
return (
{children}
diff --git a/client/src/mobile/components/MNavRail.tsx b/client/src/mobile/components/MNavRail.tsx
new file mode 100644
index 000000000..f21fc5304
--- /dev/null
+++ b/client/src/mobile/components/MNavRail.tsx
@@ -0,0 +1,114 @@
+import type { LucideIcon } from 'lucide-react';
+import { Plus, Search, Settings2, Shield, Sparkles, Upload } from 'lucide-react';
+import { useLocation, useNavigate } from 'react-router';
+import { useAssistantHomeLauncher } from '../../components/Assistant/useAssistantHome';
+import { useNavItems } from '../../components/Layout/navItems';
+import { isNavItemActive, useCreateAction } from '../../components/Layout/useCreateAction';
+import { useTranslation } from '../../i18n';
+import { useAuthStore } from '../../store/authStore';
+import MFab from './MFab';
+import { MRail, MRailButton, MRailSpacer } from './MRail';
+
+interface RailEntry {
+ id: string;
+ label: string;
+ icon: LucideIcon;
+ active: boolean;
+ go: () => void;
+}
+
+/**
+ * The touch shell's navigation on a wide window (hooks/sizeClass.ts): a glass
+ * rail on the leading edge, where an iPad app keeps its sidebar, in place of
+ * the phone's bottom dock.
+ *
+ * It has the room the dock lacks, so every destination sits in it at once,
+ * with its name under the icon: the dock's own items, the ones the phone keeps
+ * under More, the home assistant, and settings and administration at the foot,
+ * which the phone reaches through the avatar menu. The create action keeps the
+ * dock's raised circle at the head, with the same context-aware meaning.
+ */
+export default function MNavRail() {
+ const { t } = useTranslation();
+ const navigate = useNavigate();
+ const location = useLocation();
+ const create = useCreateAction(true);
+ const assistant = useAssistantHomeLauncher();
+ const isAdmin = useAuthStore((s) => s.user?.role === 'admin');
+ const navItems = useNavItems();
+
+ const isActive = (to: string) => isNavItemActive(location.pathname, to);
+ const main: RailEntry[] = [
+ ...navItems.map(({ to, label, icon }) => ({
+ id: to,
+ label,
+ icon,
+ active: isActive(to),
+ go: () => void navigate(to),
+ })),
+ ...(assistant.available
+ ? [{ id: 'assistant', label: t('assistant.launcher.tooltip'), icon: Sparkles, active: false, go: assistant.open }]
+ : []),
+ ];
+ const foot: RailEntry[] = [
+ {
+ id: '/settings',
+ label: t('nav.bottomSettings'),
+ icon: Settings2,
+ active: isActive('/settings'),
+ go: () => void navigate('/settings'),
+ },
+ ...(isAdmin
+ ? [
+ {
+ id: '/admin',
+ label: t('nav.bottomAdmin'),
+ icon: Shield,
+ active: isActive('/admin'),
+ go: () => void navigate('/admin'),
+ },
+ ]
+ : []),
+ ];
+
+ // Settings and admin have nothing to create, and /vacay draws its own action
+ // (the year/edit toggle), the same exceptions the dock makes.
+ const noFab = ['/settings', '/admin', '/vacay'].some((p) => location.pathname.startsWith(p));
+ const searchFab = location.pathname.startsWith('/atlas');
+
+ return (
+
+ {!noFab && (
+
+ {searchFab ? (
+
+ ) : create.upload ? (
+
+ ) : (
+
+ )}
+
+ )}
+ {main.map((entry) => (
+
+ ))}
+
+
+ {foot.map((entry) => (
+
+ ))}
+
+ );
+}
+
+function RailEntryButton({ label, icon: Icon, active, go }: RailEntry) {
+ return (
+
+
+
+ );
+}
diff --git a/client/src/mobile/components/MPullIndicator.tsx b/client/src/mobile/components/MPullIndicator.tsx
index cb5ff1610..619afe098 100644
--- a/client/src/mobile/components/MPullIndicator.tsx
+++ b/client/src/mobile/components/MPullIndicator.tsx
@@ -13,7 +13,7 @@ export default function MPullIndicator({ state, label }: { state: PullState; lab
aria-hidden={!state.refreshing}
role={state.refreshing ? 'status' : undefined}
aria-label={state.refreshing ? label : undefined}
- className="pointer-events-none fixed inset-x-0 z-30 flex justify-center transition-opacity duration-200"
+ className="m-span-x pointer-events-none fixed z-30 flex justify-center transition-opacity duration-200"
style={{ top: 'calc(var(--m-safe-top, 12px) + 70px)', opacity: visible ? Math.max(0.35, progress) : 0 }}
>
diff --git a/client/src/mobile/components/MRail.tsx b/client/src/mobile/components/MRail.tsx
new file mode 100644
index 000000000..cb26a1aef
--- /dev/null
+++ b/client/src/mobile/components/MRail.tsx
@@ -0,0 +1,65 @@
+import type { ReactNode } from 'react';
+
+/**
+ * The glass rail on the leading edge that takes the dock's place on a wide
+ * window (hooks/sizeClass.ts): the app's sections (MNavRail) or a trip's
+ * (MTripRail). It sits inside the strip --m-rail-w reserves, so the page
+ * column and every fixed bar start right after it.
+ */
+export function MRail({ label, fixed = false, children }: { label: string; fixed?: boolean; children: ReactNode }) {
+ return (
+
+ );
+}
+
+/** Pushes the entries after it to the foot of the rail. */
+export function MRailSpacer() {
+ return ;
+}
+
+interface MRailButtonProps {
+ label: string;
+ active: boolean;
+ onClick: () => void;
+ /** The icon, drawn at 20px. */
+ children: ReactNode;
+}
+
+/**
+ * One destination: the icon on the dock's 40px circle, filled while it is the
+ * current one, its name underneath. Names wrap to two lines rather than being
+ * cut, since a rail entry has no other way to say what it is; the title gives
+ * the whole name to a pointer hovering it.
+ */
+export function MRailButton({ label, active, onClick, children }: MRailButtonProps) {
+ return (
+
+ );
+}
diff --git a/client/src/mobile/components/MSheet.tsx b/client/src/mobile/components/MSheet.tsx
index e1fa7644b..71f0dd295 100644
--- a/client/src/mobile/components/MSheet.tsx
+++ b/client/src/mobile/components/MSheet.tsx
@@ -32,21 +32,74 @@ interface MSheetProps {
* throwing away a state that differs from the one at the first touch.
*/
discardGuard?: unknown
+ /** Width as a centred form sheet on a wide window (default regular). */
+ wideWidth?: MSheetWidth
+ /** Where it stands on a wide window (default centre). */
+ wideAnchor?: MSheetWideAnchor
}
const EXIT_MS = 300
const DISCARD_BUTTON = 'rounded-full bg-danger px-4 py-2 text-body font-semibold text-white' // theme-lint-disable: white on the danger fill, as ConfirmDialog draws it
+/**
+ * How wide the sheet gets on a wide window, where it is a centred form sheet
+ * rather than a panel across the screen: compact for a short list of actions,
+ * regular for a form, large for a sheet that holds a page of its own.
+ */
+export type MSheetWidth = 'compact' | 'regular' | 'large'
+
+// On a wide window (hooks/sizeClass.ts) a docked or floating sheet becomes
+// what iPadOS shows there: a form sheet centred over the dimmed page, as wide
+// as its content needs and no wider, instead of a band across a 13" screen.
+// Centred with auto margins between zero insets, so it needs no physical side.
+const WIDE_POSITION = 'wide:inset-x-0 wide:mx-auto wide:bottom-auto wide:top-1/2 wide:-translate-y-1/2'
+const WIDE_WIDTH: Record = {
+ compact: 'wide:w-[min(320px,calc(100%-48px))]',
+ regular: 'wide:w-[min(540px,calc(100%-48px))]',
+ large: 'wide:w-[min(720px,calc(100%-48px))]',
+}
+
const POSITION: Record = {
card: 'absolute inset-x-[14px] top-1/2 -translate-y-1/2',
bottom: 'absolute inset-x-4 bottom-[calc(var(--bottom-nav-h,84px)+16px)]',
drawer: 'absolute left-0 top-0 bottom-0 w-[78%] max-w-[320px]',
}
+/**
+ * Where a sheet stands on a wide window. centre: a form sheet. rail-foot: a
+ * popover beside the foot of the navigation rail, for a menu opened from there
+ * (the trip's More), the way iPadOS shows a menu next to the button that
+ * opened it rather than in the middle of the screen.
+ */
+export type MSheetWideAnchor = 'center' | 'rail-foot'
+const WIDE_ANCHOR: Record = {
+ center: WIDE_POSITION,
+ 'rail-foot': 'wide:top-auto wide:translate-y-0 wide:end-auto wide:bottom-[calc(env(safe-area-inset-bottom,0px)+12px)] wide:start-[calc(var(--m-rail-w)+6px)]',
+}
+
+/** The box the panel sits in: its place on a phone, and on a wide window. */
+function frameClass(variant: MSheetVariant, width: MSheetWidth = 'regular', anchor: MSheetWideAnchor = 'center'): string {
+ if (variant === 'drawer') return POSITION.drawer
+ return `${POSITION[variant]} ${WIDE_WIDTH[width]} ${WIDE_ANCHOR[anchor]}`
+}
+
+/** The popover's arrow, pointing at the More button at the foot of the rail (wide windows only). */
+function PopoverArrow({ variant, anchor }: { variant: MSheetVariant; anchor?: MSheetWideAnchor }) {
+ if (anchor !== 'rail-foot' || variant === 'drawer') return null
+ return (
+
+ )
+}
+
+const WIDE_HEIGHT = 'wide:max-h-[min(calc(100dvh-var(--m-safe-top,12px)-64px),880px)]'
+
const SHAPE: Record = {
- card: 'rounded-[28px] shadow-[0_30px_80px_-24px_rgba(0,0,0,.6)] max-h-[calc(100dvh-var(--m-safe-top,12px)-96px)]',
- bottom: 'rounded-[26px] shadow-[0_-8px_40px_-14px_rgba(0,0,0,.45)] max-h-[calc(100dvh-var(--bottom-nav-h,84px)-var(--m-safe-top,12px)-72px)]',
+ card: `rounded-[28px] shadow-[0_30px_80px_-24px_rgba(0,0,0,.6)] max-h-[calc(100dvh-var(--m-safe-top,12px)-96px)] ${WIDE_HEIGHT}`,
+ bottom: `rounded-[26px] shadow-[0_-8px_40px_-14px_rgba(0,0,0,.45)] max-h-[calc(100dvh-var(--bottom-nav-h,84px)-var(--m-safe-top,12px)-72px)] ${WIDE_HEIGHT} wide:shadow-[0_30px_80px_-24px_rgba(0,0,0,.6)]`,
drawer: 'h-full shadow-[0_0_60px_-10px_rgba(0,0,0,.5)]',
}
@@ -87,6 +140,8 @@ export default function MSheet({
className = '',
children,
discardGuard,
+ wideWidth,
+ wideAnchor,
}: MSheetProps) {
const { t } = useTranslation()
const { asking, markStart, requestClose, wouldAsk, keepEditing, discard, reset } = useDiscardGuard(discardGuard, onClose)
@@ -187,7 +242,8 @@ export default function MSheet({
if (e.target === e.currentTarget) requestClose()
}}
>
-
+
+
+
{toasts.map((toast) => (
))}
diff --git a/client/src/mobile/components/useEdgeFade.ts b/client/src/mobile/components/useEdgeFade.ts
new file mode 100644
index 000000000..70a24bc3e
--- /dev/null
+++ b/client/src/mobile/components/useEdgeFade.ts
@@ -0,0 +1,47 @@
+import { useEffect, useState } from 'react';
+
+export interface EdgeFade {
+ /** Content is scrolled past the leading edge. */
+ start: boolean;
+ /** More content waits beyond the trailing edge. */
+ end: boolean;
+}
+
+const NONE: EdgeFade = { start: false, end: false };
+
+/**
+ * Which ends of a horizontal scroller have more behind them, so the strip can
+ * fade out there (m-fade-s / m-fade-e in mobile.css) instead of cutting a chip
+ * in half with nothing to say the row goes on. Follows scrolling and every
+ * change of size: a rotation, a fold, the pane beside the map opening.
+ */
+export function useEdgeFade(el: HTMLElement | null): EdgeFade {
+ const [fade, setFade] = useState(NONE);
+ useEffect(() => {
+ if (!el) return;
+ const measure = () => {
+ // scrollLeft runs from 0 towards the negative in a right-to-left strip.
+ const scrolled = Math.abs(el.scrollLeft);
+ const room = el.scrollWidth - el.clientWidth;
+ const next = { start: scrolled > 1, end: room - scrolled > 1 };
+ setFade((prev) => (prev.start === next.start && prev.end === next.end ? prev : next));
+ };
+ measure();
+ el.addEventListener('scroll', measure, { passive: true });
+ const observer = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(measure);
+ observer?.observe(el);
+ return () => {
+ el.removeEventListener('scroll', measure);
+ observer?.disconnect();
+ };
+ }, [el]);
+ return fade;
+}
+
+/** The mask classes for a fade state. */
+export function edgeFadeClass(fade: EdgeFade): string {
+ if (fade.start && fade.end) return 'm-fade-se';
+ if (fade.start) return 'm-fade-s';
+ if (fade.end) return 'm-fade-e';
+ return '';
+}
diff --git a/client/src/mobile/keyboard/MKeyboardHost.tsx b/client/src/mobile/keyboard/MKeyboardHost.tsx
new file mode 100644
index 000000000..91c6427f9
--- /dev/null
+++ b/client/src/mobile/keyboard/MKeyboardHost.tsx
@@ -0,0 +1,63 @@
+import { useEffect } from 'react';
+import { useNativeCapabilities } from '../../native/capabilities';
+import { isNativeIos } from '../../native/platform';
+import { reportNativeFailure } from '../../native/reportFailure';
+import { TrekShell } from '../../native/trekShell';
+import { findShortcut, toNativeCommand, useShortcutRegistry } from './shortcuts';
+
+/**
+ * Answers the touch shell's keyboard shortcuts (useShortcuts), once for every
+ * screen. In a browser it listens for the keys itself. In the app the binary
+ * takes them over as native key commands when it can (feature keyCommands),
+ * which puts them in the overlay a held ⌘ shows and in the iPadOS menu bar;
+ * the page then leaves those keys alone, so nothing runs twice.
+ */
+export default function MKeyboardHost() {
+ const lists = useShortcutRegistry((s) => s.lists);
+ const { caps } = useNativeCapabilities();
+ const native = isNativeIos() && caps.features.includes('keyCommands');
+
+ useEffect(() => {
+ const onKey = (e: KeyboardEvent) => {
+ if (e.defaultPrevented || e.isComposing) return;
+ const all = lists.map((l) => l.shortcuts);
+ const hit = findShortcut(e, native ? all.map((l) => l.filter((s) => !s.mod && !s.ctrl)) : all);
+ if (!hit) return;
+ e.preventDefault();
+ hit.run();
+ };
+ document.addEventListener('keydown', onKey);
+ return () => document.removeEventListener('keydown', onKey);
+ }, [lists, native]);
+
+ useEffect(() => {
+ if (!native) return;
+ const commands = lists.flatMap((l) =>
+ l.shortcuts.filter((s) => s.mod || s.ctrl).map((s) => toNativeCommand(l.owner, s))
+ );
+ TrekShell.setKeyCommands({ commands }).catch(reportNativeFailure);
+ }, [lists, native]);
+
+ useEffect(() => {
+ if (!native) return;
+ let cancelled = false;
+ let remove: (() => Promise) | null = null;
+ TrekShell.addListener('keyCommand', ({ id }) => {
+ const at = id.indexOf(':');
+ const owner = id.slice(0, at);
+ const list = useShortcutRegistry.getState().lists.find((l) => l.owner === owner);
+ list?.shortcuts.find((s) => s.id === id.slice(at + 1))?.run();
+ })
+ .then((handle) => {
+ if (cancelled) void handle.remove();
+ else remove = handle.remove;
+ })
+ .catch(reportNativeFailure);
+ return () => {
+ cancelled = true;
+ if (remove) void remove();
+ };
+ }, [native]);
+
+ return null;
+}
diff --git a/client/src/mobile/keyboard/MShellShortcuts.tsx b/client/src/mobile/keyboard/MShellShortcuts.tsx
new file mode 100644
index 000000000..4ee562b22
--- /dev/null
+++ b/client/src/mobile/keyboard/MShellShortcuts.tsx
@@ -0,0 +1,38 @@
+import { useLocation, useMatch, useNavigate } from 'react-router';
+import { useNavItems } from '../../components/Layout/navItems';
+import { useCreateAction } from '../../components/Layout/useCreateAction';
+import { useTranslation } from '../../i18n';
+import type { Shortcut } from './shortcuts';
+import { useShortcuts } from './useShortcuts';
+
+/**
+ * The app-wide shortcuts of the touch shell: ⌘1 to ⌘9 for the sections in the
+ * order the rail shows them, ⌘N for what the "+" creates here, ⌘, for
+ * settings. Inside a trip the numbers belong to the trip's own sections
+ * (MTripShell), so the shell lets go of them there.
+ */
+export default function MShellShortcuts() {
+ const { t } = useTranslation();
+ const navigate = useNavigate();
+ const location = useLocation();
+ const inTrip = useMatch('/trips/:id');
+ const navItems = useNavItems();
+ const create = useCreateAction(true);
+ const noCreate = ['/settings', '/admin', '/vacay'].some((p) => location.pathname.startsWith(p));
+
+ const shortcuts: Shortcut[] = [
+ ...(inTrip
+ ? []
+ : navItems.slice(0, 9).map((item, i) => ({
+ id: `go-${item.id}`,
+ title: item.label,
+ key: String(i + 1),
+ mod: true,
+ run: () => void navigate(item.to),
+ }))),
+ ...(noCreate ? [] : [{ id: 'create', title: create.label, key: 'n', mod: true, run: create.run }]),
+ { id: 'settings', title: t('nav.bottomSettings'), key: ',', mod: true, run: () => void navigate('/settings') },
+ ];
+ useShortcuts('shell', shortcuts);
+ return null;
+}
diff --git a/client/src/mobile/keyboard/shortcuts.ts b/client/src/mobile/keyboard/shortcuts.ts
new file mode 100644
index 000000000..6c851a14a
--- /dev/null
+++ b/client/src/mobile/keyboard/shortcuts.ts
@@ -0,0 +1,103 @@
+import { create } from 'zustand';
+import type { NativeKeyCommand } from '../../native/trekShell';
+
+/**
+ * A hardware keyboard shortcut of the touch shell. The shell is what an iPad
+ * shows, and an iPad often has a keyboard attached: there the app should
+ * answer ⌘1 and ⌘N the way any iPad app does.
+ */
+export interface Shortcut {
+ /** Stable id, also what the app's native key command reports back. */
+ id: string;
+ /** Its name, for the overlay a held ⌘ shows and the iPadOS menu bar. */
+ title: string;
+ /** KeyboardEvent.key, lower case for letters ('n', '1', ',', 'ArrowLeft'). */
+ key: string;
+ /** ⌘ on Apple keyboards, Ctrl elsewhere. */
+ mod?: boolean;
+ shift?: boolean;
+ alt?: boolean;
+ /** The physical Control key on top of ⌘ (⌃⌘S). */
+ ctrl?: boolean;
+ run: () => void;
+}
+
+/** Whether an event is this shortcut. ⌘ and Ctrl both count as the command key. */
+export function matchesShortcut(
+ e: Pick,
+ s: Shortcut
+): boolean {
+ const key = e.key.length === 1 ? e.key.toLowerCase() : e.key;
+ if (key !== s.key) return false;
+ if (s.ctrl) {
+ if (!e.ctrlKey || !e.metaKey) return false;
+ } else if (!!s.mod !== (e.metaKey || e.ctrlKey)) {
+ return false;
+ }
+ return !!s.shift === e.shiftKey && !!s.alt === e.altKey;
+}
+
+/** Typing in a field keeps its keys: a shortcut without ⌘ never fires there. */
+export function isTypingTarget(target: EventTarget | null): boolean {
+ if (!(target instanceof HTMLElement)) return false;
+ if (target.isContentEditable) return true;
+ const tag = target.tagName;
+ return tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT';
+}
+
+/** The first shortcut of the lists (later ones first) that the event is. */
+export function findShortcut(
+ e: Pick,
+ lists: Shortcut[][]
+): Shortcut | null {
+ for (let i = lists.length - 1; i >= 0; i--) {
+ for (const s of lists[i]) {
+ if (!s.mod && !s.ctrl && isTypingTarget(e.target)) continue;
+ if (matchesShortcut(e, s)) return s;
+ }
+ }
+ return null;
+}
+
+interface ShortcutRegistry {
+ /** The lists that are live, by owner, in the order they were registered. */
+ lists: { owner: string; shortcuts: Shortcut[] }[];
+ set: (owner: string, shortcuts: Shortcut[]) => void;
+ remove: (owner: string) => void;
+}
+
+/**
+ * Every screen's live shortcuts in one place, so a single keydown listener and
+ * the app's native key commands (NativeKeyCommands) answer for all of them, a
+ * trip's own shortcuts ahead of the shell's.
+ */
+export const useShortcutRegistry = create((set) => ({
+ lists: [],
+ set: (owner, shortcuts) =>
+ set((state) => {
+ const at = state.lists.findIndex((l) => l.owner === owner);
+ if (at === -1) return { lists: [...state.lists, { owner, shortcuts }] };
+ const lists = state.lists.slice();
+ lists[at] = { owner, shortcuts };
+ return { lists };
+ }),
+ remove: (owner) => set((state) => ({ lists: state.lists.filter((l) => l.owner !== owner) })),
+}));
+
+const NATIVE_KEYS: Record = {
+ ArrowLeft: 'left',
+ ArrowRight: 'right',
+ ArrowUp: 'up',
+ ArrowDown: 'down',
+ Escape: 'escape',
+};
+
+/** A shortcut as the app's UIKeyCommand, under an id unique across screens. */
+export function toNativeCommand(owner: string, s: Shortcut): NativeKeyCommand {
+ const modifiers: string[] = [];
+ if (s.mod || s.ctrl) modifiers.push('command');
+ if (s.ctrl) modifiers.push('control');
+ if (s.shift) modifiers.push('shift');
+ if (s.alt) modifiers.push('option');
+ return { id: `${owner}:${s.id}`, title: s.title, input: NATIVE_KEYS[s.key] ?? s.key, modifiers };
+}
diff --git a/client/src/mobile/keyboard/useShortcuts.ts b/client/src/mobile/keyboard/useShortcuts.ts
new file mode 100644
index 000000000..69fca7aea
--- /dev/null
+++ b/client/src/mobile/keyboard/useShortcuts.ts
@@ -0,0 +1,27 @@
+import { useEffect, useRef } from 'react';
+import { useShortcutRegistry, type Shortcut } from './shortcuts';
+
+/**
+ * Registers a screen's keyboard shortcuts while it is mounted (MKeyboardHost
+ * answers them). The list may be rebuilt on every render: the registry only
+ * changes when a shortcut's id, name or keys do, and pressing one always runs
+ * the newest handler.
+ */
+export function useShortcuts(owner: string, shortcuts: Shortcut[]): void {
+ const latest = useRef(shortcuts);
+ useEffect(() => {
+ latest.current = shortcuts;
+ });
+ const signature = shortcuts.map((s) => [s.id, s.title, s.key, s.mod, s.shift, s.alt, s.ctrl].join('|')).join('\n');
+ const setList = useShortcutRegistry((s) => s.set);
+ const remove = useShortcutRegistry((s) => s.remove);
+ // Re-registered when the signature changes, never for a new handler alone:
+ // each registered shortcut runs whatever handler is newest when pressed.
+ useEffect(() => {
+ setList(
+ owner,
+ latest.current.map((s) => ({ ...s, run: () => latest.current.find((x) => x.id === s.id)?.run() }))
+ );
+ }, [owner, signature, setList]);
+ useEffect(() => () => remove(owner), [owner, remove]);
+}
diff --git a/client/src/mobile/mobile.css b/client/src/mobile/mobile.css
index 022531562..a26f4789d 100644
--- a/client/src/mobile/mobile.css
+++ b/client/src/mobile/mobile.css
@@ -53,6 +53,22 @@
* real devices derive them from the safe-area insets. */
--bottom-nav-h: calc(84px + env(safe-area-inset-bottom, 0px));
--m-safe-top: calc(env(safe-area-inset-top, 0px) + 12px);
+ /* The navigation rail's share of the leading edge (wide windows only), what
+ * every full-width fixed bar and the page column start after. */
+ --m-rail-w: 0px;
+}
+
+/* Wide size class (hooks/sizeClass.ts WIDE_QUERY): the rail on the leading
+ * edge takes the dock's place, so nothing docks at the bottom any more and
+ * content only clears the home indicator. */
+@media (min-width: 600px) and (min-height: 501px) {
+ .m-root {
+ --bottom-nav-h: env(safe-area-inset-bottom, 0px);
+ --m-rail-w: calc(env(safe-area-inset-left, 0px) + 92px);
+ }
+ :root[dir='rtl'] .m-root {
+ --m-rail-w: calc(env(safe-area-inset-right, 0px) + 92px);
+ }
}
.dark .m-root {
@@ -143,6 +159,18 @@
to { opacity: 0; transform: translateY(6px); }
}
+/* A form sheet on a wide window sits mid-screen, so it rises from the bottom
+ edge of the window rather than from just below its own resting place. */
+@media (min-width: 600px) and (min-height: 501px) {
+ @keyframes m-sheet-up {
+ from { transform: translateY(calc(50dvh + 50%)); }
+ to { transform: translateY(0); }
+ }
+ @keyframes m-sheet-down {
+ from { transform: translateY(0); }
+ to { transform: translateY(calc(50dvh + 50%)); }
+ }
+}
.m-sheet-in { animation: m-sheet-in 260ms var(--ease-out-quint) both; }
.m-sheet-out { animation: m-sheet-out 220ms var(--ease-drawer) both; }
.m-sheet-up { animation: m-sheet-up 420ms var(--ease-drawer) both; }
@@ -499,3 +527,94 @@
.m-root [data-field-trigger='pad'] {
padding-inline: 14px !important;
}
+
+/* ── The page column on a wide window ───────────────────────────────────────
+ Fixed bars span the page, not the window: they start after the navigation
+ rail (--m-rail-w, 0 on a phone, so these are the phone's insets there). */
+.m-bar-x {
+ inset-inline-start: calc(var(--m-rail-w, 0px) + 16px);
+ inset-inline-end: 16px;
+}
+.m-span-x {
+ inset-inline-start: var(--m-rail-w, 0px);
+ inset-inline-end: 0;
+}
+/* A screen whose background is a map reaches under the rail: the map runs to
+ the window's edge and the rail floats over it like the top controls do. Its
+ own bars then keep to the page column with m-bar-x / m-span-x. */
+.m-bleed {
+ margin-inline-start: calc(var(--m-rail-w, 0px) * -1);
+}
+/* The trip's pane beside the map (split size class, MTripShell): a third of
+ the window, within what a list and its rows need. On a foldable that reports
+ its fold (two horizontal viewport segments), the pane takes the first half
+ to the fold exactly, so no row runs across the crease and the map has the
+ other half to itself. */
+.m-trip {
+ --trip-pane-open: clamp(360px, 38vw, 460px);
+}
+@media (horizontal-viewport-segments: 2) {
+ .m-trip {
+ --trip-pane-open: calc(env(viewport-segment-width 0 0, 50vw) - var(--m-rail-w, 0px));
+ }
+}
+
+/* The phone rules of index.css, for the app. It shows this shell at every
+ size, an iPad's included (mobile/useIsPhone.ts), where their media query does
+ not match; the shell's root carries .m-shell, so they follow it there: the
+ document is the scroller, the shell paints the background, no zoom buttons
+ on a touch map, no scrollbars. */
+html:has(.m-shell) {
+ overflow: visible;
+ overscroll-behavior: none;
+}
+html:has(.m-shell) body {
+ height: auto;
+ overflow: visible;
+ overflow-x: clip;
+ background-color: transparent;
+}
+html:has(.m-shell) .leaflet-control-zoom {
+ display: none !important;
+}
+html:has(.m-shell) * {
+ scrollbar-width: none;
+}
+html:has(.m-shell) ::-webkit-scrollbar {
+ width: 0;
+ height: 0;
+}
+
+/* While the trip's map runs under the rail (MTripShell, --trip-map-inset), the
+ controls both engines draw in its corners step clear of the rail. A margin on
+ the leading side moves only the corner next to the rail, in either reading
+ direction: the corner on the far side is anchored there and does not move. */
+.m-trip .leaflet-control-container > div,
+.m-trip .maplibregl-control-container > div,
+.m-trip .mapboxgl-control-container > div {
+ margin-inline-start: var(--trip-map-inset, 0px);
+}
+
+/* A horizontal strip with more behind an edge fades out there
+ (components/useEdgeFade.ts), so a cut chip reads as "the row goes on". */
+.m-fade-s,
+.m-fade-e,
+.m-fade-se {
+ --m-fade-w: 28px;
+ -webkit-mask-image: var(--m-fade-mask);
+ mask-image: var(--m-fade-mask);
+}
+.m-fade-s {
+ --m-fade-mask: linear-gradient(var(--m-fade-dir, 90deg), transparent 0, #000 var(--m-fade-w));
+}
+.m-fade-e {
+ --m-fade-mask: linear-gradient(var(--m-fade-dir, 90deg), #000 calc(100% - var(--m-fade-w)), transparent 100%);
+}
+.m-fade-se {
+ --m-fade-mask: linear-gradient(var(--m-fade-dir, 90deg), transparent 0, #000 var(--m-fade-w), #000 calc(100% - var(--m-fade-w)), transparent 100%);
+}
+:root[dir='rtl'] .m-fade-s,
+:root[dir='rtl'] .m-fade-e,
+:root[dir='rtl'] .m-fade-se {
+ --m-fade-dir: 270deg;
+}
diff --git a/client/src/mobile/screens/admin/MAdmin.tsx b/client/src/mobile/screens/admin/MAdmin.tsx
index 4c29ccc7b..ebb3f94cc 100644
--- a/client/src/mobile/screens/admin/MAdmin.tsx
+++ b/client/src/mobile/screens/admin/MAdmin.tsx
@@ -107,7 +107,7 @@ export default function MAdmin() {
return (
// Flow screen: scrolls with the document (#1809), so no height and no
// scroll container of its own.
-
+
{/* Header: back · section switcher · create user */}