mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-23 05:21:15 +00:00
fix(native): one size class the keyboard cannot move, shortcuts that wait for sheets
From the large-screen review (code findings H1, M1, M2, M3, M4, M7, L1, L3, L4, L6, L7): - The size class is one value in JavaScript (hooks/sizeClass.ts) and the stylesheet follows it: MobileShell writes it to the shell as data-size, the wide:/split: variants and mobile.css key on that instead of media queries of their own. A window that only grows shorter at the same width while a field has focus is Android's soft keyboard, not a new window, so the rail, the form sheets and the panes no longer fold away (and take the focused field with them) while one types. - The large-screen layout is the app's only. In a browser the touch shell is the phone's below 768px and stays compact there, as before this branch. - Shortcuts are the app's only, so a browser keeps Ctrl+1 and Alt+Left. The command key is the platform's own (Cmd on Apple, Ctrl elsewhere), digits are matched by the key's place as well (AZERTY), and nothing runs while a sheet or another modal dialog is open: the page listens to nothing and the app is handed no key commands, so Cmd+[ can no longer drop an unsaved form. - Inside a trip Cmd+N belongs to the trip shell and creates what the tab on show creates, named after it. - Inside the touch shell the desktop navbar of the few PageShell routes is hidden and --nav-h is 0. - The rail comes before the page in the DOM, so a keyboard reaches it first. - The phone's deep day colour for a journey card without a photo stays the phone's; the desktop and shared timelines keep their faint wash. Its card is opaque, a suggestion included, so the map's names do not read through. - The trip widget's iPad mini layout keys on the iPad mini's width alone. - The trip dock gets the scroll-edge strip and the denser dock glass the global dock has. - Duplicate test id FE-MOB-PANES-016 renumbered.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// FE-JRN-COVER-001 to FE-JRN-COVER-010
|
||||
// FE-JRN-COVER-001 to FE-JRN-COVER-011
|
||||
|
||||
import { describe, it, expect, vi } from 'vitest'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
@@ -133,4 +133,25 @@ describe('JourneyEntryCover', () => {
|
||||
expect(container.querySelector('img')).toHaveAttribute('src', '/api/photos/7/thumbnail')
|
||||
expect(container.querySelector('svg.lucide-play')).toBeNull()
|
||||
})
|
||||
|
||||
it('FE-JRN-COVER-011: only the phone draws a card without a photo in the deep day colour, opaque even as a suggestion', () => {
|
||||
const entry = buildEntry({ photos: [], type: 'skeleton' })
|
||||
const phone = render(<JourneyEntryCover entry={entry} dayColor="#6366f1" isActive={false} onClick={() => {}} tone="mobile" />)
|
||||
const phoneCard = phone.getByRole('button')
|
||||
// d9, the deep wash (jsdom spells the colour out as rgba)
|
||||
expect(phoneCard.style.backgroundImage).toMatch(/rgba\(99, 102, 241, 0\.85/)
|
||||
expect(phoneCard.className).not.toContain('opacity-90')
|
||||
expect(phone.container.querySelector('svg.lucide-map-pin')?.getAttribute('class')).toContain('-mt-6')
|
||||
phone.unmount()
|
||||
|
||||
// The desktop and shared timelines keep their faint wash and the day-coloured pin.
|
||||
const desk = render(<JourneyEntryCover entry={entry} dayColor="#6366f1" isActive={false} onClick={() => {}} />)
|
||||
const deskCard = desk.getByRole('button')
|
||||
// 2e, the faint one
|
||||
expect(deskCard.style.backgroundImage).toMatch(/rgba\(99, 102, 241, 0\.18/)
|
||||
expect(deskCard.className).toContain('opacity-90')
|
||||
const pin = desk.container.querySelector('svg.lucide-map-pin') as SVGElement
|
||||
expect(pin.getAttribute('class')).not.toContain('-mt-6')
|
||||
expect(pin.style.color).not.toBe('')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -64,9 +64,10 @@ interface Props {
|
||||
tone?: 'app' | 'mobile'
|
||||
/**
|
||||
* large: the card a wide window shows (an iPad, a foldable unfolded), with
|
||||
* the room for a two-line name and the whole place under it.
|
||||
* the room for a two-line name and the whole place under it. compact: a phone
|
||||
* on its side, where a regular card left the map a strip 30px tall.
|
||||
*/
|
||||
size?: 'regular' | 'large'
|
||||
size?: 'compact' | 'regular' | 'large'
|
||||
}
|
||||
|
||||
export default function JourneyEntryCover({
|
||||
@@ -81,6 +82,7 @@ export default function JourneyEntryCover({
|
||||
size = 'regular',
|
||||
}: Props) {
|
||||
const large = size === 'large'
|
||||
const box = large ? 'h-[196px] w-[176px]' : size === 'compact' ? 'h-[112px] w-[124px]' : 'h-[152px] w-[136px]'
|
||||
const { t, locale } = useTranslation()
|
||||
const isSuggestion = entry.type === 'skeleton'
|
||||
|
||||
@@ -97,7 +99,12 @@ export default function JourneyEntryCover({
|
||||
const mood = showMood ? moodMeta(entry.mood) : undefined
|
||||
const weather = showWeather ? weatherMeta(entry.weather) : undefined
|
||||
|
||||
const emptyGround = tone === 'mobile' ? 'bg-[color:var(--m-sheetop)]' : 'bg-white dark:bg-zinc-800'
|
||||
const mobile = tone === 'mobile'
|
||||
const emptyGround = mobile ? 'bg-[color:var(--m-sheetop)]' : 'bg-white dark:bg-zinc-800'
|
||||
// The mark of a card without a photo: white and raised clear of the name on the
|
||||
// phone's deep day colour, the day's own colour on the faint wash elsewhere.
|
||||
const emptyIcon = mobile ? '-mt-6 opacity-80' : 'opacity-60'
|
||||
const emptyIconStyle = mobile ? undefined : { color: dayColor }
|
||||
// One ground for every corner mark. Dark rather than a white veil: these sit on
|
||||
// whatever photograph the traveller took, and a bright sky swallowed the white one.
|
||||
const badge = 'rounded-full bg-black/45 px-[7px] py-[2px] text-[10px] font-bold whitespace-nowrap text-white backdrop-blur-[2px]'
|
||||
@@ -117,9 +124,9 @@ export default function JourneyEntryCover({
|
||||
// room for it with their gap and top padding).
|
||||
// White on the root: every mark and line on the card is white, over a photo or
|
||||
// over the day's colour alike.
|
||||
className={`relative text-white ${large ? 'h-[196px] w-[176px]' : 'h-[152px] w-[136px]'} flex-none origin-bottom overflow-hidden rounded-[18px] text-start transition-[transform,box-shadow] duration-200 ease-[cubic-bezier(.2,.8,.2,1)] motion-reduce:transition-none ${
|
||||
className={`relative text-white ${box} flex-none origin-bottom overflow-hidden rounded-[18px] text-start transition-[transform,box-shadow] duration-200 ease-[cubic-bezier(.2,.8,.2,1)] motion-reduce:transition-none ${
|
||||
isActive ? 'z-[1] scale-[1.18] shadow-[0_18px_40px_-16px_rgba(0,0,0,.55)]' : 'scale-100 shadow-[0_10px_24px_-14px_rgba(0,0,0,.5)]'
|
||||
} ${src ? '' : emptyGround} ${isSuggestion ? 'opacity-90' : ''}`}
|
||||
} ${src ? '' : emptyGround} ${isSuggestion && !mobile ? 'opacity-90' : ''}`}
|
||||
// backgroundImage, not background: the shorthand would drop the opaque colour
|
||||
// the class supplies and leave the map showing through a card that is only a
|
||||
// faint wash of the day's colour.
|
||||
@@ -131,9 +138,14 @@ export default function JourneyEntryCover({
|
||||
// ring lost its top edge to that clip.
|
||||
style={{
|
||||
boxShadow: `inset 0 0 0 ${isActive ? 2.5 : 1.5}px ${dayColor}${isActive ? '' : 'b3'}`,
|
||||
// Without a photograph the card is the day's colour, deep enough to carry
|
||||
// the white name like a photo does, rather than a grey that read as empty.
|
||||
...(src ? null : { backgroundImage: `linear-gradient(160deg, ${dayColor}d9, ${dayColor}8c 55%, ${dayColor}59)` }),
|
||||
// Without a photograph the phone's card is the day's colour, deep enough to
|
||||
// carry the white name like a photo does, rather than a grey that read as
|
||||
// empty. Its ground stays opaque (no dimming for a suggestion either): it
|
||||
// floats over the map, whose labels read through anything less. The desktop
|
||||
// and shared timelines keep their faint wash of the day.
|
||||
...(src ? null : { backgroundImage: mobile
|
||||
? `linear-gradient(160deg, ${dayColor}d9, ${dayColor}8c 55%, ${dayColor}59)`
|
||||
: `linear-gradient(160deg, ${dayColor}2e, ${dayColor}0d)` }),
|
||||
}}
|
||||
>
|
||||
{src ? (
|
||||
@@ -141,8 +153,8 @@ export default function JourneyEntryCover({
|
||||
) : (
|
||||
<span className="absolute inset-0 flex items-center justify-center">
|
||||
{posterless
|
||||
? <Play size={24} strokeWidth={1.8} fill="currentColor" className="ml-0.5 -mt-6 opacity-80" />
|
||||
: <MapPin size={24} strokeWidth={1.8} className="-mt-6 opacity-80" />}
|
||||
? <Play size={24} strokeWidth={1.8} fill="currentColor" style={emptyIconStyle} className={`ml-0.5 ${emptyIcon}`} />
|
||||
: <MapPin size={24} strokeWidth={1.8} style={emptyIconStyle} className={emptyIcon} />}
|
||||
</span>
|
||||
)}
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ export default function Navbar({ tripTitle, tripId, onBack, showBack, onSettings
|
||||
paddingTop: 'env(safe-area-inset-top, 0px)',
|
||||
height: 'var(--nav-h)',
|
||||
transition: 'background 240ms cubic-bezier(0.23,1,0.32,1), backdrop-filter 240ms cubic-bezier(0.23,1,0.32,1), box-shadow 240ms cubic-bezier(0.23,1,0.32,1)',
|
||||
}} className="hidden md:flex items-center px-4 gap-4 fixed top-0 inset-x-0 z-[200]">
|
||||
}} data-desktop-navbar="" className="hidden md:flex items-center px-4 gap-4 fixed top-0 inset-x-0 z-[200]">
|
||||
{/* Left side. flex-1 basis-0, matching the action cluster on the right, so
|
||||
the tab pill between them sits in the middle of the bar rather than
|
||||
being centred on top of both (#1983). Both columns keep at least their
|
||||
|
||||
@@ -31,18 +31,10 @@ export function useCreateAction(phone: boolean): CreateAction {
|
||||
const inCollection = useMatch('/collections/:id');
|
||||
|
||||
if (inTrip) {
|
||||
// The "+" is context-aware per active tab: Bookings → reservation,
|
||||
// Transports → transport, Costs → expense. Tabs without a create modal
|
||||
// (lists / files / collab) fall through to adding a place. #1349
|
||||
const id = inTrip.params.id;
|
||||
const id = inTrip.params.id ?? '';
|
||||
const tripTab = typeof sessionStorage !== 'undefined' ? sessionStorage.getItem(`trip-tab-${id}`) : null;
|
||||
if (tripTab === 'finanzplan')
|
||||
return { label: t('costs.addExpense'), run: () => navigate(`/trips/${id}?create=expense`) };
|
||||
if (tripTab === 'buchungen')
|
||||
return { label: t('reservations.addManual'), run: () => navigate(`/trips/${id}?create=reservation`) };
|
||||
if (tripTab === 'transports')
|
||||
return { label: t('transport.addManual'), run: () => navigate(`/trips/${id}?create=transport`) };
|
||||
return { label: t('places.addPlace'), run: () => navigate(`/trips/${id}?create=place`) };
|
||||
const intent = tripCreateIntent(id, tripTab);
|
||||
return { label: t(intent.labelKey), run: () => navigate(intent.to) };
|
||||
}
|
||||
if (inJourney) {
|
||||
// Context-aware per tab, like the trip's "+": the Gallery holds photos, so
|
||||
@@ -69,6 +61,19 @@ export function useCreateAction(phone: boolean): CreateAction {
|
||||
return { label: t('dashboard.newTrip'), run: () => navigate('/dashboard?create=1') };
|
||||
}
|
||||
|
||||
/**
|
||||
* What the "+" creates inside a trip, by its active tab: Bookings a reservation,
|
||||
* Transports a transport, Costs an expense. Tabs without a create modal (lists,
|
||||
* files, collab) fall through to adding a place (#1349). Pure, so a caller that
|
||||
* knows the tab itself (the trip's own ⌘N, MTripShell) asks with that one.
|
||||
*/
|
||||
export function tripCreateIntent(tripId: string, tab: string | null): { labelKey: string; to: string } {
|
||||
if (tab === 'finanzplan') return { labelKey: 'costs.addExpense', to: `/trips/${tripId}?create=expense` };
|
||||
if (tab === 'buchungen') return { labelKey: 'reservations.addManual', to: `/trips/${tripId}?create=reservation` };
|
||||
if (tab === 'transports') return { labelKey: 'transport.addManual', to: `/trips/${tripId}?create=transport` };
|
||||
return { labelKey: 'places.addPlace', to: `/trips/${tripId}?create=place` };
|
||||
}
|
||||
|
||||
/** Whether a nav item is the current route: the dashboard only on its exact path, the rest by prefix. */
|
||||
export function isNavItemActive(pathname: string, to: string): boolean {
|
||||
return to === '/dashboard' ? pathname === '/dashboard' : pathname.startsWith(to);
|
||||
|
||||
Reference in New Issue
Block a user