mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-23 13:23:04 +00:00
ba70ad28b8
Arabic runs the app right to left, but margins, paddings, insets, text alignment, borders and corner radii were written for the left side, so icons sat against the wrong edge of their labels, indents and badges pointed the wrong way and amount columns aligned left. They now use the logical forms (ms-, ps-, start-, text-start, marginInlineStart, insetInlineEnd and their CSS equivalents), which are the very same sides in a left to right language. Geometry stays physical on purpose: maps, positions measured from the pointer or a bounding box, time axes, sliders, transforms and print output. Amounts drawn as several spans keep their order in a right to left row, the time picker keeps hours before minutes, and two switches whose thumb slid out of its track in Arabic now move the right way. lint:rtl counts what is still physical per file against a baseline that may only shrink (1512 uses in 370 files before, 319 in 113 now), and CI runs it, so new code reaches for the logical forms.
88 lines
4.1 KiB
TypeScript
88 lines
4.1 KiB
TypeScript
import { AlertTriangle } from 'lucide-react'
|
|
import { useTranslation } from '../../i18n'
|
|
import DayImpactList from '../shared/DayImpactList'
|
|
import { dayChips, shrinkTripLines, type ShiftMode } from '../../utils/dayImpactLines'
|
|
import type { RangeCheck } from '../../hooks/useTripRangeGuard'
|
|
|
|
interface TripDateReviewProps {
|
|
/** The start of a dated trip moved: ask how bookings follow (#1288). */
|
|
askShift: boolean
|
|
shiftMode: ShiftMode
|
|
onShiftMode: (mode: ShiftMode) => void
|
|
/** What the new dates remove, if anything worth a word. */
|
|
removal: RangeCheck
|
|
error?: string
|
|
}
|
|
|
|
/**
|
|
* Whether the step shows both of its parts. Then they stand side by side in a wide
|
|
* dialog, the question on the left and the removed days on the right, instead of one
|
|
* long column that has to be scrolled through before the buttons.
|
|
*/
|
|
export function dateReviewIsWide(askShift: boolean, removal: RangeCheck): boolean {
|
|
return askShift && !!removal && removal !== 'unknown'
|
|
}
|
|
|
|
/**
|
|
* The step the trip dialog puts between a change of dates and the save: how
|
|
* bookings follow a moved start, and which days the new range removes with what
|
|
* is on them. Either part can stand alone. The list's booking hint follows the
|
|
* shift mode picked beside it, because the two modes leave those bookings in
|
|
* different places.
|
|
*/
|
|
export default function TripDateReview({ askShift, shiftMode, onShiftMode, removal, error }: TripDateReviewProps) {
|
|
const { t } = useTranslation()
|
|
const modes: { mode: ShiftMode; label: string; desc: string }[] = [
|
|
{ mode: 'keep_bookings', label: t('dashboard.dateShiftKeepBookings'), desc: t('dashboard.dateShiftKeepBookingsDesc') },
|
|
{ mode: 'shift_all', label: t('dashboard.dateShiftAll'), desc: t('dashboard.dateShiftAllDesc') },
|
|
]
|
|
|
|
const wide = dateReviewIsWide(askShift, removal)
|
|
|
|
return (
|
|
<div className="space-y-3">
|
|
{error && (
|
|
<div className="p-3 bg-danger-soft border border-danger/30 rounded-xl text-body text-danger">{error}</div>
|
|
)}
|
|
<div className={wide ? 'grid gap-5 md:grid-cols-2' : 'space-y-3'}>
|
|
{askShift && (
|
|
<div className="space-y-3">
|
|
<p className="text-body text-content-secondary">{t('dashboard.dateShiftIntro')}</p>
|
|
{modes.map(({ mode, label, desc }) => (
|
|
<label key={mode}
|
|
className={`flex items-start gap-3 rounded-xl border px-3 py-2.5 cursor-pointer transition-colors ${shiftMode === mode ? 'border-accent bg-surface-selected' : 'border-edge hover:bg-surface-hover'}`}>
|
|
<input type="radio" name="date_shift_mode" value={mode} checked={shiftMode === mode}
|
|
onChange={() => onShiftMode(mode)} className="mt-1 accent-[var(--accent)]" />
|
|
<span className="block text-body font-medium leading-snug text-content">
|
|
{label}
|
|
<span className="mt-0.5 block text-caption font-normal text-content-muted text-pretty">{desc}</span>
|
|
</span>
|
|
</label>
|
|
))}
|
|
<p className="text-caption text-content-muted">{t('dashboard.dateShiftHint')}</p>
|
|
</div>
|
|
)}
|
|
{removal === 'unknown' && (
|
|
<div role="alert" className="flex items-start gap-3 rounded-xl border border-edge-faint bg-surface-secondary p-3">
|
|
<span className="mt-0.5 flex h-7 w-7 flex-shrink-0 items-center justify-center rounded-lg bg-danger-soft text-danger">
|
|
<AlertTriangle size={15} strokeWidth={2} aria-hidden="true" />
|
|
</span>
|
|
<p className="text-body text-content">{t('dashboard.shrinkUnknown')}</p>
|
|
</div>
|
|
)}
|
|
{removal && removal !== 'unknown' && (
|
|
// Beside the question on a wide screen, below it on a narrow one.
|
|
<div className={wide ? 'border-t border-edge-faint pt-3 md:border-s md:border-t-0 md:ps-5 md:pt-0' : ''}>
|
|
<p className="text-body text-content-secondary">{t('dashboard.shrinkIntro')}</p>
|
|
<DayImpactList
|
|
lines={shrinkTripLines(removal, t, shiftMode)}
|
|
days={dayChips(removal.dayLabels, t)}
|
|
label={t('dashboard.shrinkTitle')}
|
|
/>
|
|
</div>
|
|
)}
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|