diff --git a/client/scripts/eslint-baseline.json b/client/scripts/eslint-baseline.json index df4ac5097..9c19b5144 100644 --- a/client/scripts/eslint-baseline.json +++ b/client/scripts/eslint-baseline.json @@ -1,6 +1,6 @@ { "src": { - "@typescript-eslint/no-non-null-assertion": 368, + "@typescript-eslint/no-non-null-assertion": 367, "@typescript-eslint/no-misused-promises": 820, "no-console": 88, "complexity": 217, diff --git a/client/scripts/theme-baseline.json b/client/scripts/theme-baseline.json index fe60408e7..10da2cade 100644 --- a/client/scripts/theme-baseline.json +++ b/client/scripts/theme-baseline.json @@ -241,7 +241,7 @@ "mobile/screens/trip/sheets/MDaysSheet.tsx": 4, "mobile/screens/trip/sheets/MExportSheet.tsx": 2, "mobile/screens/trip/sheets/MImportSheet.tsx": 2, - "mobile/screens/trip/sheets/MLinkedCosts.tsx": 9, + "mobile/screens/trip/sheets/MLinkedCosts.tsx": 8, "mobile/screens/trip/sheets/MMehrSheet.tsx": 3, "mobile/screens/trip/sheets/MNoteSheet.tsx": 1, "mobile/screens/trip/sheets/MPlaceEditSheet.tsx": 2, @@ -250,8 +250,8 @@ "mobile/screens/trip/sheets/MTransportFormSheet.tsx": 9, "mobile/screens/trip/sheets/MTransportSheet.tsx": 9, "mobile/screens/trip/sheets/MTripSheetUi.tsx": 5, - "mobile/screens/trip/sheets/PlCategoryPicker.tsx": 2, - "mobile/screens/trip/sheets/PlFileAttach.tsx": 7, + "mobile/screens/trip/sheets/PlCategoryPicker.tsx": 1, + "mobile/screens/trip/sheets/PlFileAttach.tsx": 3, "mobile/screens/trip/sheets/PlPlaceSearch.tsx": 6, "mobile/screens/trip/sheets/PlSheetChrome.tsx": 5, "mobile/screens/trip/sheets/PlTimeFields.tsx": 3, diff --git a/client/src/components/Planner/PlaceContactFields.test.tsx b/client/src/components/Planner/PlaceContactFields.test.tsx index 82ea80228..987ae9eda 100644 --- a/client/src/components/Planner/PlaceContactFields.test.tsx +++ b/client/src/components/Planner/PlaceContactFields.test.tsx @@ -54,7 +54,7 @@ describe('PlaceContactFields (#2472)', () => { const opens = screen.getAllByRole('textbox', { name: /Monday opens/ }) await user.type(opens[0], '0930') expect(opens[0]).toHaveValue('09:30') - expect(JSON.parse(onChange.mock.lastCall![1])[0]).toEqual({ closed: false, open: '09:30' }) + expect(JSON.parse(onChange.mock.lastCall?.[1])[0]).toEqual({ closed: false, open: '09:30' }) }) it('FE-PLANNER-CONTACT-004: looked-up hours fill an empty place, and an edited one offers to take them over', async () => { @@ -97,7 +97,7 @@ describe('PlaceContactFields (#2472)', () => { const allDay = screen.getByRole('switch', { name: 'Monday: Open 24 hours' }) expect(allDay).toHaveAttribute('aria-checked', 'false') await user.click(allDay) - expect(JSON.parse(onChange.mock.lastCall![1])[0]).toEqual({ closed: false, open: '00:00', close: '23:59' }) + expect(JSON.parse(onChange.mock.lastCall?.[1])[0]).toEqual({ closed: false, open: '00:00', close: '23:59' }) expect(allDay).toHaveAttribute('aria-checked', 'true') // The two time fields give way to the word. expect(screen.queryByRole('textbox', { name: /Monday opens/ })).not.toBeInTheDocument() @@ -105,7 +105,7 @@ describe('PlaceContactFields (#2472)', () => { // Closing the day turns the all-day switch off. await user.click(screen.getByRole('switch', { name: 'Monday: Closed' })) - expect(JSON.parse(onChange.mock.lastCall![1])[0]).toEqual({ closed: true }) + expect(JSON.parse(onChange.mock.lastCall?.[1])[0]).toEqual({ closed: true }) expect(allDay).toHaveAttribute('aria-checked', 'false') }) diff --git a/client/src/components/Planner/PlaceDetailsColumn.tsx b/client/src/components/Planner/PlaceDetailsColumn.tsx index b2155ba30..f1e66e541 100644 --- a/client/src/components/Planner/PlaceDetailsColumn.tsx +++ b/client/src/components/Planner/PlaceDetailsColumn.tsx @@ -251,7 +251,7 @@ export default function PlaceDetailsColumn({ className="flex h-[36px] w-full shrink-0 items-center gap-2 rounded-full border border-[color:var(--m-rowbr)] bg-[color:var(--m-ic)] pe-3 ps-3.5 text-start" > - {t('places.details.title')} + {t('places.details.title')} { const coords = screen.getByRole('group', { name: 'Coordinates' }); expect(within(coords).getByPlaceholderText(/Latitude/i)).toBeInTheDocument(); expect(within(coords).getByPlaceholderText(/Longitude/i)).toBeInTheDocument(); - // Each Markdown field keeps its own formatting bar. - expect(screen.getAllByRole('toolbar')).toHaveLength(2); + // Each Markdown field keeps its own formatting bar; only the open tab's is shown. + expect(screen.getAllByRole('toolbar', { hidden: true })).toHaveLength(2); + expect(screen.getAllByRole('toolbar')).toHaveLength(1); }); it('FE-PLANNER-PLACEFORM-105: the new category field takes the focus when it opens', async () => { @@ -2685,7 +2686,8 @@ describe('PlaceFormModal in the look of the booking editors', () => { it('FE-PLANNER-PLACEFORM-120: the formatting bars show their names in the shared tooltip, never the native one', async () => { const user = userEvent.setup(); render(); - const bars = screen.getAllByRole('toolbar'); + // Both Markdown texts have a bar; the hidden tab's waits under its tab. + const bars = screen.getAllByRole('toolbar', { hidden: true }); expect(bars).toHaveLength(2); for (const bar of bars) { for (const button of within(bar).getAllByRole('button')) expect(button).not.toHaveAttribute('title'); @@ -2748,6 +2750,8 @@ describe('PlaceFormModal and the columns beside it', () => { const assignment = buildAssignment({ id: 123, day_id: 5, place, notes: 'Old note' }); render(); + // The day's note sits under its own tab. + await user.click(within(screen.getByRole('group', { name: 'Text to edit' })).getByRole('button', { name: /day/i })); const notes = screen.getByRole('textbox', { name: 'Notes for this day' }); expect(notes).toHaveValue('Old note'); await user.clear(notes); diff --git a/client/src/components/Planner/PlaceFormTexts.tsx b/client/src/components/Planner/PlaceFormTexts.tsx index 797594d7c..cf571469a 100644 --- a/client/src/components/Planner/PlaceFormTexts.tsx +++ b/client/src/components/Planner/PlaceFormTexts.tsx @@ -58,7 +58,7 @@ export function PlaceFormTexts({ return (
- fill value={shown.field} onChange={setActive} diff --git a/client/src/components/Planner/TagColorField.tsx b/client/src/components/Planner/TagColorField.tsx index 3883e5b28..f2f5f2372 100644 --- a/client/src/components/Planner/TagColorField.tsx +++ b/client/src/components/Planner/TagColorField.tsx @@ -97,6 +97,8 @@ export function TagColorField({
- +
({ ...hsv, h: at(e).x * 359.9 }))} > - +
{ // Google writes a place open all week as one period on Sunday that never closes. expect(weekFromPeriods([{ open: p(0, 0), close: null }])).toEqual(Array.from({ length: 7 }, () => ({ closed: false, ...ALL_DAY }))) // A day from midnight to the next midnight is the same. - expect(weekFromPeriods([{ open: p(1, 0), close: p(2, 0) }])![0]).toEqual({ closed: false, ...ALL_DAY }) + expect(weekFromPeriods([{ open: p(1, 0), close: p(2, 0) }])?.[0]).toEqual({ closed: false, ...ALL_DAY }) expect(isAllDay({ closed: false, open: '00:00', close: '23:59' })).toBe(true) expect(isAllDay({ closed: false, open: '00:00', close: '00:00' })).toBe(true) expect(isAllDay({ closed: false, open: '00:00', close: '22:00' })).toBe(false) @@ -78,10 +78,10 @@ describe('typing and taking over (#2472)', () => { const week = emptyWeek() week[0] = { closed: false, ...ALL_DAY } week[1] = { closed: false, open: '09:00', close: '17:00' } - const lines = hoursLines(writeWeek(week), 'en', 'Closed', 'Open 24 hours')! + const lines = hoursLines(writeWeek(week), 'en', 'Closed', 'Open 24 hours') ?? [] expect(lines[0]).toBe('Monday: Open 24 hours') expect(lines[1]).toBe('Tuesday: 09:00 – 17:00') // Without the label the times stay, as before. - expect(hoursLines(writeWeek(week), 'en', 'Closed')![0]).toBe('Monday: 00:00 – 23:59') + expect(hoursLines(writeWeek(week), 'en', 'Closed')?.[0]).toBe('Monday: 00:00 – 23:59') }) }) diff --git a/client/src/mobile/screens/trip/sheets/MPlaceEditSheet.tsx b/client/src/mobile/screens/trip/sheets/MPlaceEditSheet.tsx index 79cbca704..6c48c70dd 100644 --- a/client/src/mobile/screens/trip/sheets/MPlaceEditSheet.tsx +++ b/client/src/mobile/screens/trip/sheets/MPlaceEditSheet.tsx @@ -1,5 +1,6 @@ import { useEffect, useMemo, useRef, useState, type ClipboardEvent } from 'react' import { Globe, MapPin, MapPinOff } from 'lucide-react' +import { fs } from '../../../../components/shared/DialogShell' import MSheet from '../../../components/MSheet' import { DEFAULT_FORM, @@ -373,7 +374,8 @@ export default function MPlaceEditSheet({ planner, onOpenExpense }: MPlaceEditSh onChange={e => handleChange('website', e.target.value)} placeholder="https://" aria-label={t('places.formWebsite')} - className="min-w-0 flex-1 bg-transparent font-[inherit] text-[0.84375rem] font-medium text-m-ink outline-none placeholder:text-m-faint" + className="min-w-0 flex-1 bg-transparent font-[inherit] font-medium text-m-ink outline-none placeholder:text-m-faint" + style={fs(13.5, 'body')} /> diff --git a/client/src/mobile/screens/trip/sheets/PlCategoryPicker.tsx b/client/src/mobile/screens/trip/sheets/PlCategoryPicker.tsx index c9faf713b..d484d7e11 100644 --- a/client/src/mobile/screens/trip/sheets/PlCategoryPicker.tsx +++ b/client/src/mobile/screens/trip/sheets/PlCategoryPicker.tsx @@ -1,4 +1,4 @@ -import { useState } from 'react' +import { createElement, useState } from 'react' import { Ban, Check, ChevronDown, Plus, X } from 'lucide-react' import { getCategoryIcon } from '../../../../components/shared/categoryIcons' import { useNewCategory } from '../../../../components/Planner/usePlaceForm' @@ -35,7 +35,14 @@ export default function PlCategoryPicker({ planner, value, onChange }: PlCategor } = useNewCategory({ variant: 'sheet', create: tripActions.addCategory, onCreated: pick, t, toast }) const current = (categories || []).find(cat => String(cat.id) === value) - const CurrentIcon = current ? getCategoryIcon(current.icon) : Ban + // The icon of the picked category, made as an element: a component looked up while + // rendering would be a new one each time to React. + const currentIcon = createElement(current ? getCategoryIcon(current.icon) : Ban, { + size: 15, + strokeWidth: 2, + className: 'flex-none', + style: current?.color ? { color: current.color } : undefined, + }) return (
@@ -46,7 +53,7 @@ export default function PlCategoryPicker({ planner, value, onChange }: PlCategor onClick={() => setOpen(v => !v)} className={`${SELECT_FIELD_CLS} gap-[10px] text-start`} > - + {currentIcon} {current ? current.name : t('places.noCategory')} diff --git a/client/src/mobile/screens/trip/sheets/PlContactFields.test.tsx b/client/src/mobile/screens/trip/sheets/PlContactFields.test.tsx index d46c7476d..414856aa9 100644 --- a/client/src/mobile/screens/trip/sheets/PlContactFields.test.tsx +++ b/client/src/mobile/screens/trip/sheets/PlContactFields.test.tsx @@ -43,11 +43,11 @@ describe('PlContactFields', () => { fireEvent.click(screen.getByRole('button', { name: 'places.hoursAdd' })); fireEvent.click(screen.getByRole('switch', { name: 'Monday: places.hoursAllDay' })); - expect(JSON.parse(onChange.mock.lastCall![1])[0]).toEqual({ closed: false, open: '00:00', close: '23:59' }); + expect(JSON.parse(onChange.mock.lastCall?.[1])[0]).toEqual({ closed: false, open: '00:00', close: '23:59' }); expect(screen.getByRole('switch', { name: 'Monday: places.hoursAllDay' })).toHaveAttribute('aria-checked', 'true'); fireEvent.click(screen.getByRole('switch', { name: 'Tuesday: places.hoursClosed' })); - expect(JSON.parse(onChange.mock.lastCall![1])[1]).toEqual({ closed: true }); + expect(JSON.parse(onChange.mock.lastCall?.[1])[1]).toEqual({ closed: true }); expect(screen.getByText('places.hoursClosed')).toBeInTheDocument(); }); @@ -57,7 +57,7 @@ describe('PlContactFields', () => { fireEvent.click(screen.getByRole('button', { name: 'places.hoursAdd' })); fireEvent.click(screen.getByRole('switch', { name: 'Monday: places.hoursClosed' })); fireEvent.click(screen.getByRole('button', { name: 'places.hoursCopyFirst:Monday' })); - expect(JSON.parse(onChange.mock.lastCall![1]).every((d: { closed: boolean }) => d.closed)).toBe(true); + expect(JSON.parse(onChange.mock.lastCall?.[1]).every((d: { closed: boolean }) => d.closed)).toBe(true); fireEvent.click(screen.getByRole('button', { name: 'places.hoursRemove' })); expect(onChange).toHaveBeenLastCalledWith('opening_hours', ''); expect(screen.getByRole('button', { name: 'places.hoursAdd' })).toBeInTheDocument(); diff --git a/client/src/mobile/screens/trip/sheets/PlContactFields.tsx b/client/src/mobile/screens/trip/sheets/PlContactFields.tsx index 9a19b4b30..98531a4a3 100644 --- a/client/src/mobile/screens/trip/sheets/PlContactFields.tsx +++ b/client/src/mobile/screens/trip/sheets/PlContactFields.tsx @@ -4,22 +4,26 @@ import { Clock, Copy, DoorClosed, Mail, Phone, RotateCcw, X } from 'lucide-react import { isAllDay, weekdayNames } from '../../../../components/Planner/placeHours'; import { usePlaceHours } from '../../../../components/Planner/usePlaceHours'; import CustomTimePicker from '../../../../components/shared/CustomTimePicker'; +import { fs } from '../../../../components/shared/DialogShell'; import { NO_AUTOFILL } from '../../../../utils/noAutofill'; import { AddFieldButton, AMOUNT_FIELD_CLS, Eyebrow, FORM_PAIR_CLS } from './PlSheetChrome'; +/** The text of the sheet's fields, 13.5 px as in FIELD_CLS, following the text size setting. */ +const FIELD_TEXT = fs(13.5, 'body'); + type Translate = (key: string, params?: Record) => string; const LABEL = 'mb-[5px] mt-3 uppercase'; const BARE_INPUT = - 'min-w-0 flex-1 bg-transparent font-[inherit] text-[0.84375rem] font-medium text-m-ink outline-none placeholder:text-m-faint'; + 'min-w-0 flex-1 bg-transparent font-[inherit] font-medium text-m-ink outline-none placeholder:text-m-faint'; const HEAD_BUTTON = 'grid h-[28px] w-[28px] place-items-center rounded-full text-m-muted active:bg-[color:var(--m-ic)]'; const WEEK = 'overflow-hidden rounded-[18px] border border-[color:var(--m-rowbr)] bg-[color:var(--m-ic)]'; const DAY_ROW = 'grid grid-cols-[22px_minmax(0,1fr)_auto] items-center gap-[6px] border-b border-[color:var(--m-rowbr)] px-[8px] py-[6px] last:border-b-0'; /** A closed or all-day day says so where its two times would be. */ -const DAY_STATE = 'flex h-[38px] items-center px-[4px] text-[0.78125rem] font-medium text-m-muted'; +const DAY_STATE = 'flex h-[38px] items-center px-[4px] font-medium text-m-muted'; /** The two switches after the times: round, as tall as a time field. */ -const DAY_BUTTON = 'grid h-[30px] w-[30px] flex-none place-items-center rounded-full text-[0.6875rem] font-bold'; +const DAY_BUTTON = 'grid h-[30px] w-[30px] flex-none place-items-center rounded-full font-bold'; const DAY_BUTTON_OFF = 'bg-[color:var(--m-card)] text-m-muted'; const DAY_BUTTON_ON = 'bg-m-act text-m-actfg'; @@ -69,6 +73,7 @@ export function PlContactFields({ placeholder="+49 …" aria-label={t('places.formPhone')} className={BARE_INPUT} + style={FIELD_TEXT} {...NO_AUTOFILL} /> @@ -86,6 +91,7 @@ export function PlContactFields({ placeholder="info@…" aria-label={t('places.formEmail')} className={BARE_INPUT} + style={FIELD_TEXT} {...NO_AUTOFILL} /> @@ -131,9 +137,13 @@ export function PlContactFields({ const allDay = isAllDay(day); return (
- {names[i]} + + {names[i]} + {day.closed || allDay ? ( - {day.closed ? t('places.hoursClosed') : t('places.hoursAllDay')} + + {day.closed ? t('places.hoursClosed') : t('places.hoursAllDay')} + ) : (
@@ -160,6 +170,7 @@ export function PlContactFields({ aria-label={`${longNames[i]}: ${t('places.hoursAllDay')}`} onClick={() => hours.toggleAllDay(i)} className={`${DAY_BUTTON} ${allDay ? DAY_BUTTON_ON : DAY_BUTTON_OFF}`} + style={fs(11, 'caption')} > 24h diff --git a/client/src/mobile/screens/trip/sheets/PlFileAttach.tsx b/client/src/mobile/screens/trip/sheets/PlFileAttach.tsx index cbfee6d89..255ec1f72 100644 --- a/client/src/mobile/screens/trip/sheets/PlFileAttach.tsx +++ b/client/src/mobile/screens/trip/sheets/PlFileAttach.tsx @@ -41,10 +41,10 @@ export default function PlFileAttach({ planner, files, onAdd, onRemove, canAttac {t('files.title')} {(canAttach || canLink) && (
- {canAttach && inputRef.current?.click()} />} {canLink && ( setPicking(v => !v)} pressed={picking} ariaExpanded={picking} /> )} + {canAttach && inputRef.current?.click()} />}
)} {t('places.textsLabel')} - value={shown.field} onChange={setActive} options={tabs.map((tab) => ({ @@ -57,7 +58,9 @@ export function PlPlaceTexts({ aria-label={tab.aria} className={FIELD_AREA_CLS} /> -

{tab.hint}

+

+ {tab.hint} +

))}
diff --git a/client/src/mobile/screens/trip/sheets/PlSheetChrome.tsx b/client/src/mobile/screens/trip/sheets/PlSheetChrome.tsx index 111ebf15b..d85afa869 100644 --- a/client/src/mobile/screens/trip/sheets/PlSheetChrome.tsx +++ b/client/src/mobile/screens/trip/sheets/PlSheetChrome.tsx @@ -3,6 +3,7 @@ import { Plus, Trash2, X } from 'lucide-react' import type { LucideIcon } from 'lucide-react' import MIconBtn from '../../../components/MIconBtn' import { edgeFadeClass, useEdgeFade } from '../../../components/useEdgeFade' +import { fs } from '../../../../components/shared/DialogShell' import { CustomDatePicker } from '../../../../components/shared/CustomDateTimePicker' /** @@ -58,7 +59,7 @@ export function AddFieldButton({ icon: Icon, label, onClick, disabled, pressed, className={`${SELECT_FIELD_CLS} gap-[10px] text-start disabled:opacity-40 ${pressed ? '!border-transparent !bg-m-act text-m-actfg' : 'text-m-faint'}`} >