mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-21 11:36:05 +00:00
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:
@@ -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={[]}
|
||||
|
||||
@@ -41,14 +41,14 @@ export default function MImageViewer({
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-label={alt}
|
||||
className="m-root fixed inset-0 z-[65] bg-black/[.92]"
|
||||
className="m-root fixed inset-0 z-[var(--z-overlay)] bg-[color:var(--m-viewer-bg)]"
|
||||
onClick={onClose}
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClose}
|
||||
aria-label={t('collab.chat.closeImage')}
|
||||
className="absolute end-4 top-[calc(var(--m-safe-top,12px)+4px)] z-10 flex h-10 w-10 items-center justify-center rounded-full bg-white/15 text-white"
|
||||
className="absolute end-4 top-[calc(var(--m-safe-top,12px)+4px)] z-10 flex h-10 w-10 items-center justify-center rounded-full bg-[color:var(--m-viewer-btn)] text-[color:var(--m-viewer-ink)]"
|
||||
>
|
||||
<X size={20} strokeWidth={2} />
|
||||
</button>
|
||||
|
||||
@@ -21,6 +21,10 @@
|
||||
--m-act: #101013;
|
||||
--m-actfg: #fff;
|
||||
--m-dim: rgba(16,16,19,.4);
|
||||
/* A picture shown full screen (MImageViewer): dark in either scheme, as a photo viewer is. */
|
||||
--m-viewer-bg: rgba(0,0,0,.92);
|
||||
--m-viewer-ink: #fff;
|
||||
--m-viewer-btn: rgba(255,255,255,.15);
|
||||
--m-sheet: rgba(250,250,248,.94);
|
||||
--m-sheetop: #FAFAF8;
|
||||
--m-shbr: rgba(255,255,255,.95);
|
||||
|
||||
@@ -295,7 +295,7 @@ export default function MDashboard(): React.ReactElement {
|
||||
)}
|
||||
<div style={{ order: dashOrder.indexOf('trips') }}>{renderBlock('trips')}</div>
|
||||
</div>
|
||||
<div className="contents min-w-0 split:sticky split:top-[calc(var(--m-safe-top,12px)+82px)] split:-mt-[14px] split:block">
|
||||
<div className="contents min-w-0 split:sticky split:top-[calc(var(--m-safe-top,12px)+70px)] split:-mt-3 split:block">
|
||||
{dashOrder.filter(id => id !== 'trips').map(id => (
|
||||
<div key={id} style={{ order: dashOrder.indexOf(id) }}>{renderBlock(id)}</div>
|
||||
))}
|
||||
|
||||
@@ -84,7 +84,7 @@ export default function MJourneyDetail({ journeyId, embedded = false }: JourneyD
|
||||
sidebarMapItems, tracks, mapLayers, entryTitleOf, mapPhotos, openMapPhotos, recordings, canTakeOverRecording, dayImport, dayImportDates, dawarichByDate, recordingPrep,
|
||||
dismissSuggestion, restoreSuggestions, openAtEntryId,
|
||||
loadJourney, updateEntry, deleteEntry, reorderEntries, uploadPhotos,
|
||||
addPickedProviderPhotos, addEntryProviderPhotos,
|
||||
addPickedProviderPhotos, addEntryProviderPhotos, writeAboutPlace,
|
||||
} = useJourneyDetail({ journeyId, embedded })
|
||||
|
||||
// The dock's FAB is a sibling of this screen: on the Gallery it becomes the
|
||||
@@ -353,6 +353,7 @@ export default function MJourneyDetail({ journeyId, embedded = false }: JourneyD
|
||||
hideLayerControl
|
||||
controlsTop="calc(var(--m-safe-top, 12px) + 50px)"
|
||||
onOpenEntry={handleMarkerClick}
|
||||
onWriteAboutPlace={writeAboutPlace}
|
||||
entryTitleOf={entryTitleOf}
|
||||
checkins={[]}
|
||||
entries={sidebarMapItems}
|
||||
|
||||
@@ -9,6 +9,7 @@ import MToggle from '../../components/MToggle'
|
||||
import { MSetCard, MSetEyebrow, MSetSegments, MSetRow } from './MSettingsUi'
|
||||
import MMobileNavCustomizer from './MMobileNavCustomizer'
|
||||
import MMobileDashOrder from './MMobileDashOrder'
|
||||
import { useIsWide } from '../../../hooks/sizeClass'
|
||||
|
||||
function SliderRow({ label, sub, value, onChange }: { label: string; sub?: string; value: number; onChange: (v: number) => void }) {
|
||||
return (
|
||||
@@ -41,6 +42,8 @@ function SliderRow({ label, sub, value, onChange }: { label: string; sub?: strin
|
||||
*/
|
||||
export default function MSettingsAppearance() {
|
||||
const { t } = useTranslation()
|
||||
// A tablet has the rail on its side, no bottom bar: only the dashboard's order is left to set.
|
||||
const wide = useIsWide()
|
||||
const { cfg, darkMode, isDark, update, setMode, setWidget, resetAll, accentLight, accentDark, customRatio } =
|
||||
useAppearanceEditor()
|
||||
|
||||
@@ -156,11 +159,18 @@ export default function MSettingsAppearance() {
|
||||
)}
|
||||
</MSetCard>
|
||||
|
||||
<MSetCard title={t('settings.appearance.mobile')} icon={Smartphone} className="mt-3">
|
||||
<MSetEyebrow className="mb-[6px]">{t('settings.appearance.mobileNav')}</MSetEyebrow>
|
||||
<MMobileNavCustomizer value={cfg.mobileNav} onChange={(mn) => update({ mobileNav: mn })} />
|
||||
|
||||
<MSetEyebrow className="mb-[6px] mt-[14px]">{t('settings.appearance.dashOrder')}</MSetEyebrow>
|
||||
<MSetCard
|
||||
title={wide ? t('settings.appearance.dashOrder') : t('settings.appearance.mobile')}
|
||||
icon={wide ? LayoutDashboard : Smartphone}
|
||||
className="mt-3"
|
||||
>
|
||||
{!wide && (
|
||||
<>
|
||||
<MSetEyebrow className="mb-[6px]">{t('settings.appearance.mobileNav')}</MSetEyebrow>
|
||||
<MMobileNavCustomizer value={cfg.mobileNav} onChange={(mn) => update({ mobileNav: mn })} />
|
||||
<MSetEyebrow className="mb-[6px] mt-[14px]">{t('settings.appearance.dashOrder')}</MSetEyebrow>
|
||||
</>
|
||||
)}
|
||||
<p className="-mt-[2px] mb-2 font-geist text-[0.625rem] leading-relaxed text-m-muted">{t('settings.appearance.dashOrder.hint')}</p>
|
||||
<MMobileDashOrder cfg={cfg} onChange={(order) => update({ dashboard: { ...cfg.dashboard, mobileOrder: order } })} />
|
||||
</MSetCard>
|
||||
|
||||
@@ -29,7 +29,7 @@ import { useDayPreviewStore } from '../../dayPreviewStore'
|
||||
import { useIsSplit, useIsWide } from '../../../hooks/sizeClass'
|
||||
import MTripRail from './MTripRail'
|
||||
import {
|
||||
CollabSegment, CompactToggle, DayRailSteps, DockMoreButton, DocSyncButton, GlassSegment, HeaderActions, PrimaryPill, ROW_AFTER_BACK, ROW_CENTRED,
|
||||
CollabSegment, CompactToggle, DockMoreButton, DocSyncButton, GlassSegment, HeaderActions, PrimaryPill, ROW_AFTER_BACK, ROW_CENTRED,
|
||||
} from './MTripShellParts'
|
||||
import { edgeFadeClass, useEdgeFade } from '../../components/useEdgeFade'
|
||||
import { useShortcuts } from '../../keyboard/useShortcuts'
|
||||
@@ -645,7 +645,6 @@ export default function MTripShell({
|
||||
{/* The glass is the outer box, the scroller sits inside its padding: that way
|
||||
the fade at an edge that runs on takes the chips, not the glass's rim. */}
|
||||
<div className="relative flex min-w-0 flex-1 rounded-full border border-[color:var(--m-gbr)] bg-[color:var(--m-glass)] p-[3px] backdrop-blur-[24px] backdrop-saturate-[1.7]">
|
||||
<DayRailSteps rail={dayRail} fade={dayFade} />
|
||||
<div ref={setDayRail} className={`relative flex min-w-0 flex-1 items-center gap-[2px] overflow-x-auto rounded-full wide:[--m-fade-reach:52px] ${edgeFadeClass(dayFade)}`}>
|
||||
{dayPill && (
|
||||
<span
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ChevronLeft, ChevronRight, FolderSync, List, MoreHorizontal, Plus, Rows3 } from 'lucide-react';
|
||||
import { FolderSync, List, MoreHorizontal, Plus, Rows3 } from 'lucide-react';
|
||||
import { useCallback, useLayoutEffect, useRef, useState, type ReactNode } from 'react';
|
||||
import { canManageDocSync } from '../../../components/Files/docsync/useDocSync';
|
||||
import { useDocSyncOffered } from '../../../components/Files/docsync/useDocSyncOffered';
|
||||
@@ -6,7 +6,7 @@ import { useIsWide } from '../../../hooks/sizeClass';
|
||||
import { useAuthStore } from '../../../store/authStore';
|
||||
import type { Trip } from '../../../types';
|
||||
import MIconBtn from '../../components/MIconBtn';
|
||||
import { edgeFadeClass, useEdgeFade, type EdgeFade } from '../../components/useEdgeFade';
|
||||
import { edgeFadeClass, useEdgeFade } from '../../components/useEdgeFade';
|
||||
import type { MTripCollabTab } from './MTripShell';
|
||||
import { collabBoardFor, collabSideBySide } from './tabs/collabPanes';
|
||||
|
||||
@@ -119,67 +119,6 @@ export function HeaderActions({
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The day strip's way on past an edge, on a wide window: a round chevron over
|
||||
* the faded end that pages the strip along. The fade alone was too quiet on a
|
||||
* large screen, where a day cut in half at the end ("Wed") read as a mistake
|
||||
* rather than as more to come. The days themselves stay where a screen reader
|
||||
* and the keyboard reach them, so the chevron is for the eye and the finger only.
|
||||
*/
|
||||
export function DayRailSteps({ rail, fade }: { rail: HTMLElement | null; fade: EdgeFade }) {
|
||||
const wide = useIsWide();
|
||||
if (!wide || !rail) return null;
|
||||
// A page along: the day the edge cuts comes to the other edge, whole, so the
|
||||
// next tap continues from there. Read in reading order, so a right-to-left
|
||||
// strip pages the same way round.
|
||||
const step = (toward: 'start' | 'end') => {
|
||||
const rtl = getComputedStyle(rail).direction === 'rtl';
|
||||
const box = rail.getBoundingClientRect();
|
||||
const chips = Array.from(rail.querySelectorAll<HTMLElement>('button'));
|
||||
const pastEnd = (r: DOMRect) => (rtl ? r.left < box.left - 1 : r.right > box.right + 1);
|
||||
const pastStart = (r: DOMRect) => (rtl ? r.right > box.right + 1 : r.left < box.left - 1);
|
||||
const target =
|
||||
toward === 'end'
|
||||
? chips.find((chip) => pastEnd(chip.getBoundingClientRect()))
|
||||
: chips.filter((chip) => pastStart(chip.getBoundingClientRect())).pop();
|
||||
const reduced = window.matchMedia?.('(prefers-reduced-motion: reduce)')?.matches;
|
||||
// 'nearest' on the block axis: the shell root is fixed, anything else scrolls the page behind it.
|
||||
target?.scrollIntoView({
|
||||
inline: toward === 'end' ? 'start' : 'end',
|
||||
block: 'nearest',
|
||||
behavior: reduced ? 'auto' : 'smooth',
|
||||
});
|
||||
};
|
||||
const btn =
|
||||
'absolute top-1/2 z-[1] flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-full border border-[color:var(--m-gbr)] bg-[color:var(--m-sheetop)] text-m-ink shadow-[0_4px_12px_-4px_rgba(0,0,0,.35)]';
|
||||
return (
|
||||
<>
|
||||
{fade.start && (
|
||||
<button
|
||||
type="button"
|
||||
tabIndex={-1}
|
||||
aria-hidden="true"
|
||||
onClick={() => step('start')}
|
||||
className={`${btn} start-[4px]`}
|
||||
>
|
||||
<ChevronLeft size={15} strokeWidth={2.4} className="rtl:-scale-x-100" />
|
||||
</button>
|
||||
)}
|
||||
{fade.end && (
|
||||
<button
|
||||
type="button"
|
||||
tabIndex={-1}
|
||||
aria-hidden="true"
|
||||
onClick={() => step('end')}
|
||||
className={`${btn} end-[4px]`}
|
||||
>
|
||||
<ChevronRight size={15} strokeWidth={2.4} className="rtl:-scale-x-100" />
|
||||
</button>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
interface CollabSegmentProps {
|
||||
active: MTripCollabTab;
|
||||
onPick: (tab: MTripCollabTab) => void;
|
||||
|
||||
@@ -345,12 +345,14 @@ export default function MMapArea({ planner, shell }: MMapAreaProps) {
|
||||
// the overview stack) follows on its own. The band used to float a further 38px up to
|
||||
// leave the corner under it to the map credit; the phone map carries no visible credit
|
||||
// any more (see mobile.css), so that row would now only be a gap over the dock.
|
||||
// A wide window has no dock (the rail stands on the side), so there the floor is
|
||||
// the safe area alone and the controls sit down in the corners.
|
||||
//
|
||||
// The metrics are classes rather than an inline --bottom-nav-h, and the lift is its
|
||||
// OWN variable folded into them: the compass band below is identified by being the
|
||||
// one element that sets that name inline, and a second one would make that ambiguous.
|
||||
<div
|
||||
className="absolute inset-0 isolate overflow-hidden bg-[color:var(--m-mapb)] [--m-map-floor:calc(env(safe-area-inset-bottom,0px)+74px+var(--m-stage-lift,0px))] [--bottom-nav-h:var(--m-map-floor)]"
|
||||
className="absolute inset-0 isolate overflow-hidden bg-[color:var(--m-mapb)] [--m-map-floor:calc(env(safe-area-inset-bottom,0px)+74px+var(--m-stage-lift,0px))] wide:[--m-map-floor:calc(env(safe-area-inset-bottom,0px)+8px+var(--m-stage-lift,0px))] [--bottom-nav-h:var(--m-map-floor)]"
|
||||
// A stage bar used to stand over the dock for the whole of the road trip tab, and the
|
||||
// floor cleared its 61px plus a gap the year round. It is gone, so the only thing
|
||||
// left in that slot is the bar the picker raises while other ways of driving a leg
|
||||
|
||||
@@ -281,7 +281,7 @@ function NoteCardRow({ note, color, canEdit, onTap, onTogglePin, onDelete, t }:
|
||||
const websiteHref = safeExternalHref(note.website)
|
||||
|
||||
return (
|
||||
<div className="mt-2 overflow-hidden rounded-2xl border border-[color:var(--m-rowbr)] bg-[color:var(--m-ic)] wide:mb-3 wide:mt-0 wide:break-inside-avoid">
|
||||
<div className="mt-2 overflow-hidden rounded-2xl border border-[color:var(--m-rowbr)] bg-[color:var(--m-ic)] wide:mb-3 wide:mt-0 wide:inline-block wide:w-full wide:break-inside-avoid wide:align-top">
|
||||
<div className="flex items-center gap-[7px] px-3 py-[10px]" style={{ background: `${color}0d` }}>
|
||||
{!!note.pinned && <Pin size={11} strokeWidth={2.4} style={{ color }} className="flex-none" />}
|
||||
<button type="button" onClick={onTap} className="flex min-w-0 flex-1 items-center gap-[7px] text-start">
|
||||
|
||||
@@ -480,7 +480,7 @@ function PackingCategoryCard({
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="mt-[10px] overflow-hidden rounded-2xl border border-[color:var(--m-rowbr)] bg-m-sheetop wide:mb-[10px] wide:mt-0 wide:break-inside-avoid">
|
||||
<div className="mt-[10px] overflow-hidden rounded-2xl border border-[color:var(--m-rowbr)] bg-m-sheetop wide:mb-[10px] wide:mt-0 wide:inline-block wide:w-full wide:break-inside-avoid wide:align-top">
|
||||
{/* A <div role="button"> rather than a real <button type="button"> — the rename input and
|
||||
the assign/menu triggers below are interactive elements a <button type="button"> may
|
||||
not contain (invalid HTML); this stays keyboard-operable via onKeyDown. */}
|
||||
|
||||
@@ -44,14 +44,16 @@ const PANE_INSETS = 'pb-[calc(var(--bottom-nav-h,84px)+22px)] pt-[calc(var(--m-s
|
||||
* columns, each keeping its own height, so the columns start level and no
|
||||
* short card ends above its neighbour in a ragged row or stretches into an
|
||||
* empty panel. In date order that reads down the first column, then the next.
|
||||
* The cards' own top margin gives way to an even gap under each card, so the
|
||||
* columns start on one line in every engine.
|
||||
* The cards' own top margin gives way to an even gap under each card. Each
|
||||
* card is an inline block, so that gap travels with it: as a plain block's
|
||||
* bottom margin it was carried over a column break by WebKit and pushed the
|
||||
* next column's first card down by the gap (seen on iPad).
|
||||
*/
|
||||
export function CardGrid({ children }: { children: ReactNode }) {
|
||||
// 380px a column: one column until the page has room for two cards that keep
|
||||
// their titles and time ranges whole (an 11" iPad upright stays at one).
|
||||
return (
|
||||
<div className="wide:columns-[380px] wide:gap-x-3 wide:pt-2 wide:[&>*]:mb-3 wide:[&>*]:mt-0 wide:[&>*]:break-inside-avoid">
|
||||
<div className="wide:columns-[380px] wide:gap-x-3 wide:pt-2 wide:[&>*]:mb-3 wide:[&>*]:mt-0 wide:[&>*]:inline-block wide:[&>*]:w-full wide:[&>*]:break-inside-avoid wide:[&>*]:align-top">
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -72,7 +72,7 @@ export function JourneyDetailPageDesktop({ journeyId, embedded = false }: Journe
|
||||
recordings, canTakeOverRecording, recordingNeedsConnection, dayImport, recordingPrep,
|
||||
feedEdge, scrollFeedTo,
|
||||
loadJourney, updateEntry, deleteEntry, reorderEntries, uploadPhotos, deletePhoto,
|
||||
addPickedProviderPhotos, addEntryProviderPhotos,
|
||||
addPickedProviderPhotos, addEntryProviderPhotos, writeAboutPlace,
|
||||
} = useJourneyDetail({ journeyId, embedded })
|
||||
// Inside a trip the trip draws the bar and owns the height; the journal fills
|
||||
// the box it is given and starts at its top.
|
||||
@@ -191,6 +191,7 @@ export function JourneyDetailPageDesktop({ journeyId, embedded = false }: Journe
|
||||
tracks={tracks}
|
||||
layers={mapLayers}
|
||||
entryTitleOf={entryTitleOf}
|
||||
onWriteAboutPlace={writeAboutPlace}
|
||||
photos={mapPhotos}
|
||||
onPhotoClick={openMapPhotos}
|
||||
dark={document.documentElement.classList.contains('dark')}
|
||||
@@ -721,6 +722,7 @@ export function JourneyDetailPageDesktop({ journeyId, embedded = false }: Journe
|
||||
ref={mapRef}
|
||||
layers={mapLayers}
|
||||
onOpenEntry={handleMarkerClick}
|
||||
onWriteAboutPlace={writeAboutPlace}
|
||||
entryTitleOf={entryTitleOf}
|
||||
checkins={[]}
|
||||
entries={sidebarMapItems as any}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { afterAll, beforeAll, describe, expect, it, vi } from 'vitest';
|
||||
import { PROVIDER_SELECT_ALL_MAX_PAGES } from '@trek/shared';
|
||||
import {
|
||||
createDraftJourneyEntry,
|
||||
entryForPlace,
|
||||
distanceBetweenGeoPoints,
|
||||
fetchRemainingProviderPages,
|
||||
groupPhotosByDate,
|
||||
@@ -185,6 +186,35 @@ describe('createDraftJourneyEntry', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('entryForPlace', () => {
|
||||
const place = { place_id: 4, name: 'Piazza San Marco', lat: 45.434, lng: 12.3388, days: ['2026-05-14', '2026-05-15'], time: '10:00' };
|
||||
|
||||
it('a planned place starts a new entry on its first day, at its time and spot, named after it', () => {
|
||||
const entry = entryForPlace({ id: 7, entries: [] }, place, new Date('2026-06-01T08:00:00'));
|
||||
expect(entry).toMatchObject({
|
||||
id: 0,
|
||||
journey_id: 7,
|
||||
entry_date: '2026-05-14',
|
||||
entry_time: '10:00',
|
||||
title: 'Piazza San Marco',
|
||||
location_name: 'Piazza San Marco',
|
||||
location_lat: 45.434,
|
||||
location_lng: 12.3388,
|
||||
});
|
||||
});
|
||||
|
||||
it('writes up the suggestion the trip left for the place, so the entry stays linked to it', () => {
|
||||
const suggestion = { ...createDraftJourneyEntry(7), id: 31, type: 'skeleton' as const, source_place_id: 4 };
|
||||
const other = { ...createDraftJourneyEntry(7), id: 32, type: 'skeleton' as const, source_place_id: 5 };
|
||||
expect(entryForPlace({ id: 7, entries: [other, suggestion] }, place)).toBe(suggestion);
|
||||
});
|
||||
|
||||
it('a place without a planned time takes the time of now', () => {
|
||||
const entry = entryForPlace({ id: 7 }, { ...place, time: null }, new Date('2026-06-01T08:05:00'));
|
||||
expect(entry.entry_time).toBe('08:05');
|
||||
});
|
||||
});
|
||||
|
||||
describe('matchJourneyEntries', () => {
|
||||
const entries = [
|
||||
{ id: 1, title: 'Mercado da Ribeira', story: 'Ate too much', location_name: 'Lisbon', tags: ['food'] },
|
||||
|
||||
@@ -48,6 +48,32 @@ export function createDraftJourneyEntry(journeyId: number, now = new Date(), onD
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* The entry to write about a planned place picked on the journey map: the
|
||||
* suggestion the trip left for it, when the journal still has one (writing it
|
||||
* up keeps its link to the place), else a new entry on the place's first day,
|
||||
* at its time and spot, named after it.
|
||||
*/
|
||||
export function entryForPlace(
|
||||
journey: { id: number; entries?: JourneyEntry[] },
|
||||
place: { place_id: number; name: string; lat: number; lng: number; days: string[]; time: string | null },
|
||||
now = new Date()
|
||||
): JourneyEntry {
|
||||
const suggestion = (journey.entries ?? []).find(
|
||||
(entry) => entry.type === 'skeleton' && entry.source_place_id === place.place_id
|
||||
);
|
||||
if (suggestion) return suggestion;
|
||||
const draft = createDraftJourneyEntry(journey.id, now, place.days[0]);
|
||||
return {
|
||||
...draft,
|
||||
entry_time: place.time ?? draft.entry_time,
|
||||
title: place.name,
|
||||
location_name: place.name,
|
||||
location_lat: place.lat,
|
||||
location_lng: place.lng,
|
||||
};
|
||||
}
|
||||
|
||||
export function formatDate(d: string, locale?: string): { weekday: string; month: string; day: number } {
|
||||
const date = new Date(d + 'T00:00:00');
|
||||
// Pass the app's selected locale so weekday/month follow the UI language
|
||||
|
||||
@@ -13,10 +13,10 @@ import { lockBodyScroll } from '../../utils/bodyScrollLock'
|
||||
import { localIsoDate } from '../../utils/localDate'
|
||||
import { journeyOpenAtEntryId } from '../../components/Journey/journeyOpenAt'
|
||||
import type { JourneyEntry } from '../../store/journeyStore'
|
||||
import { createDraftJourneyEntry, photoUrl } from './JourneyDetailPage.helpers'
|
||||
import { createDraftJourneyEntry, entryForPlace, photoUrl } from './JourneyDetailPage.helpers'
|
||||
import { useDawarichSuggestions } from '../../hooks/useDawarichSuggestions'
|
||||
import { openStaysByDate } from '../../components/Dawarich/dawarichSuggestionModel'
|
||||
import type { DawarichSuggestion, DawarichSuggestionTarget } from '@trek/shared'
|
||||
import type { DawarichSuggestion, DawarichSuggestionTarget, JourneyMapPlace } from '@trek/shared'
|
||||
|
||||
import { useDawarichJournalTrail } from '../../hooks/useDawarichJournalTrail'
|
||||
import { useJourneyDetailLayers } from './useJourneyDetailLayers'
|
||||
@@ -595,5 +595,8 @@ export function useJourneyDetail({ journeyId, embedded = false }: JourneyDetailO
|
||||
loadJourney, updateEntry, deleteEntry, reorderEntries, uploadPhotos, deletePhoto,
|
||||
addPickedProviderPhotos: providerPhotos.addPickedPhotos,
|
||||
addEntryProviderPhotos: providerPhotos.addEntryPhotos,
|
||||
// A planned place picked on the map that nothing was written about yet: write it up.
|
||||
writeAboutPlace:
|
||||
canEditEntries && current ? (place: JourneyMapPlace) => setEditingEntry(entryForPlace(current, place)) : undefined,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,6 +195,8 @@ describe('list tabs on a wide window', () => {
|
||||
// No card splits across two columns, and none keeps a top margin that
|
||||
// would start its column lower than the next.
|
||||
expect(grid.className).toContain('wide:[&>*]:break-inside-avoid');
|
||||
// An inline block keeps its gap with it, so no column starts lower than the first (iPad).
|
||||
expect(grid.className).toContain('wide:[&>*]:inline-block');
|
||||
expect(grid.className).toContain('wide:[&>*]:mt-0');
|
||||
expect(grid.className).not.toContain('wide:grid');
|
||||
});
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { act, fireEvent, renderHook } from '@testing-library/react';
|
||||
import { act, renderHook } from '@testing-library/react';
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||
import { openingView } from '../../../src/components/Map/openingView';
|
||||
import MChipStrip from '../../../src/mobile/components/MChipStrip';
|
||||
import { edgeFadeClass, useEdgeFade } from '../../../src/mobile/components/useEdgeFade';
|
||||
import { DayRailSteps, GlassSegment, HeaderActions } from '../../../src/mobile/screens/trip/MTripShellParts';
|
||||
import { GlassSegment, HeaderActions } from '../../../src/mobile/screens/trip/MTripShellParts';
|
||||
import { FilePreviewPane, FileTile } from '../../../src/mobile/screens/trip/tabs/MFilesBoard';
|
||||
import type { TripFile } from '../../../src/types';
|
||||
import { buildPlanner } from '../../helpers/mobileTrip';
|
||||
@@ -149,62 +149,6 @@ describe('the top controls of a trip', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('the day strip on a wide window', () => {
|
||||
/** A strip 400px wide at x 100, with five 120px days laid out in reading order. */
|
||||
function rail(rtl = false, scrolled = 0) {
|
||||
const el = document.createElement('div');
|
||||
if (rtl) el.style.direction = 'rtl';
|
||||
el.getBoundingClientRect = () => ({ left: 100, right: 500, top: 0, bottom: 40, width: 400, height: 40 }) as DOMRect;
|
||||
const chips = Array.from({ length: 5 }, (_, i) => {
|
||||
const chip = document.createElement('button');
|
||||
chip.textContent = `Day ${i + 1}`;
|
||||
const from = rtl ? 500 - (i + 1) * 120 + scrolled : 100 + i * 120 - scrolled;
|
||||
chip.getBoundingClientRect = () =>
|
||||
({ left: from, right: from + 120, top: 0, bottom: 40, width: 120, height: 40 }) as DOMRect;
|
||||
chip.scrollIntoView = vi.fn();
|
||||
el.appendChild(chip);
|
||||
return chip;
|
||||
});
|
||||
document.body.appendChild(el);
|
||||
return { el, chips };
|
||||
}
|
||||
|
||||
afterEach(() => {
|
||||
document.body.innerHTML = '';
|
||||
});
|
||||
|
||||
it('FE-MOB-LSTRIP-008: a chevron over the faded end brings the day the edge cuts to the start, for the eye and the finger only', () => {
|
||||
setSizeClass('wide');
|
||||
const { el, chips } = rail();
|
||||
const { container } = render(<DayRailSteps rail={el} fade={{ start: false, end: true }} />);
|
||||
const steps = container.querySelectorAll('button');
|
||||
expect(steps).toHaveLength(1);
|
||||
expect(steps[0]).toHaveAttribute('aria-hidden', 'true');
|
||||
expect(steps[0]).toHaveAttribute('tabindex', '-1');
|
||||
fireEvent.click(steps[0]);
|
||||
// Day 4 runs from 460 to 580, past the end at 500.
|
||||
expect(chips[3].scrollIntoView).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ inline: 'start', block: 'nearest' })
|
||||
);
|
||||
expect(chips[4].scrollIntoView).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('FE-MOB-LSTRIP-009: back towards the start, in reading order in a right-to-left strip; a phone keeps the fade alone', () => {
|
||||
setSizeClass('wide');
|
||||
// Scrolled by 200 towards the end: in a right-to-left strip days 1 and 2 lie past the right edge.
|
||||
const { el, chips } = rail(true, 200);
|
||||
const { container, unmount } = render(<DayRailSteps rail={el} fade={{ start: true, end: false }} />);
|
||||
fireEvent.click(container.querySelector('button') as HTMLButtonElement);
|
||||
expect(chips[1].scrollIntoView).toHaveBeenCalledWith(expect.objectContaining({ inline: 'end', block: 'nearest' }));
|
||||
expect(chips[0].scrollIntoView).not.toHaveBeenCalled();
|
||||
unmount();
|
||||
|
||||
setSizeClass('compact');
|
||||
const phone = render(<DayRailSteps rail={el} fade={{ start: true, end: true }} />);
|
||||
expect(phone.container.querySelector('button')).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('the files board', () => {
|
||||
const pdf = {
|
||||
id: 5,
|
||||
|
||||
@@ -11,6 +11,7 @@ import { ToastContainer } from '../../../../src/components/shared/Toast';
|
||||
import { DEFAULT_APPEARANCE, type AppearanceConfig } from '@trek/shared';
|
||||
import type { Settings } from '../../../../src/types';
|
||||
import MSettingsAppearance from '../../../../src/mobile/screens/settings/MSettingsAppearance';
|
||||
import { setSizeClass } from '../../../helpers/sizeClass';
|
||||
|
||||
type UpdateSettingMock = ReturnType<typeof vi.fn>;
|
||||
|
||||
@@ -415,4 +416,13 @@ describe('MSettingsAppearance', () => {
|
||||
unmount();
|
||||
expect(appearanceCalls(updateSetting)).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('FE-MOB-SETAPP-029: a tablet, with its rail on the side, has no bottom navbar to set, only the dashboard order', () => {
|
||||
seedAppearance(undefined);
|
||||
setSizeClass('wide');
|
||||
renderAppearance();
|
||||
expect(screen.queryByText('Bottom navbar')).not.toBeInTheDocument();
|
||||
expect(screen.queryByLabelText('Move under “More”')).not.toBeInTheDocument();
|
||||
expect(screen.getAllByText('Dashboard order').length).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -212,6 +212,8 @@ describe('MMapArea', () => {
|
||||
// The floor is the dock's top edge: 62px tall at safe-bottom + 12, raised by the stage lift.
|
||||
expect(layer.className)
|
||||
.toContain('[--m-map-floor:calc(env(safe-area-inset-bottom,0px)+74px+var(--m-stage-lift,0px))]')
|
||||
// No dock on a wide window: the controls sit down at the safe area.
|
||||
expect(layer.className).toContain('wide:[--m-map-floor:calc(env(safe-area-inset-bottom,0px)+8px+var(--m-stage-lift,0px))]')
|
||||
// The band sits on that floor and the controls add their own 12 on top. It used to float
|
||||
// a further 38px up to leave the corner under it to the credit; the phone map shows none,
|
||||
// so that row would only be a gap over the dock.
|
||||
|
||||
@@ -999,6 +999,7 @@ describe('MPackingListTab', () => {
|
||||
await setup()
|
||||
const card = screen.getAllByRole('button', { expanded: true })[0].parentElement as HTMLElement
|
||||
expect(card.className).toContain('wide:break-inside-avoid')
|
||||
expect(card.className).toContain('wide:inline-block')
|
||||
expect((card.parentElement as HTMLElement).className).toContain('wide:columns-[300px]')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user