mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-21 19:40:34 +00:00
feat(mobile): one glass language across the day plan's controls
- The rename and reorder controls beside the day's name, and the day and weather chips on the timeline card, are now round or pill glass controls of one height, so they read as tappable; the stay chips follow. - A leg between two stops is one pill, as on the desktop: the mode, the time in full weight and the distance beside it, larger and without a dot. - The timeline flows under the up-next card at a fixed 12px, whatever its height, instead of an offset that left a gap when the stop has no address. - The places bar on the map wears the day rail's glass at its 36px height. - A context menu stays inside all four edges of the screen, measured at its real size rather than mid-animation, and scrolls when taller than it.
This commit is contained in:
@@ -146,6 +146,17 @@ describe('PoiCategoryPill', () => {
|
||||
}
|
||||
})
|
||||
|
||||
it('FE-COMP-POIPILL-013b: in the phone chrome the bar wears the day rail glass at its 36px height', () => {
|
||||
pill({ categories: WITH_PLUGINS, fullWidth: true, phoneChrome: true })
|
||||
for (const button of screen.getAllByRole('button')) {
|
||||
expect(button.style.minWidth).toBe('34px')
|
||||
expect(button.style.height).toBe('28px')
|
||||
}
|
||||
const bar = screen.getAllByRole('button')[0].closest('[style*="overflow"]') as HTMLElement
|
||||
expect(bar.style.padding).toBe('3px')
|
||||
expect(bar.style.background).toBe('var(--m-glass)')
|
||||
})
|
||||
|
||||
it('FE-COMP-POIPILL-014: a desktop segment keeps its 34px instead of shrinking in a narrow corridor', () => {
|
||||
pill({ categories: WITH_PLUGINS })
|
||||
for (const button of screen.getAllByRole('button')) {
|
||||
|
||||
@@ -18,10 +18,23 @@ interface Props {
|
||||
* The phone map gives it the full width between the screen margins; on
|
||||
* desktop it floats, so it stays content-width there. */
|
||||
fullWidth?: boolean
|
||||
/** The phone shell's chrome: the glass, hairline and 36px height of the day rail
|
||||
* and the tab switch above it, so the three bars read as one set. */
|
||||
phoneChrome?: boolean
|
||||
}
|
||||
|
||||
// The touch target every segment keeps, however many categories there are.
|
||||
const SEGMENT = 34
|
||||
// On the phone the segment is as tall as a day chip; it keeps its width.
|
||||
const PHONE_SEGMENT_HEIGHT = 28
|
||||
|
||||
/** The phone shell's glass, as the day rail draws it (bg/border --m-glass/--m-gbr). */
|
||||
const PHONE_GLASS: React.CSSProperties = {
|
||||
background: 'var(--m-glass)',
|
||||
border: '1px solid var(--m-gbr)',
|
||||
backdropFilter: 'blur(24px) saturate(170%)',
|
||||
WebkitBackdropFilter: 'blur(24px) saturate(170%)',
|
||||
}
|
||||
|
||||
// How far one wheel step moves the bar. Firefox counts a mouse wheel in lines and
|
||||
// some drivers in pages; a line moves about one segment, a page one bar width.
|
||||
@@ -50,10 +63,11 @@ interface SegmentProps {
|
||||
loading: boolean
|
||||
failed: boolean
|
||||
fullWidth?: boolean
|
||||
phoneChrome?: boolean
|
||||
onToggle: (key: string) => void
|
||||
}
|
||||
|
||||
function Segment({ cat, on, loading, failed, fullWidth, onToggle }: Readonly<SegmentProps>) {
|
||||
function Segment({ cat, on, loading, failed, fullWidth, phoneChrome, onToggle }: Readonly<SegmentProps>) {
|
||||
return (
|
||||
<Tooltip label={cat.label} placement="bottom">
|
||||
<button
|
||||
@@ -71,7 +85,7 @@ function Segment({ cat, on, loading, failed, fullWidth, onToggle }: Readonly<Seg
|
||||
flexShrink: fullWidth ? 1 : 0,
|
||||
flexBasis: fullWidth ? 0 : undefined,
|
||||
minWidth: SEGMENT,
|
||||
width: fullWidth ? 'auto' : SEGMENT, height: SEGMENT, borderRadius: 999, border: 'none', cursor: 'pointer',
|
||||
width: fullWidth ? 'auto' : SEGMENT, height: phoneChrome ? PHONE_SEGMENT_HEIGHT : SEGMENT, borderRadius: 999, border: 'none', cursor: 'pointer',
|
||||
background: on ? cat.color : 'transparent',
|
||||
color: on ? '#fff' : undefined,
|
||||
transition: 'background 0.14s, color 0.14s',
|
||||
@@ -108,11 +122,11 @@ function Segment({ cat, on, loading, failed, fullWidth, onToggle }: Readonly<Seg
|
||||
// and whatever plugins add follows a thin divider (#1781); once that is more than the
|
||||
// width holds, the bar scrolls sideways (by swipe, trackpad or mouse wheel) rather than
|
||||
// shrinking a segment below the touch target.
|
||||
export default function PoiCategoryPill({ categories, active, onToggle, loadingKeys, errorKeys, moved, onSearchArea, fullWidth }: Readonly<Props>) {
|
||||
export default function PoiCategoryPill({ categories, active, onToggle, loadingKeys, errorKeys, moved, onSearchArea, fullWidth, phoneChrome }: Readonly<Props>) {
|
||||
const { t } = useTranslation()
|
||||
const anyError = !!errorKeys && Array.from(active).some(k => errorKeys.has(k))
|
||||
|
||||
const frosted: React.CSSProperties = {
|
||||
const frosted: React.CSSProperties = phoneChrome ? PHONE_GLASS : {
|
||||
background: 'var(--sidebar-bg)',
|
||||
backdropFilter: 'blur(20px) saturate(180%)',
|
||||
WebkitBackdropFilter: 'blur(20px) saturate(180%)',
|
||||
@@ -132,6 +146,7 @@ export default function PoiCategoryPill({ categories, active, onToggle, loadingK
|
||||
loading={loading}
|
||||
failed={!!errorKeys?.has(cat.key)}
|
||||
fullWidth={fullWidth}
|
||||
phoneChrome={phoneChrome}
|
||||
onToggle={onToggle}
|
||||
/>
|
||||
)
|
||||
@@ -142,7 +157,7 @@ export default function PoiCategoryPill({ categories, active, onToggle, loadingK
|
||||
<div onWheel={wheelSideways} style={{
|
||||
display: fullWidth ? 'flex' : 'inline-flex',
|
||||
alignSelf: fullWidth ? 'stretch' : undefined,
|
||||
alignItems: 'center', gap: 2, padding: 4, borderRadius: 999, pointerEvents: 'auto', ...frosted,
|
||||
alignItems: 'center', gap: 2, padding: phoneChrome ? 3 : 4, borderRadius: 999, pointerEvents: 'auto', ...frosted,
|
||||
maxWidth: '100%', overflowX: 'auto', scrollbarWidth: 'none',
|
||||
}}>
|
||||
{categories.core.map(segment)}
|
||||
|
||||
@@ -101,12 +101,15 @@ describe('ContextMenu', () => {
|
||||
expect(onClose).toHaveBeenCalledTimes(2)
|
||||
})
|
||||
|
||||
it('FE-W4CTX-010: flips the menu back inside the viewport when it would overflow', () => {
|
||||
vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockReturnValue({
|
||||
width: 200, height: 120, top: 0, left: 0, right: 0, bottom: 0, x: 0, y: 0, toJSON: () => ({}),
|
||||
} as DOMRect)
|
||||
function layoutSize(width: number, height: number) {
|
||||
vi.spyOn(HTMLElement.prototype, 'offsetWidth', 'get').mockReturnValue(width)
|
||||
vi.spyOn(HTMLElement.prototype, 'offsetHeight', 'get').mockReturnValue(height)
|
||||
Object.defineProperty(window, 'innerWidth', { writable: true, configurable: true, value: 400 })
|
||||
Object.defineProperty(window, 'innerHeight', { writable: true, configurable: true, value: 300 })
|
||||
}
|
||||
|
||||
it('FE-W4CTX-010: flips the menu back inside the viewport when it would overflow', () => {
|
||||
layoutSize(200, 120)
|
||||
|
||||
const { baseElement } = render(<ContextMenu menu={{ x: 380, y: 290, items: [{ label: 'Open' }] }} onClose={() => {}} />)
|
||||
|
||||
@@ -115,6 +118,18 @@ describe('ContextMenu', () => {
|
||||
expect(menu.style.top).toBe('172px')
|
||||
})
|
||||
|
||||
it('FE-W4CTX-010b: keeps an end-aligned menu off the left edge, and caps one taller than the screen', () => {
|
||||
layoutSize(200, 500)
|
||||
|
||||
const { baseElement } = render(<ContextMenu menu={{ x: 40, y: 20, alignEnd: true, items: [{ label: 'Open' }] }} onClose={() => {}} />)
|
||||
|
||||
const menu = baseElement.querySelector('.trek-popover-enter') as HTMLElement
|
||||
expect(menu.style.left).toBe('8px')
|
||||
expect(menu.style.top).toBe('8px')
|
||||
expect(menu.style.maxHeight).toBe('284px')
|
||||
expect(menu.style.overflowY).toBe('auto')
|
||||
})
|
||||
|
||||
it('FE-W4CTX-011: Escape, a scroll and a resize close it', () => {
|
||||
const onClose = vi.fn()
|
||||
render(<ContextMenu menu={{ x: 0, y: 0, items: [{ label: 'Open' }] }} onClose={onClose} />)
|
||||
|
||||
@@ -97,14 +97,26 @@ export function ContextMenu({ menu, onClose }: ContextMenuProps) {
|
||||
useLayoutEffect(() => {
|
||||
if (!menu || !ref.current) return
|
||||
const el = ref.current
|
||||
const rect = el.getBoundingClientRect()
|
||||
// The layout size, not getBoundingClientRect: the menu is still mid enter
|
||||
// animation (scaled down) here, and the smaller box let a menu opened near an
|
||||
// edge end up partly off screen.
|
||||
const width = el.offsetWidth
|
||||
const viewW = window.innerWidth
|
||||
const viewH = window.innerHeight
|
||||
// Taller than the screen (a long list on a phone): cap it and let it scroll.
|
||||
if (el.offsetHeight > viewH - 16) {
|
||||
el.style.maxHeight = `${viewH - 16}px`
|
||||
el.style.overflowY = 'auto'
|
||||
}
|
||||
const height = Math.min(el.offsetHeight, viewH - 16)
|
||||
let { x, y } = menu
|
||||
if (menu.alignEnd) x = Math.max(8, x - rect.width)
|
||||
if (x + rect.width > window.innerWidth - 8) x = window.innerWidth - rect.width - 8
|
||||
if (y + rect.height > window.innerHeight - 8) y = window.innerHeight - rect.height - 8
|
||||
if (menu.alignEnd) x = x - width
|
||||
// Kept inside all four edges with 8px to spare.
|
||||
x = Math.min(Math.max(8, x), viewW - width - 8)
|
||||
y = Math.min(Math.max(8, y), viewH - height - 8)
|
||||
if (x !== menu.x || y !== menu.y) {
|
||||
el.style.left = `${x}px`
|
||||
el.style.top = `${y}px`
|
||||
el.style.left = `${Math.max(8, x)}px`
|
||||
el.style.top = `${Math.max(8, y)}px`
|
||||
}
|
||||
}, [menu])
|
||||
|
||||
|
||||
@@ -441,6 +441,7 @@ export default function MMapArea({ planner, shell }: MMapAreaProps) {
|
||||
<div className="pointer-events-none absolute inset-x-4 z-[25] flex flex-col items-center gap-2 top-[calc(var(--m-safe-top,12px)+96px)]">
|
||||
<PoiCategoryPill
|
||||
fullWidth
|
||||
phoneChrome
|
||||
categories={poi.categories}
|
||||
active={poi.active}
|
||||
onToggle={poi.toggle}
|
||||
|
||||
@@ -34,6 +34,10 @@ import MDayPager from '../../../components/MDayPager'
|
||||
*/
|
||||
|
||||
const GLASS_PILL = 'rounded-full border border-[color:var(--m-gbr)] bg-[color:var(--m-glass)]'
|
||||
/** A tappable pill in the same glass, 28px tall like GLASS_ROUND, for a label. */
|
||||
const GLASS_CHIP = `relative flex h-7 flex-none items-center whitespace-nowrap font-geist text-[0.6875rem] font-semibold text-m-ink transition-transform active:scale-95 ${GLASS_PILL}`
|
||||
/** A round control the size of a GLASS_PILL row, with a 44px hit area around it. */
|
||||
const GLASS_ROUND = `relative flex h-7 w-7 flex-none items-center justify-center text-m-muted transition-transform active:scale-95 before:absolute before:-inset-2 before:content-[''] ${GLASS_PILL}`
|
||||
|
||||
export default function MPlanTimeline({ planner, shell }: MPlanTimelineProps) {
|
||||
const { t, trip, can } = planner
|
||||
@@ -178,17 +182,18 @@ function PlanDayPage({ planner, shell, dayId: pageDayId, active, editing, legMen
|
||||
const chrome = { editing, t, language: tl.language, timeFormat: tl.timeFormat }
|
||||
|
||||
return (
|
||||
<div className="absolute inset-0">
|
||||
// One column under the day chips: the UP-NEXT card (go mode) or the edit
|
||||
// header, then the timeline card filling the rest, 12px apart whatever height
|
||||
// the card above it has. A day without an up-next starts the timeline right
|
||||
// under the chips.
|
||||
<div className="absolute inset-x-4 flex flex-col gap-3 top-[calc(var(--m-safe-top,12px)+102px)] bottom-[calc(env(safe-area-inset-bottom,0px)+90px)]">
|
||||
{!editing && <UpNextCard tl={tl} t={t} onOpen={openPlace} />}
|
||||
{editing && <EditHeader tl={tl} planner={planner} shell={shell} />}
|
||||
|
||||
{/* Timeline card — go mode leaves room for the UP-NEXT card above, but
|
||||
collapses that reserved space up to the day chips when the day has no
|
||||
up-next (no places), so an empty day shows no gap. */}
|
||||
<div
|
||||
data-touch-drag={editing && active ? '' : undefined}
|
||||
className="absolute inset-x-4 overflow-x-hidden overflow-y-auto overscroll-y-contain rounded-[22px] border border-[color:var(--m-cbr)] bg-[color:var(--m-card)] px-3.5 pb-2 pt-1 backdrop-blur-[24px] backdrop-saturate-[1.6] bottom-[calc(env(safe-area-inset-bottom,0px)+90px)]"
|
||||
style={{ top: `calc(var(--m-safe-top, 12px) + ${editing ? 140 : tl.upNext ? 216 : 102}px)` }}
|
||||
data-timeline-card=""
|
||||
className="min-h-0 flex-1 overflow-x-hidden overflow-y-auto overscroll-y-contain rounded-[22px] border border-[color:var(--m-cbr)] bg-[color:var(--m-card)] px-3.5 pb-2 pt-1 backdrop-blur-[24px] backdrop-saturate-[1.6]"
|
||||
>
|
||||
{planner.toursEnabled && tl.rows.some(row => row.kind === 'place' && row.invalidTour) && (
|
||||
<div role="status" className="border-b border-[color:var(--warning)] p-2 text-sm text-[color:var(--warning)]">
|
||||
@@ -342,7 +347,7 @@ function UpNextCard({ tl, t, onOpen }: {
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => onOpen(upNext.assignment)}
|
||||
className="absolute inset-x-4 cursor-pointer rounded-[22px] border border-[color:var(--m-inbr)] bg-[color:var(--m-inner)] px-4 py-3.5 text-start shadow-[0_18px_44px_-18px_rgba(0,0,0,.3)] backdrop-blur-[28px] backdrop-saturate-[1.8] top-[calc(var(--m-safe-top,12px)+102px)]"
|
||||
className="flex-none cursor-pointer rounded-[22px] border border-[color:var(--m-inbr)] bg-[color:var(--m-inner)] px-4 py-3.5 text-start shadow-[0_18px_44px_-18px_rgba(0,0,0,.3)] backdrop-blur-[28px] backdrop-saturate-[1.8]"
|
||||
>
|
||||
<div className="flex items-center justify-between">
|
||||
<span className="whitespace-nowrap font-geist text-[0.65625rem] font-bold uppercase tracking-[.08em] text-m-muted">
|
||||
@@ -391,7 +396,7 @@ function EditHeader({ tl, planner, shell }: {
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="absolute inset-x-4 flex items-center gap-2 top-[calc(var(--m-safe-top,12px)+102px)]">
|
||||
<div className="flex flex-none items-center gap-2">
|
||||
{renaming ? (
|
||||
<input
|
||||
autoFocus
|
||||
@@ -421,17 +426,17 @@ function EditHeader({ tl, planner, shell }: {
|
||||
type="button"
|
||||
aria-label={t('mobileTrip.renameDay')}
|
||||
onClick={() => { setDraft(tl.day?.title ?? ''); setRenaming(true) }}
|
||||
className="flex-none text-m-faint"
|
||||
className={GLASS_ROUND}
|
||||
>
|
||||
<Pencil size={14} strokeWidth={2} />
|
||||
<Pencil size={13} strokeWidth={2.2} />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
aria-label={t('dayplan.reorderDays')}
|
||||
onClick={() => shell.openSheet('days')}
|
||||
className="flex-none text-m-faint"
|
||||
className={GLASS_ROUND}
|
||||
>
|
||||
<CalendarRange size={14} strokeWidth={2} />
|
||||
<CalendarRange size={13} strokeWidth={2.2} />
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
@@ -476,15 +481,23 @@ function TimelineHeader({ tl, dayLabel, openLabel, weatherLabel, onOpenDay, onOp
|
||||
the browser's: while the chips overflow they pan first, and the pager
|
||||
takes over at their end or when they fit. */}
|
||||
<span className="flex min-w-0 items-center gap-1.5 overflow-x-auto">
|
||||
{/* The same glass controls as the edit header's: a round one when the day
|
||||
is already named above it, a pill with the day's name otherwise. */}
|
||||
<button
|
||||
type="button"
|
||||
onClick={onOpenDay}
|
||||
aria-label={openLabel}
|
||||
className="flex flex-none items-center gap-[5px] whitespace-nowrap rounded-full bg-[color:var(--m-ic)] px-2.5 py-1 font-geist text-[0.6875rem] font-semibold"
|
||||
// No widened hit area here: inside the scrolling chip strip it would add
|
||||
// a few pixels of sideways scroll.
|
||||
className={dayLabel ? `${GLASS_CHIP} gap-[5px] px-2.5` : `${GLASS_CHIP} w-7 justify-center`}
|
||||
>
|
||||
<CalendarDays size={12} strokeWidth={2.2} className="text-m-muted" />
|
||||
{dayLabel}
|
||||
<ChevronRight size={11} strokeWidth={2.4} aria-hidden="true" className="text-m-faint" />
|
||||
<CalendarDays size={13} strokeWidth={2.2} className="text-m-muted" />
|
||||
{dayLabel && (
|
||||
<>
|
||||
{dayLabel}
|
||||
<ChevronRight size={11} strokeWidth={2.4} aria-hidden="true" className="text-m-faint" />
|
||||
</>
|
||||
)}
|
||||
</button>
|
||||
{tl.hotelChips.map(chip => (
|
||||
<button
|
||||
@@ -492,7 +505,7 @@ function TimelineHeader({ tl, dayLabel, openLabel, weatherLabel, onOpenDay, onOp
|
||||
type="button"
|
||||
onClick={() => onOpenStay(chip)}
|
||||
aria-label={stayLabel(chip)}
|
||||
className="flex flex-none items-center gap-[5px] whitespace-nowrap rounded-full bg-[color:var(--m-ic)] px-2.5 py-1 font-geist text-[0.6875rem] font-semibold"
|
||||
className={`${GLASS_CHIP} gap-[5px] px-2.5`}
|
||||
>
|
||||
<HotelChipIcon variant={chip.variant} />
|
||||
{chip.name}
|
||||
@@ -506,7 +519,7 @@ function TimelineHeader({ tl, dayLabel, openLabel, weatherLabel, onOpenDay, onOp
|
||||
onClick={onOpenDay}
|
||||
aria-label={weatherLabel || openLabel}
|
||||
title={tl.weatherPlaceName || undefined}
|
||||
className="ms-auto flex flex-none items-center gap-1 whitespace-nowrap px-1.5 py-1 text-[0.71875rem] font-semibold"
|
||||
className={`${GLASS_CHIP} ms-auto gap-1 px-2.5`}
|
||||
>
|
||||
<WeatherIcon size={13} strokeWidth={2} />
|
||||
{tl.weatherTemp}°
|
||||
|
||||
@@ -468,23 +468,23 @@ function TravelLine({ seg }: { seg: RouteSegment }) {
|
||||
const mode = seg.mode
|
||||
const Icon = routeModeIcon(mode)
|
||||
const durationText = seg.durationText ?? (mode === 'walking' ? seg.walkingText : seg.drivingText)
|
||||
// One pill between two hairlines, as the desktop day plan draws a leg: the mode,
|
||||
// the time in full weight and the distance muted beside it, no dot between them.
|
||||
return (
|
||||
<>
|
||||
<span className="h-px flex-1 bg-[color:var(--m-rowbr)]" />
|
||||
<span className="inline-flex items-center gap-[3px] whitespace-nowrap font-geist text-[0.59375rem] font-semibold text-m-faint">
|
||||
<Icon size={10} strokeWidth={2} />
|
||||
{durationText}
|
||||
<span className="inline-flex items-center gap-[6px] whitespace-nowrap rounded-full border border-[color:var(--m-rowbr)] bg-[color:var(--m-ic)] px-2.5 py-[3px] font-geist text-[0.6875rem] leading-none">
|
||||
<Icon size={12} strokeWidth={2.2} className="flex-none text-m-muted" />
|
||||
<span className="font-semibold text-m-ink">{durationText}</span>
|
||||
{seg.distanceText && <span className="text-m-muted">{seg.distanceText}</span>}
|
||||
{/* Extra text a plugin route attached to this leg (e.g. "25 min charge"). */}
|
||||
{seg.noteText && (
|
||||
<span className="inline-flex items-center gap-[3px] text-m-muted">
|
||||
<Zap size={11} strokeWidth={2} />
|
||||
{seg.noteText}
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
<span className="whitespace-nowrap font-geist text-[0.59375rem] font-semibold text-m-faint">
|
||||
· {seg.distanceText}
|
||||
</span>
|
||||
{/* Extra text a plugin route attached to this leg (e.g. "25 min charge"). */}
|
||||
{seg.noteText && (
|
||||
<span className="inline-flex items-center gap-[3px] whitespace-nowrap font-geist text-[0.59375rem] font-semibold text-m-faint">
|
||||
<Zap size={10} strokeWidth={2} />
|
||||
{seg.noteText}
|
||||
</span>
|
||||
)}
|
||||
<span className="h-px flex-1 bg-[color:var(--m-rowbr)]" />
|
||||
</>
|
||||
)
|
||||
@@ -493,7 +493,7 @@ function TravelLine({ seg }: { seg: RouteSegment }) {
|
||||
export function ConnRow({ seg, onTap }: { seg: RouteSegment; onTap?: (e: MouseEvent) => void }) {
|
||||
// Tap to change the leg's mode (#1281).
|
||||
const inner = <TravelLine seg={seg} />
|
||||
const cls = 'mt-[5px] flex w-full items-center gap-2 py-px text-[color:var(--m-conn)]'
|
||||
const cls = 'mt-[6px] flex w-full items-center gap-2 py-px text-[color:var(--m-conn)] transition-transform active:scale-[.98]'
|
||||
return onTap
|
||||
? <button type="button" onClick={onTap} className={cls}>{inner}</button>
|
||||
: <div className={cls}>{inner}</div>
|
||||
|
||||
@@ -176,14 +176,19 @@ describe('MPlanTimeline', () => {
|
||||
expect(screen.queryByText('Museum Rd 1')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('FE-MOB-PLTL-004: collapses the reserved space when the day has no up next', () => {
|
||||
it('FE-MOB-PLTL-004: the timeline follows the up-next card in one column, and starts at the top without one', () => {
|
||||
const { container, unmount } = renderTimeline()
|
||||
expect(card(container).style.top).toContain('216px')
|
||||
// The card flows under the up-next card at a fixed gap, whatever its height,
|
||||
// rather than at an offset that assumed an address line (a gap without one).
|
||||
const upNext = screen.getByText('mobileTrip.upNext').closest('button') as HTMLElement
|
||||
expect(upNext.nextElementSibling).toBe(card(container))
|
||||
expect(card(container).parentElement).toHaveClass('flex-col', 'gap-3')
|
||||
expect(card(container).style.top).toBe('')
|
||||
unmount()
|
||||
|
||||
const empty = renderTimeline({ upNext: null, rows: [], merged: [] })
|
||||
expect(screen.queryByText('mobileTrip.upNext')).not.toBeInTheDocument()
|
||||
expect(card(empty.container).style.top).toContain('102px')
|
||||
expect(card(empty.container).previousElementSibling).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -532,7 +537,8 @@ describe('MPlanTimeline', () => {
|
||||
const { container } = renderTimeline({}, {}, { mode: 'edit' })
|
||||
|
||||
expect(screen.queryByText('mobileTrip.upNext')).not.toBeInTheDocument()
|
||||
expect(card(container).style.top).toContain('140px')
|
||||
// The edit header takes the up-next card's place, the timeline right under it.
|
||||
expect(card(container).previousElementSibling).toContainElement(screen.getByLabelText('mobileTrip.renameDay'))
|
||||
})
|
||||
|
||||
it('FE-MOB-PLTL-026: splits the day title into city pills', () => {
|
||||
|
||||
@@ -390,7 +390,10 @@ describe('ConnRow', () => {
|
||||
const { container } = render(<ConnRow seg={SEG} />)
|
||||
|
||||
expect(screen.getByText('14 min')).toBeInTheDocument()
|
||||
expect(screen.getByText('· 5.4 km')).toBeInTheDocument()
|
||||
// The distance sits in the same pill as the time, with no dot between them.
|
||||
expect(screen.getByText('5.4 km')).toBeInTheDocument()
|
||||
expect(screen.getByText('14 min').parentElement).toBe(screen.getByText('5.4 km').parentElement)
|
||||
expect(container.textContent).not.toContain('·')
|
||||
expect(container.querySelector('button')).toBeNull()
|
||||
})
|
||||
|
||||
@@ -448,7 +451,7 @@ describe('HotelConnRow', () => {
|
||||
|
||||
expect(top.children[0].textContent).toBe('Hotel Sacher')
|
||||
expect(top.children[1].textContent).toContain('14 min')
|
||||
expect(top.children[1].textContent).toContain('· 5.4 km')
|
||||
expect(top.children[1].textContent).toContain('5.4 km')
|
||||
unmount()
|
||||
|
||||
const bottom = render(<HotelConnRow seg={SEG} name="Hotel Sacher" placement="bottom" />)
|
||||
|
||||
Reference in New Issue
Block a user