fix(mobile): iPad feedback: columns start level, map controls sit low, no day-rail chevrons, no bottom-bar settings on a tablet, and a planned place on the journey map can be written up

This commit is contained in:
Maurice
2026-11-08 11:30:45 +01:00
parent 6a60fc183a
commit 42341c2c76
24 changed files with 192 additions and 149 deletions
@@ -1,3 +1,4 @@
import type { JourneyMapPlace } from '@trek/shared';
import { useCallback, useState, type ComponentProps, type Ref } from 'react';
import JourneyMap, { type JourneyMapHandle } from './JourneyMap';
import JourneyMapAuto from './JourneyMapAuto';
@@ -27,6 +28,13 @@ interface Props extends MapProps {
/** Leads from a picked place or stay to its entry. */
onOpenEntry?: (entryId: string) => void;
entryTitleOf?: (entryId: number) => string | null;
/** Starts an entry about a picked planned place nothing was written about; absent for a reader who cannot. */
onWriteAboutPlace?: (place: JourneyMapPlace) => void;
}
/** A card action, only where the screen offers one. */
function offeredIf<T>(offered: unknown, action: T): T | undefined {
return offered ? action : undefined;
}
/**
@@ -44,6 +52,7 @@ export default function JourneyLayeredMap({
controlsTop = 12,
onOpenEntry,
entryTitleOf,
onWriteAboutPlace,
photos,
tracks,
height = 220,
@@ -55,6 +64,13 @@ export default function JourneyLayeredMap({
setPicked({ marks, key: marks.map((m) => m.key).join(',') });
}, []);
const close = useCallback(() => setPicked(null), []);
const writeAbout = useCallback(
(place: JourneyMapPlace) => {
setPicked(null);
onWriteAboutPlace?.(place);
},
[onWriteAboutPlace]
);
const openEntry = useCallback(
(entryId: string) => {
setPicked(null);
@@ -99,6 +115,7 @@ export default function JourneyLayeredMap({
marks={card.marks}
onClose={close}
onOpenEntry={onOpenEntry ? openEntry : undefined}
onWriteAbout={offeredIf(onWriteAboutPlace, writeAbout)}
entryTitleOf={entryTitleOf}
/>
)}
@@ -86,4 +86,23 @@ describe('JourneyMapPickCard', () => {
fireEvent.keyDown(window, { key: 'Escape' });
expect(onClose).toHaveBeenCalled();
});
it('FE-JOURNEY-MAPPICK-004: a place nothing was written about offers a new entry to whoever can write', () => {
const onWriteAbout = vi.fn();
const { unmount } = render(<JourneyMapPickCard marks={[plan()]} onClose={vi.fn()} onWriteAbout={onWriteAbout} />);
fireEvent.click(screen.getByRole('button', { name: 'New entry' }));
expect(onWriteAbout).toHaveBeenCalledWith(expect.objectContaining({ place_id: 4, name: 'Piazza San Marco' }));
unmount();
// A reader who cannot write, or a place already written about, gets no such button.
render(
<JourneyMapPickCard
marks={[plan({ entry_id: 7 })]}
onClose={vi.fn()}
onOpenEntry={vi.fn()}
onWriteAbout={onWriteAbout}
/>
);
expect(screen.queryByRole('button', { name: 'New entry' })).toBeNull();
});
});
@@ -1,5 +1,5 @@
import type { JourneyMapPlace, JourneyMapStay } from '@trek/shared';
import { CalendarRange, ChevronLeft, ChevronRight, Clock, MapPin, NotebookPen, X } from 'lucide-react';
import { CalendarRange, ChevronLeft, ChevronRight, Clock, MapPin, NotebookPen, PenLine, X } from 'lucide-react';
import { useEffect, useState } from 'react';
import { useTranslation } from '../../i18n';
import { SoftPill, WhiteBadge } from '../Planner/planParts';
@@ -14,6 +14,8 @@ interface Props {
onOpenEntry?: (entryId: string) => void;
/** The title of an entry the reader can see, for the stay that belongs to it. */
entryTitleOf?: (entryId: number) => string | null;
/** Starts an entry about a planned place nothing was written about; absent where the reader cannot write. */
onWriteAbout?: (place: JourneyMapPlace) => void;
}
function dayLabel(date: string, locale: string): string {
@@ -41,7 +43,15 @@ function OpenEntry({ entryId, onOpenEntry }: { entryId: number; onOpenEntry?: (e
);
}
function PlaceDetail({ place, onOpenEntry }: { place: JourneyMapPlace; onOpenEntry?: (entryId: string) => void }) {
function PlaceDetail({
place,
onOpenEntry,
onWriteAbout,
}: {
place: JourneyMapPlace;
onOpenEntry?: (entryId: string) => void;
onWriteAbout?: (place: JourneyMapPlace) => void;
}) {
const { t, locale } = useTranslation();
return (
<div className="flex flex-col gap-2">
@@ -56,9 +66,22 @@ function PlaceDetail({ place, onOpenEntry }: { place: JourneyMapPlace; onOpenEnt
{place.entry_id !== null ? (
<OpenEntry entryId={place.entry_id} onOpenEntry={onOpenEntry} />
) : (
<p className="text-content-muted" style={fs(11.5, 'body')}>
{t('journey.map.pick.notWritten')}
</p>
<>
<p className="text-content-muted" style={fs(11.5, 'body')}>
{t('journey.map.pick.notWritten')}
</p>
{onWriteAbout && (
<button
type="button"
onClick={() => onWriteAbout(place)}
className="inline-flex items-center gap-1 self-start rounded-lg bg-accent px-2.5 py-1.5 font-semibold text-accent-text hover:opacity-90"
style={fs(11.5, 'body')}
>
<PenLine size={12} strokeWidth={2.2} aria-hidden />
{t('journey.detail.newEntry')}
</button>
)}
</>
)}
</div>
);
@@ -106,7 +129,7 @@ function markName(mark: JourneyMapMark): string {
* one spot come as a list first, each with what kind it is, so overlapping
* hits stay reachable one by one.
*/
export default function JourneyMapPickCard({ marks, onClose, onOpenEntry, entryTitleOf }: Props) {
export default function JourneyMapPickCard({ marks, onClose, onOpenEntry, entryTitleOf, onWriteAbout }: Props) {
const { t, locale } = useTranslation();
const [picked, setPicked] = useState<JourneyMapMark | null>(marks.length === 1 ? marks[0] : null);
@@ -150,7 +173,9 @@ export default function JourneyMapPickCard({ marks, onClose, onOpenEntry, entryT
<X size={14} strokeWidth={2.2} />
</button>
</div>
{picked?.kind === 'plan' && <PlaceDetail place={picked.place} onOpenEntry={onOpenEntry} />}
{picked?.kind === 'plan' && (
<PlaceDetail place={picked.place} onOpenEntry={onOpenEntry} onWriteAbout={onWriteAbout} />
)}
{picked?.kind === 'stay' && (
<StayDetail stay={picked.stay} onOpenEntry={onOpenEntry} entryTitleOf={entryTitleOf} />
)}
@@ -8,7 +8,7 @@ import JourneyDayScrubber from './JourneyDayScrubber'
import { dayColorOf } from './journeyCard'
import { useJourneyCarouselSync } from './useJourneyCarouselSync'
import type { JourneyEntry } from '../../store/journeyStore'
import type { JourneyTrack } from '@trek/shared'
import type { JourneyMapPlace, JourneyTrack } from '@trek/shared'
interface MapEntry {
id: string
@@ -40,6 +40,8 @@ interface Props {
/** The map's layers (JRN-04); a picked place or stay leads to its entry's card. */
layers?: JourneyMapLayersView | null
entryTitleOf?: (entryId: number) => string | null
/** Starts an entry about a picked planned place nothing was written about. */
onWriteAboutPlace?: (place: JourneyMapPlace) => void
/** Geotagged photos on the map, a tap opening them. */
photos?: MapPhoto[]
onPhotoClick?: (photoIds: string[]) => void
@@ -64,6 +66,7 @@ export default function MobileMapTimeline({
initialEntryId,
layers,
entryTitleOf,
onWriteAboutPlace,
photos,
onPhotoClick,
controlsTop,
@@ -118,6 +121,7 @@ export default function MobileMapTimeline({
hideLayerControl
controlsTop={controlsTop}
onOpenEntry={handleMarkerClick}
onWriteAboutPlace={onWriteAboutPlace}
entryTitleOf={entryTitleOf}
entries={mapEntries}
checkins={[]}
@@ -160,6 +164,7 @@ export default function MobileMapTimeline({
hideLayerControl
controlsTop={controlsTop}
onOpenEntry={handleMarkerClick}
onWriteAboutPlace={onWriteAboutPlace}
entryTitleOf={entryTitleOf}
entries={mapEntries}
checkins={[]}