fix(dayplan): the delete question asks inside the day dialog, and its buttons stay small

Deleting a day no longer stacks a second dialog over the reorder dialog. The
dialog swaps its list for the question at the same size and in the same place;
Cancel and Escape bring the list back with the focus on the row asked about.
The foot is one row of normal sized buttons with the hint line above it, the
undated day is labelled "Without date" in every language, and the dialog is a
step wider so no label breaks. The list of what goes with a day is quieter: a
cancelled stay tints its whole row, a day with nothing on it is one plain line.
On the phone the add buttons are two pills under the scrolling list, and the
confirm sheet moves a long label to its own row instead of breaking it.
This commit is contained in:
Maurice
2026-09-23 21:41:05 +02:00
parent f3ca0b1a4c
commit 83be759c49
44 changed files with 625 additions and 315 deletions
+38 -36
View File
@@ -12,19 +12,22 @@ interface DayAddFooterProps {
locale: string
}
const outlineBtn =
'flex items-center justify-center gap-1.5 rounded-lg border border-edge py-2 text-body font-medium transition-colors hover:bg-surface-hover focus-visible:bg-surface-hover disabled:cursor-default disabled:opacity-40 disabled:hover:bg-transparent'
const primaryBtn =
'flex items-center justify-center gap-1.5 rounded-lg bg-accent py-2 text-body font-medium text-accent-text transition-colors hover:bg-accent-hover disabled:cursor-default disabled:opacity-40 disabled:hover:bg-accent'
/** One button size for the whole foot of the reorder dialog, the delete question's included. */
export const FOOTER_BTN =
'inline-flex min-h-9 flex-shrink-0 items-center justify-center gap-1.5 whitespace-nowrap rounded-lg px-3 py-1.5 text-body font-medium transition-colors disabled:cursor-default disabled:opacity-40'
const SECONDARY_BTN = `${FOOTER_BTN} border border-edge text-content-secondary hover:bg-surface-hover disabled:hover:bg-transparent`
const CLOSE_BTN = `${FOOTER_BTN} ml-auto border border-edge text-content-muted hover:bg-surface-hover hover:text-content`
/** The add that matters most, tinted from the accent instead of filled with it. */
const MAIN_BTN = `${FOOTER_BTN} border border-[color:color-mix(in_srgb,var(--accent)_30%,transparent)] bg-[color:color-mix(in_srgb,var(--accent)_10%,transparent)] font-semibold text-accent-on hover:bg-[color:color-mix(in_srgb,var(--accent)_16%,transparent)] disabled:hover:bg-[color:color-mix(in_srgb,var(--accent)_10%,transparent)]`
/**
* The foot of the reorder dialog: close it, or add a day.
*
* On a trip with dates there are two ways to add one, side by side. A day
* without a date goes to the end and leaves the trip dates alone; the next
* calendar day, named on its button, extends the trip by one. The line under
* them says what the button in view does, and switches while the pointer or the
* focus rests on the other one. When no day can be added it says why instead.
* On a trip with dates there are two ways to add one, in one row with Close. The
* next calendar day, named on its button, extends the trip by one; a day without
* a date goes to the end and leaves the trip dates alone. The line above them
* says what the button in view does, and switches while the pointer or the focus
* rests on the other one. When no day can be added it says why instead.
*/
export function DayAddFooter({ dayAdd, onAddDay, onClose, t, locale }: DayAddFooterProps) {
const [aboutUndated, setAboutUndated] = useState(false)
@@ -34,21 +37,21 @@ export function DayAddFooter({ dayAdd, onAddDay, onClose, t, locale }: DayAddFoo
const addOff = busy || !!blocked
const closeButton = (
<button type="button" onClick={onClose} className={`${outlineBtn} flex-shrink-0 px-4 text-content-muted`}>
<button type="button" onClick={onClose} className={CLOSE_BTN}>
{t('common.close')}
</button>
)
if (!dayAdd?.nextDate) {
return (
<div className="flex items-center justify-between gap-3">
{closeButton}
<div className="flex min-w-0 items-center gap-3">
{blocked && <span className="min-w-0 text-caption text-content-faint">{blocked}</span>}
<button type="button" onClick={onAddDay} disabled={addOff} className={`${primaryBtn} flex-shrink-0 px-4`}>
<Plus size={15} strokeWidth={2} />
<div className="flex flex-col gap-2.5">
{blocked && <p className="m-0 text-caption text-content-faint">{blocked}</p>}
<div className="flex flex-wrap items-center gap-2">
<button type="button" onClick={onAddDay} disabled={addOff} className={MAIN_BTN}>
<Plus size={15} strokeWidth={2} aria-hidden="true" />
{t('dayplan.addDay')}
</button>
{closeButton}
</div>
</div>
)
@@ -65,34 +68,33 @@ export function DayAddFooter({ dayAdd, onAddDay, onClose, t, locale }: DayAddFoo
}
return (
<div className="flex flex-col gap-3">
<div className="grid grid-cols-2 gap-2">
<button
type="button"
onClick={onAddDay}
disabled={addOff}
aria-describedby={hintId}
className={`${outlineBtn} min-w-0 px-3 text-center leading-tight text-content-secondary`}
{...pointAtUndated}
>
<Plus size={15} strokeWidth={2} className="flex-shrink-0" />
{t('dayplan.addUndatedDay')}
</button>
<div className="flex flex-col gap-2.5">
<p id={hintId} aria-live="polite" className="m-0 text-caption text-content-faint">
{hint}
</p>
{/* Should a language run long, the row wraps between buttons, never inside one. */}
<div className="flex flex-wrap items-center gap-2">
<button
type="button"
onClick={dayAdd.onAddDated}
disabled={addOff || !!dayAdd.datedBlocked}
aria-describedby={hintId}
className={`${primaryBtn} min-w-0 px-3 text-center leading-tight`}
className={MAIN_BTN}
>
<CalendarPlus size={15} strokeWidth={2} className="flex-shrink-0" />
<CalendarPlus size={15} strokeWidth={2} aria-hidden="true" />
{t('dayplan.addDatedDay', { date })}
</button>
</div>
<div className="flex items-center justify-between gap-3">
<p id={hintId} aria-live="polite" className="m-0 min-w-0 text-caption text-content-faint">
{hint}
</p>
<button
type="button"
onClick={onAddDay}
disabled={addOff}
aria-describedby={hintId}
className={SECONDARY_BTN}
{...pointAtUndated}
>
<Plus size={15} strokeWidth={2} aria-hidden="true" />
{t('dayplan.addUndatedDay')}
</button>
{closeButton}
</div>
</div>