fix(dashboard): upcoming bookings read cleanly, pending as a letter on the icon

The PENDING pill beside a title broke long names over several lines; a small
dot on the type icon's corner now carries the status's first letter (A for
Ausstehend, P for Pending), with the word as its tooltip and accessible name.
The time and the trip or place below the name are soft badges instead of a
line strung together with dots. Desktop and phone alike.
This commit is contained in:
Maurice
2026-11-15 12:22:05 +01:00
parent a1f063c703
commit cb1b5dd88c
5 changed files with 46 additions and 19 deletions
@@ -278,7 +278,7 @@ function MUpcomingWidget({ items }: { items: UpcomingReservation[] }): React.Rea
navigate(`/trips/${tripId}`)
}
const subFor = (r: UpcomingReservation): string => {
const subFor = (r: UpcomingReservation): string[] => {
const parsed = splitReservationDateTime(r.reservation_time)
const datePart = parsed.date || r.day_date || null
const date = datePart ? new Date(datePart + 'T00:00:00Z') : null
@@ -287,7 +287,8 @@ function MUpcomingWidget({ items }: { items: UpcomingReservation[] }): React.Rea
: null
const timeStr = parsed.time ? formatTime(parsed.time, locale, timeFormat) : null
const tail = MOMENT_LABEL[r.type] ? t(MOMENT_LABEL[r.type]) : (r.location || r.place_name || r.trip_title || null)
return [dateStr, timeStr, tail].filter(Boolean).join(' · ')
// Each part a badge of its own instead of one line strung together with dots.
return [dateStr, timeStr, tail].filter((part): part is string => !!part)
}
return (
@@ -302,19 +303,24 @@ function MUpcomingWidget({ items }: { items: UpcomingReservation[] }): React.Rea
onClick={() => openReservation(r.trip_id)}
className="flex w-full items-center gap-[11px] border-b border-[color:var(--m-rowbr)] py-[9px] text-start"
>
<span className="flex h-8 w-8 flex-none items-center justify-center rounded-[11px] bg-[color:var(--m-ic)]">
<span className="relative flex h-8 w-8 flex-none items-center justify-center rounded-[11px] bg-[color:var(--m-ic)]">
{RES_ICON[r.type] || <Ticket size={14} strokeWidth={2} />}
{/* Pending: the status's first letter on a dot at the icon's corner, the word for screen readers. */}
{r.status === 'pending' && (
<span aria-label={t('reservations.pending')} className="absolute -start-[5px] -top-[5px] flex h-4 w-4 items-center justify-center rounded-full bg-m-act text-[0.5625rem] font-bold leading-none text-m-actfg shadow-[0_0_0_2px_var(--m-card)]">
{t('reservations.pending').charAt(0).toUpperCase()}
</span>
)}
</span>
<div className="min-w-0 flex-1">
<div className="flex min-w-0 items-center gap-1.5">
<span dir="auto" className="truncate text-[0.8125rem] font-semibold">{r.title}</span>
{r.status === 'pending' && (
<span className="flex-none rounded-full bg-[color:var(--m-ic)] px-[6px] py-px font-geist text-[0.5625rem] font-bold uppercase tracking-[.08em] text-m-muted">
{t('reservations.pending')}
</span>
)}
</div>
<div className="truncate font-geist text-[0.625rem] text-m-muted">{subFor(r)}</div>
<div className="mt-[3px] flex min-w-0 gap-[4px]">
{subFor(r).map(part => (
<span key={part} className="min-w-0 truncate rounded-full bg-m-ic first:flex-none px-[7px] py-px font-geist text-[0.625rem] font-medium text-m-muted">{part}</span>
))}
</div>
</div>
<ChevronRight size={14} strokeWidth={2} className="flex-none text-m-faint" />
</button>
@@ -205,7 +205,10 @@ describe('DashboardPage (desktop)', () => {
// Only the unconfirmed one is marked.
const pending = container.querySelectorAll('.upc-pending');
expect(pending).toHaveLength(1);
expect(pending[0]).toHaveTextContent('Pending');
// A letter on the type icon's corner, the word as its name and tooltip.
expect(pending[0]).toHaveTextContent(/^P$/);
expect(pending[0]).toHaveAttribute('aria-label', 'Pending');
expect(pending[0].closest('.upc-type')).not.toBeNull();
});
it('FE-PAGE-DESKDASH-009: the currency tool converts and swaps the pair', async () => {
+12 -4
View File
@@ -769,14 +769,22 @@ function UpcomingTool({ items, locale, onOpen }: {
<div className="upc-info">
<div className="t">
{r.title}
{r.status === 'pending' && <span className="upc-pending">{t('reservations.pending')}</span>}
</div>
<div className="s">
{timeStr && <><Clock size={11} /> {timeStr} · </>}
{moment ? t(moment) : (r.location || r.place_name || r.trip_title)}
{timeStr && <span className="upc-chip"><Clock size={11} />{timeStr}</span>}
{(moment || r.location || r.place_name || r.trip_title) && (
<span className="upc-chip">{moment ? t(moment) : (r.location || r.place_name || r.trip_title)}</span>
)}
</div>
</div>
<div className={`upc-type ${typeClass}`}>{RES_ICON[r.type] || <Ticket size={16} />}</div>
<div className={`upc-type ${typeClass}`}>
{RES_ICON[r.type] || <Ticket size={16} />}
{r.status === 'pending' && (
<span className="upc-pending" title={t('reservations.pending')} aria-label={t('reservations.pending')}>
{t('reservations.pending').charAt(0).toUpperCase()}
</span>
)}
</div>
</div>
)
})}
+8 -3
View File
@@ -650,10 +650,15 @@
.trek-dash .upc-info .t { font-size: 14px; font-weight: 500; margin-bottom: 2px; }
.trek-dash .upc-info .t { display: flex; align-items: center; gap: 7px; }
/* An unconfirmed booking looked exactly like a confirmed one here (#1934). */
.trek-dash .upc-pending { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; padding: 2px 6px; border-radius: 999px; background: var(--bg-2); color: var(--ink-3); }
.trek-dash .upc-info .s { font-size: 12px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
/* A pending booking: its status's first letter on a dot at the type icon's corner, the word as its tooltip. */
.trek-dash .upc-pending { position: absolute; top: -5px; inset-inline-start: -5px; width: 16px; height: 16px; border-radius: 50%; display: grid; place-items: center; font-size: 9px; font-weight: 700; line-height: 1; background: var(--ink); color: var(--surface); box-shadow: 0 0 0 2px var(--surface); }
.trek-dash .upc-info .s { font-size: 12px; color: var(--ink-3); display: flex; align-items: center; gap: 5px; margin-top: 3px; min-width: 0; }
.trek-dash .upc-info .s .upc-chip:first-child { flex-shrink: 0; }
.trek-dash .upc-info .s .upc-chip { min-width: 0; }
/* The time and the where as soft badges instead of a line strung together with dots. */
.trek-dash .upc-chip { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; padding: 2px 8px; border-radius: 999px; background: var(--bg-2); color: var(--ink-2); font-size: 11.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trek-dash .upc-info .s svg { width: 11px; height: 11px; }
.trek-dash .upc-type { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; }
.trek-dash .upc-type { position: relative; width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; }
.trek-dash .upc-type.flight { background: oklch(0.95 0.04 230); color: oklch(0.45 0.13 230); }
.trek-dash .upc-type.hotel { background: oklch(0.95 0.04 145); color: oklch(0.4 0.12 155); }
.trek-dash .upc-type.food { background: oklch(0.95 0.05 60); color: oklch(0.5 0.13 50); }
@@ -398,7 +398,10 @@ describe('MUpcomingWidget', () => {
/>,
);
expect(screen.getByText('Sep 3 · 19:30 · Narita')).toBeInTheDocument();
// Date, time and place as badges of their own, no dots strung between them.
expect(screen.getByText('Sep 3')).toBeInTheDocument();
expect(screen.getByText('19:30')).toBeInTheDocument();
expect(screen.getByText('Narita')).toBeInTheDocument();
});
it('FE-MOB-DWID-030: an unparseable date degrades to the remaining parts', () => {
@@ -449,6 +452,8 @@ describe('MUpcomingWidget', () => {
/>,
);
expect(screen.getAllByText('Pending')).toHaveLength(1);
// A letter on the icon's corner, with the word as its accessible name.
expect(screen.getAllByLabelText('Pending')).toHaveLength(1);
expect(screen.getByLabelText('Pending')).toHaveTextContent(/^P$/);
});
});