diff --git a/client/scripts/feature-pairs.json b/client/scripts/feature-pairs.json index 53de49cb5..db76f9345 100644 --- a/client/scripts/feature-pairs.json +++ b/client/scripts/feature-pairs.json @@ -1038,7 +1038,7 @@ "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/tours/tourHeadSlot.ts": "Phone shell only; the place in the shell's top row the tours tab fills with its switch and map button. The desktop planner heads its rails itself.", + "src/mobile/screens/trip/tabHeadSlot.ts": "Phone shell only; the place in the shell's top row the tours tab and the journal fill with their own switches. The desktop heads its panels itself.", "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.", diff --git a/client/src/mobile/screens/journey/MJourneyDetail.tsx b/client/src/mobile/screens/journey/MJourneyDetail.tsx index c92e45c2b..59a936a0f 100644 --- a/client/src/mobile/screens/journey/MJourneyDetail.tsx +++ b/client/src/mobile/screens/journey/MJourneyDetail.tsx @@ -1,4 +1,4 @@ -import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react' +import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore, type CSSProperties, type ReactNode } from 'react' import { Outlet, useSearchParams } from 'react-router' import { BookOpen, ChevronLeft, MapPin, Grid3x3, MoreHorizontal, Play, Image, Camera, EyeOff, Settings2, X, Route, ListChecks } from 'lucide-react' import JourneyLayeredMap from '../../../components/Journey/JourneyLayeredMap' @@ -32,6 +32,8 @@ import MJourneyFeed from './MJourneyFeed' import MJourneySettingsSheet from './MJourneySettingsSheet' import MJourneyDayImportSheet from './MJourneyDayImportSheet' import MJourneyRecordingSheet from './MJourneyRecordingSheet' +import { createPortal } from 'react-dom' +import { useTabHeadSlot } from '../trip/tabHeadSlot' /** * Journey detail — integrated map with the horizontal 280px card timeline @@ -86,6 +88,9 @@ export default function MJourneyDetail({ journeyId, embedded = false }: JourneyD loadJourney, updateEntry, deleteEntry, reorderEntries, uploadPhotos, addPickedProviderPhotos, addEntryProviderPhotos, writeAboutPlace, } = useJourneyDetail({ journeyId, embedded }) + // A trip tab: the header goes into the trip shell's top row (tabHeadSlot.ts). + const shellSlot = useTabHeadSlot() + const headSlot = embedded ? shellSlot : null // The dock's FAB is a sibling of this screen: on the Gallery it becomes the // upload button, so it has to know which tab is open — and it stops knowing @@ -339,7 +344,7 @@ export default function MJourneyDetail({ journeyId, embedded = false }: JourneyD return ( // h-dvh, not h-full: the shell stopped providing a definite height (#1809) // and a map on a percentage of an auto-height parent collapses to zero. -
+
{/* Integrated map — always mounted, the gallery overlays it. Beside the feed it begins where the feed ends, so its controls and its framing stay in the part that can be seen. */} @@ -448,10 +453,7 @@ export default function MJourneyDetail({ journeyId, embedded = false }: JourneyD {/* Header: back — segment — upload / overflow menu. Beside the feed it keeps to the feed, as the trip's controls keep to its pane. */} -
+ {embedded ? ( ) : ( @@ -464,7 +466,10 @@ export default function MJourneyDetail({ journeyId, embedded = false }: JourneyD )} -
+
-
+ {/* The stays Dawarich recorded for these dates, as candidate entries. Over the map rather than in the header: it belongs to what is on the map, @@ -824,3 +829,30 @@ export default function MJourneyDetail({ journeyId, embedded = false }: JourneyD
) } + +/** + * With the header in the shell's row, what the screen measures from its top + * starts right under that row instead of under a row of its own. + */ +const IN_SHELL_ROW = { '--m-safe-top': 'calc(env(safe-area-inset-top, 0px) + 6px)' } as CSSProperties + +/** The header row: on the screen, or in the trip shell's top row when the journal is a trip tab. */ +function HeaderFrame({ slot, feed, children }: { slot: HTMLElement | null; feed: boolean; children: ReactNode }) { + if (slot) { + return createPortal( +
+ {children} +
, + slot + ) + } + return ( +
+ {children} +
+ ) +} + diff --git a/client/src/mobile/screens/trip/MTripShell.tsx b/client/src/mobile/screens/trip/MTripShell.tsx index 4e2313b37..972b45b0b 100644 --- a/client/src/mobile/screens/trip/MTripShell.tsx +++ b/client/src/mobile/screens/trip/MTripShell.tsx @@ -35,7 +35,7 @@ import { edgeFadeClass, useEdgeFade } from '../../components/useEdgeFade' import { useShortcuts } from '../../keyboard/useShortcuts' import { tripCreateIntent } from '../../../components/Layout/useCreateAction' import MDockScrim from '../../components/MDockScrim' -import { setTourHeadSlot } from './tours/tourHeadSlot' +import { setTabHeadSlot } from './tabHeadSlot' /** * Mobile trip screen frame. Owns the chrome the design shares across every @@ -866,8 +866,8 @@ export default function MTripShell({ not in the dock, so nothing was lit up there either, and the screen gave no clue which plugin was open. Same treatment as the others, from the tab entry the planner already builds (id, label, icon). */} - {/* The tours tab puts its own controls here instead (tours/tourHeadSlot.ts). */} - {trTab === 'tour-planner' &&
} + {/* The tours tab and the journal put their own controls here instead (tabHeadSlot.ts). */} + {(trTab === 'tour-planner' || trTab === 'journal') &&
} {trTab.startsWith('plugin:') && (() => { const tab = planner.TRIP_TABS.find(x => x.id === trTab) if (!tab) return null diff --git a/client/src/mobile/screens/trip/tours/tourHeadSlot.ts b/client/src/mobile/screens/trip/tabHeadSlot.ts similarity index 55% rename from client/src/mobile/screens/trip/tours/tourHeadSlot.ts rename to client/src/mobile/screens/trip/tabHeadSlot.ts index 31565bbff..eada67f2b 100644 --- a/client/src/mobile/screens/trip/tours/tourHeadSlot.ts +++ b/client/src/mobile/screens/trip/tabHeadSlot.ts @@ -1,8 +1,9 @@ /** - * The place in the trip shell's top row that the tours tab fills with its own - * controls: the switch between the trip's tours and the editor, and on a window - * that shows the pane or the map, the map button. The row has the back button - * on one side and nothing else to say on a tablet, so the tab's name made way. + * The place in the trip shell's top row that a tab fills with its own controls, + * beside the back button: the tours tab its switch between the trip's tours and + * the editor (and the map button where the window shows the pane or the map), + * the journal its Journey/Gallery switch and its menu. Without it those sat on + * a row of their own under the shell's, an empty band above every such tab. * * The shell hands the node in through a callback ref; the tab portals into it. * Kept outside React state so the shell does not render again for it. @@ -13,7 +14,7 @@ let slot: HTMLElement | null = null; const listeners = new Set<() => void>(); /** The callback ref of the shell's slot. */ -export function setTourHeadSlot(node: HTMLElement | null): void { +export function setTabHeadSlot(node: HTMLElement | null): void { if (node === slot) return; slot = node; for (const listener of listeners) listener(); @@ -24,8 +25,8 @@ function subscribe(listener: () => void): () => void { return () => listeners.delete(listener); } -/** The slot while the shell shows it, else null (the tab then keeps its controls in its pane). */ -export function useTourHeadSlot(): HTMLElement | null { +/** The slot while the shell shows it, else null (the tab then keeps its controls on its own row). */ +export function useTabHeadSlot(): HTMLElement | null { return useSyncExternalStore( subscribe, () => slot, diff --git a/client/src/mobile/screens/trip/tours/MTourWorkspace.tsx b/client/src/mobile/screens/trip/tours/MTourWorkspace.tsx index fe6ede02f..f8a618fa5 100644 --- a/client/src/mobile/screens/trip/tours/MTourWorkspace.tsx +++ b/client/src/mobile/screens/trip/tours/MTourWorkspace.tsx @@ -13,7 +13,7 @@ import { useTripPlannerPageOf } from '../../../../pages/tripPlanner/useTripPlann import MIconBtn from '../../../components/MIconBtn'; import MSegmented from '../../../components/MSegmented'; import type { MTripTabPanelProps } from '../MTripShell'; -import { useTourHeadSlot } from './tourHeadSlot'; +import { useTabHeadSlot } from '../tabHeadSlot'; /** The pane's two halves: the trip's tours, or the editor with the tour open in it. */ type MTourPane = 'tours' | 'editor'; @@ -67,7 +67,7 @@ export default function MTourWorkspace({ planner }: Pick { setPane(next); diff --git a/client/tests/unit/mobile/journey/MJourneyDetail.test.tsx b/client/tests/unit/mobile/journey/MJourneyDetail.test.tsx index affcde569..42d24a87d 100644 --- a/client/tests/unit/mobile/journey/MJourneyDetail.test.tsx +++ b/client/tests/unit/mobile/journey/MJourneyDetail.test.tsx @@ -3,6 +3,7 @@ import { describe, it, expect, beforeEach, afterEach, onTestFinished, vi } from import { setSizeClass } from '../../../helpers/sizeClass'; import { render, screen, fireEvent, waitFor, act } from '../../../helpers/render'; import MJourneyDetail from '../../../../src/mobile/screens/journey/MJourneyDetail'; +import { setTabHeadSlot } from '../../../../src/mobile/screens/trip/tabHeadSlot'; import { addonsApi, journeyApi, memoriesApi } from '../../../../src/api/client'; import { useJourneyStore } from '../../../../src/store/journeyStore'; import { useAuthStore } from '../../../../src/store/authStore'; @@ -336,6 +337,23 @@ describe('MJourneyDetail', () => { expect(hook.setView).toHaveBeenCalledWith('timeline'); }); + it("FE-MOB-JDET-050: as a trip tab the switch and the menu sit in the trip shell's top row", () => { + const slot = document.createElement('div'); + document.body.appendChild(slot); + setTabHeadSlot(slot); + try { + mocks.detail = buildHook(); + render(); + expect(slot).toContainElement(screen.getByRole('button', { name: /journey.share.gallery/ })); + expect(slot).toContainElement(screen.getByRole('button', { name: 'files.menu' })); + // The view switch stands beside the back button rather than centred over the screen. + expect(slot.querySelector('[data-view-switch]')?.parentElement?.className).toContain('[&_[data-view-switch]]:static'); + } finally { + setTabHeadSlot(null); + slot.remove(); + } + }); + it('FE-MOB-JDET-010: back navigates to the journey list', () => { const { hook } = setup(); fireEvent.click(screen.getByRole('button', { name: 'journey.detail.backToJourney' })); diff --git a/client/tests/unit/mobile/trip/MTourWorkspace.test.tsx b/client/tests/unit/mobile/trip/MTourWorkspace.test.tsx index 73185d266..9e253caed 100644 --- a/client/tests/unit/mobile/trip/MTourWorkspace.test.tsx +++ b/client/tests/unit/mobile/trip/MTourWorkspace.test.tsx @@ -1,8 +1,8 @@ import { fireEvent } from '@testing-library/react'; import type { ReactNode } from 'react'; import { beforeEach, describe, expect, it, vi } from 'vitest'; +import { setTabHeadSlot } from '../../../../src/mobile/screens/trip/tabHeadSlot'; import MTourWorkspace from '../../../../src/mobile/screens/trip/tours/MTourWorkspace'; -import { setTourHeadSlot } from '../../../../src/mobile/screens/trip/tours/tourHeadSlot'; import { buildPlanner } from '../../../helpers/mobileTrip'; import { render, screen } from '../../../helpers/render'; import { setSizeClass } from '../../../helpers/sizeClass'; @@ -59,7 +59,7 @@ beforeEach(() => { page.wandererOpen = false; page.calls = []; dragBridge.mockClear(); - setTourHeadSlot(null); + setTabHeadSlot(null); }); describe('MTourWorkspace', () => { @@ -141,7 +141,7 @@ describe('MTourWorkspace', () => { setSizeClass('wide'); const slot = document.createElement('div'); document.body.appendChild(slot); - setTourHeadSlot(slot); + setTabHeadSlot(slot); render(); expect(await screen.findByTestId('tour-list')).toBeInTheDocument(); expect(slot).toContainElement(screen.getByRole('tab', { name: 'tours.planner.tripTours' }));