mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-22 03:50:30 +00:00
fix(mobile): large screen polish for the dashboard, the trip dock, transports, the stay chip and the journey strip
- Dashboard: crossing the split size keeps every widget in the same parent (the columns dissolve into one ordered stack below it), so the currency converter is not remounted and keeps its amount and rates. - Trip dock: More is marked with the main dock's ring while one of its sections (chat, notes, links, polls, files) is on show or it is open, instead of the filled circle of a tab. - Transport cards: the status button is a flex box, so its dot shows when the card may be edited. - Day header: the stay chip's name keeps its own direction, so a Latin name in an Arabic header is cut at its end. - Journey: a folded Duo on its side (about 540px high) gets the compact cards, so the map keeps its room. - Rail: a test pins settings and administration marking their own entry.
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import React, { useEffect, useRef, useState } from 'react'
|
||||
import { useIsSplit } from '../../../hooks/sizeClass'
|
||||
import {
|
||||
Archive, ArchiveRestore, ArrowRight, Bell, CalendarDays, CalendarPlus, Copy,
|
||||
LayoutGrid, List, MapPin, Pencil, Plus, RefreshCw, Sparkles, Trash2, Users,
|
||||
@@ -60,7 +59,6 @@ export default function MDashboard(): React.ReactElement {
|
||||
const unread = useInAppNotificationStore(s => s.unreadCount)
|
||||
const fetchUnreadCount = useInAppNotificationStore(s => s.fetchUnreadCount)
|
||||
const [menuOpen, setMenuOpen] = useState(false)
|
||||
const split = useIsSplit()
|
||||
const { available: assistantAvailable, open: openAssistant } = useAssistantHomeLauncher()
|
||||
const [subOpen, setSubOpen] = useState(false)
|
||||
// The filter chips scroll when a language's words do not fit beside the two
|
||||
@@ -281,9 +279,12 @@ export default function MDashboard(): React.ReactElement {
|
||||
|
||||
{/* Beside each other from the split size class on, the way the desktop
|
||||
dashboard holds them: the trips in the main column, the widgets in a
|
||||
column of their own, each in the order the user set. */}
|
||||
<div className="split:grid split:grid-cols-[minmax(0,1fr)_minmax(300px,360px)] split:items-start split:gap-6">
|
||||
<div className="min-w-0">
|
||||
column of their own, each in the order the user set. Narrower, both
|
||||
columns dissolve (display: contents) into one stack ordered the same
|
||||
way, so crossing the split size never moves a widget to another
|
||||
parent and its state (the converter's amount, its rates) stays. */}
|
||||
<div className="flex flex-col split:grid split:grid-cols-[minmax(0,1fr)_minmax(300px,360px)] split:items-start split:gap-6">
|
||||
<div className="contents min-w-0 split:block">
|
||||
{spotlight && (
|
||||
<MSpotlightCard
|
||||
trip={spotlight}
|
||||
@@ -292,22 +293,18 @@ export default function MDashboard(): React.ReactElement {
|
||||
actions={actionsFor(spotlight, 'list')}
|
||||
/>
|
||||
)}
|
||||
{(split ? dashOrder.filter(id => id === 'trips') : dashOrder).map(id => (
|
||||
<React.Fragment key={id}>{renderBlock(id)}</React.Fragment>
|
||||
))}
|
||||
<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">
|
||||
{dashOrder.filter(id => id !== 'trips').map(id => (
|
||||
<div key={id} style={{ order: dashOrder.indexOf(id) }}>{renderBlock(id)}</div>
|
||||
))}
|
||||
{widgetPlugins.length > 0 && (
|
||||
<div className="mt-3 flex flex-col gap-3" style={{ order: dashOrder.length }}>
|
||||
<PluginWidgets plugins={widgetPlugins} tripId={spotlight ? String(spotlight.id) : null} />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{(split || widgetPlugins.length > 0) && (
|
||||
<div className="min-w-0 split:sticky split:top-[calc(var(--m-safe-top,12px)+82px)] split:-mt-[14px]">
|
||||
{split && dashOrder.filter(id => id !== 'trips').map(id => (
|
||||
<React.Fragment key={id}>{renderBlock(id)}</React.Fragment>
|
||||
))}
|
||||
{widgetPlugins.length > 0 && (
|
||||
<div className="mt-3 flex flex-col gap-3">
|
||||
<PluginWidgets plugins={widgetPlugins} tripId={spotlight ? String(spotlight.id) : null} />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -42,8 +42,12 @@ import MJourneyRecordingSheet from './MJourneyRecordingSheet'
|
||||
* (`embedded`): the trip's back button and controls sit on top, so the screen
|
||||
* drops its own back button and leaves the trip's URL alone.
|
||||
*/
|
||||
/** A phone on its side: too short for the regular strip of cards and the map above it. */
|
||||
const SHORT_WINDOW = '(max-height: 500px)'
|
||||
/**
|
||||
* A phone on its side, or a folded Duo on its side (about 540px high): too short
|
||||
* for the regular strip of cards and the map above it. Higher than the shell's
|
||||
* 500px for that Duo, whose regular cards left the map a band under the header.
|
||||
*/
|
||||
const SHORT_WINDOW = '(max-height: 600px)'
|
||||
function subscribeShort(onChange: () => void) {
|
||||
const mq = window.matchMedia(SHORT_WINDOW)
|
||||
mq.addEventListener('change', onChange)
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useEffect, useLayoutEffect, useRef, useState, type ComponentType } from
|
||||
import { findFocusDayId, findTodayDayId } from '../../../components/Planner/today'
|
||||
import { takeResumeDay } from '../../../utils/resumeRoute'
|
||||
import {
|
||||
CalendarDays, ChevronDown, ChevronLeft, Download, FileDown, List, Map as MapIcon, MoreHorizontal, PanelLeftClose, PanelLeftOpen, Plane, Route, SlidersHorizontal, Trash2, Upload,
|
||||
CalendarDays, ChevronDown, ChevronLeft, Download, FileDown, List, Map as MapIcon, PanelLeftClose, PanelLeftOpen, Plane, Route, SlidersHorizontal, Trash2, Upload,
|
||||
} from 'lucide-react'
|
||||
import { useTripPlanner } from '../../../pages/tripPlanner/useTripPlanner'
|
||||
import { pickDockTabs } from './dockTabs'
|
||||
@@ -29,7 +29,7 @@ import { useDayPreviewStore } from '../../dayPreviewStore'
|
||||
import { useIsSplit, useIsWide } from '../../../hooks/sizeClass'
|
||||
import MTripRail from './MTripRail'
|
||||
import {
|
||||
CollabSegment, CompactToggle, DayRailSteps, DocSyncButton, GlassSegment, HeaderActions, PrimaryPill, ROW_AFTER_BACK, ROW_CENTRED,
|
||||
CollabSegment, CompactToggle, DayRailSteps, DockMoreButton, DocSyncButton, GlassSegment, HeaderActions, PrimaryPill, ROW_AFTER_BACK, ROW_CENTRED,
|
||||
} from './MTripShellParts'
|
||||
import { edgeFadeClass, useEdgeFade } from '../../components/useEdgeFade'
|
||||
import { useShortcuts } from '../../keyboard/useShortcuts'
|
||||
@@ -927,17 +927,12 @@ export default function MTripShell({
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => openSheet('mehr')}
|
||||
aria-label={t('mobileTrip.more')}
|
||||
aria-expanded={sheet?.id === 'mehr'}
|
||||
className={`flex h-[42px] w-[42px] flex-none items-center justify-center rounded-full ${
|
||||
sheet?.id === 'mehr' ? 'bg-m-act text-m-actfg' : 'text-m-muted'
|
||||
}`}
|
||||
>
|
||||
<MoreHorizontal size={19} strokeWidth={2.2} />
|
||||
</button>
|
||||
<DockMoreButton
|
||||
open={sheet?.id === 'mehr'}
|
||||
standsFor={!dockTabs.some(tab => tab.id === trTab)}
|
||||
onOpen={() => openSheet('mehr')}
|
||||
label={t('mobileTrip.more')}
|
||||
/>
|
||||
</nav>}
|
||||
|
||||
<Sheets planner={planner} shell={shell} />
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ChevronLeft, ChevronRight, FolderSync, List, Plus, Rows3 } from 'lucide-react';
|
||||
import { ChevronLeft, ChevronRight, 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';
|
||||
@@ -284,3 +284,37 @@ export function CompactToggle({ active, onToggle, label }: { active: boolean; on
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The phone dock's More. It stands for its sections (chat, notes, files and the
|
||||
* rest) while one is on show, and for itself while open: marked as a ring, as
|
||||
* the main dock's More is, not filled like a tab it would then read as.
|
||||
*/
|
||||
export function DockMoreButton({
|
||||
open,
|
||||
standsFor,
|
||||
onOpen,
|
||||
label,
|
||||
}: {
|
||||
open: boolean;
|
||||
standsFor: boolean;
|
||||
onOpen: () => void;
|
||||
label: string;
|
||||
}) {
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
onClick={onOpen}
|
||||
aria-label={label}
|
||||
aria-expanded={open}
|
||||
aria-current={!open && standsFor ? 'page' : undefined}
|
||||
className={`flex h-[42px] w-[42px] flex-none items-center justify-center rounded-full ${
|
||||
open || standsFor
|
||||
? 'bg-[color:var(--m-ic)] text-m-ink ring-[1.5px] ring-inset ring-[color:var(--m-act)]'
|
||||
: 'text-m-muted'
|
||||
}`}
|
||||
>
|
||||
<MoreHorizontal size={19} strokeWidth={2.2} />
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -544,7 +544,8 @@ function TimelineHeader({ tl, dayLabel, openLabel, weatherLabel, onOpenDay, onOp
|
||||
className={`${GLASS_CHIP} min-w-[4.5rem] shrink gap-[5px] px-2.5`}
|
||||
>
|
||||
<HotelChipIcon variant={chip.variant} />
|
||||
<span className="min-w-0 truncate">{chip.name}</span>
|
||||
{/* Its own direction, so a Latin name in an Arabic header is cut at its end, not its start. */}
|
||||
<span dir="auto" className="min-w-0 truncate">{chip.name}</span>
|
||||
{chip.time && <span className="flex-none tabular-nums text-m-muted">{chip.time.slice(0, 5)}</span>}
|
||||
</button>
|
||||
))}
|
||||
|
||||
@@ -144,7 +144,7 @@ function TransportCard({ res, planner, shell, canEdit, compact }: {
|
||||
type="button"
|
||||
onClick={toggleStatus}
|
||||
aria-label={confirmed ? t('reservations.pending') : t('reservations.confirmed')}
|
||||
className="-m-1 flex-none p-1"
|
||||
className="-m-1 flex flex-none p-1"
|
||||
>
|
||||
<StatusDot color={dotColor} />
|
||||
</button>
|
||||
|
||||
@@ -71,6 +71,19 @@ describe('MNavRail', () => {
|
||||
expect(within(rail()).getByRole('button', { name: 'Admin' })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('FE-MOB-RAIL-012: settings and administration, and their sub pages, mark their own entry in the rail', () => {
|
||||
useAuthStore.setState({ user: buildUser({ role: 'admin' }) });
|
||||
const { unmount } = render(<MNavRail />, { initialEntries: ['/settings'] });
|
||||
expect(within(rail()).getByRole('button', { name: 'Settings' })).toHaveAttribute('aria-current', 'page');
|
||||
expect(within(rail()).getByRole('button', { name: 'Admin' })).not.toHaveAttribute('aria-current');
|
||||
unmount();
|
||||
|
||||
render(<MNavRail />, { initialEntries: ['/admin/users'] });
|
||||
expect(within(rail()).getByRole('button', { name: 'Admin' })).toHaveAttribute('aria-current', 'page');
|
||||
expect(within(rail()).getByRole('button', { name: 'Settings' })).not.toHaveAttribute('aria-current');
|
||||
expect(within(rail()).getByRole('button', { name: 'My Trips' })).not.toHaveAttribute('aria-current');
|
||||
});
|
||||
|
||||
it("FE-MOB-RAIL-004: the create button keeps the dock's meaning and its exceptions", () => {
|
||||
const { unmount } = render(
|
||||
<>
|
||||
|
||||
@@ -8,6 +8,7 @@ import { useInAppNotificationStore } from '../../../../src/store/inAppNotificati
|
||||
import { usePluginStore } from '../../../../src/store/pluginStore';
|
||||
import type { TripCardBadge } from '../../../../src/api/client';
|
||||
import type { DashboardTrip } from '../../../../src/pages/dashboard/dashboardModel';
|
||||
import { setSizeClass } from '../../../helpers/sizeClass';
|
||||
|
||||
// FE-MOB-DASH-001 onwards
|
||||
|
||||
@@ -416,6 +417,21 @@ describe('MDashboard', () => {
|
||||
expect(screen.getByText('Upcoming reservations')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('FE-MOB-DASH-041: crossing the split size keeps the widgets mounted, so the converter keeps its amount', () => {
|
||||
mocks.dash = buildDash();
|
||||
render(<MDashboard />);
|
||||
const amount = screen.getAllByRole('textbox', { name: 'From' })[0] as HTMLInputElement;
|
||||
fireEvent.change(amount, { target: { value: '250' } });
|
||||
|
||||
setSizeClass('split');
|
||||
expect(screen.getAllByRole('textbox', { name: 'From' })[0]).toBe(amount);
|
||||
expect(amount.value).toBe('250');
|
||||
|
||||
setSizeClass('compact');
|
||||
expect(screen.getAllByRole('textbox', { name: 'From' })[0]).toBe(amount);
|
||||
expect(amount.value).toBe('250');
|
||||
});
|
||||
|
||||
it('FE-MOB-DASH-027: a malformed date renders a dash instead of crashing', () => {
|
||||
mocks.dash = buildDash({ gridTrips: [buildTrip({ id: 14, start_date: 'not-a-date', end_date: iso(3) })] });
|
||||
render(<MDashboard />);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// FE-MOB-JDET-001 to FE-MOB-JDET-048
|
||||
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
|
||||
import { describe, it, expect, beforeEach, afterEach, onTestFinished, vi } from 'vitest';
|
||||
import { render, screen, fireEvent, waitFor, act } from '../../../helpers/render';
|
||||
import { setSizeClass } from '../../../helpers/sizeClass';
|
||||
import MJourneyDetail from '../../../../src/mobile/screens/journey/MJourneyDetail';
|
||||
@@ -246,6 +246,21 @@ afterEach(() => {
|
||||
// ── Tests ────────────────────────────────────────────────────────────────────
|
||||
|
||||
describe('MJourneyDetail', () => {
|
||||
it('FE-MOB-JDET-049: a folded Duo on its side (540px high) gets the compact cards, so the map keeps its room', () => {
|
||||
const real = window.matchMedia;
|
||||
// Height queries answered for a window 540px high; the rest as the setup answers them.
|
||||
const tall = (query: string): MediaQueryList => {
|
||||
const max = /\(\s*max-height:\s*(\d+)px\s*\)/.exec(query);
|
||||
const list = real(query);
|
||||
return max ? ({ ...list, matches: 540 <= Number(max[1]), media: query } as MediaQueryList) : list;
|
||||
};
|
||||
window.matchMedia = tall;
|
||||
onTestFinished(() => { window.matchMedia = real; });
|
||||
setup();
|
||||
expect(document.querySelector('.h-\\[112px\\]')).toBeInTheDocument();
|
||||
expect(document.querySelector('.h-\\[152px\\]')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('FE-MOB-JDET-001: shows a spinner while the journey is loading', () => {
|
||||
setup({ loading: true, current: null });
|
||||
expect(document.querySelector('.animate-spin')).toBeInTheDocument();
|
||||
|
||||
@@ -221,6 +221,8 @@ describe('MPlanTimeline', () => {
|
||||
// The name gives way with an ellipsis; the time after it stays, with no dot between.
|
||||
const sacher = screen.getByText('Hotel Sacher')
|
||||
expect(sacher).toHaveClass('truncate', 'min-w-0')
|
||||
// In an Arabic header a Latin name keeps its own direction, so the ellipsis lands at its end.
|
||||
expect(sacher).toHaveAttribute('dir', 'auto')
|
||||
expect(sacher.closest('button')).toHaveTextContent('Hotel Sacher11:00')
|
||||
expect(sacher.closest('button')).toHaveClass('shrink')
|
||||
expect(screen.getByText('Ryokan Kyoto').closest('button')).toHaveTextContent('Ryokan Kyoto15:00')
|
||||
|
||||
@@ -243,6 +243,14 @@ describe('MTransportsTab', () => {
|
||||
await waitFor(() => expect(p.tripActions.toggleReservationStatus).toHaveBeenCalledWith(7, 101))
|
||||
})
|
||||
|
||||
it('FE-MOB-TRTAB-029: the dot inside the status button is laid out as a box, so it shows', () => {
|
||||
renderTab(planner())
|
||||
const toggle = within(cardOf('HND to ITM')).getByRole('button', { name: 'reservations.pending' })
|
||||
// The dot is a bare span sized by width and height: only a flex (or block) parent gives it its box.
|
||||
expect(toggle).toHaveClass('flex')
|
||||
expect(toggle.querySelector('span')).toHaveClass('h-[7px]', 'w-[7px]')
|
||||
})
|
||||
|
||||
it('FE-MOB-TRTAB-017: toasts when the status toggle fails', async () => {
|
||||
const p = planner()
|
||||
vi.mocked(p.tripActions.toggleReservationStatus).mockRejectedValueOnce(new Error('offline'))
|
||||
|
||||
@@ -421,10 +421,20 @@ describe('MTripShell', () => {
|
||||
expect(more).toHaveAttribute('aria-expanded', 'false')
|
||||
fireEvent.click(more)
|
||||
expect(more).toHaveAttribute('aria-expanded', 'true')
|
||||
expect(more).toHaveClass('bg-m-act')
|
||||
// A ring, as the main dock marks its More, not the fill of a tab.
|
||||
expect(more).toHaveClass('ring-[1.5px]')
|
||||
expect(more).not.toHaveClass('bg-m-act')
|
||||
expect(plan).not.toHaveAttribute('aria-current')
|
||||
act(() => { shellApi.closeSheet() })
|
||||
expect(plan).toHaveAttribute('aria-current', 'page')
|
||||
expect(more).not.toHaveClass('ring-[1.5px]')
|
||||
})
|
||||
|
||||
it('FE-MOB-SHELL-098: a section reached through More marks More with the ring while it is on show', () => {
|
||||
renderShell({ activeTab: 'dateien' } as Partial<TripPlanner>)
|
||||
const more = screen.getByRole('button', { name: 'mobileTrip.more' })
|
||||
expect(more).toHaveAttribute('aria-current', 'page')
|
||||
expect(more).toHaveClass('ring-[1.5px]')
|
||||
expect(more).not.toHaveClass('bg-m-act')
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user