mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-20 02:56:10 +00:00
fix(places): settle the gates for the place form rework
The text tabs name their field type for the switch, so it type-checks. The colour field's sliders run left to right in every language and say so with dir=ltr and a logical inset. The new phone fields take their sizes from the type tiers or fs() instead of rem literals, the category field builds its icon as an element, and the ESLint and theme baselines come down to what the tree now holds. The tests follow the tabs (only the open tab's field and formatting bar are shown), the category list and the files row, whose link button keeps its place before attach.
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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')
|
||||
})
|
||||
|
||||
|
||||
@@ -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"
|
||||
>
|
||||
<Landmark size={13} strokeWidth={2.2} className="flex-none text-m-muted" />
|
||||
<span className="min-w-0 flex-1 truncate font-geist text-[0.75rem] font-semibold text-m-ink">{t('places.details.title')}</span>
|
||||
<span className="min-w-0 flex-1 truncate font-geist text-caption font-semibold text-m-ink">{t('places.details.title')}</span>
|
||||
<ChevronDown
|
||||
size={13}
|
||||
strokeWidth={2.2}
|
||||
|
||||
@@ -2448,8 +2448,9 @@ describe('PlaceFormModal on the dialog frame', () => {
|
||||
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(<PlaceFormModal {...defaultProps} />);
|
||||
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(<PlaceFormModal {...defaultProps} onSave={onSave} place={place} assignmentId={123} dayAssignments={[assignment]} />);
|
||||
|
||||
// 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);
|
||||
|
||||
@@ -58,7 +58,7 @@ export function PlaceFormTexts({
|
||||
|
||||
return (
|
||||
<div className={PANEL}>
|
||||
<Segmented
|
||||
<Segmented<PlaceTextField>
|
||||
fill
|
||||
value={shown.field}
|
||||
onChange={setActive}
|
||||
|
||||
@@ -97,6 +97,8 @@ export function TagColorField({
|
||||
<div className="flex w-full flex-col gap-2.5">
|
||||
<div
|
||||
role="slider"
|
||||
// The gradient runs left to right in every language; so does the pick on it.
|
||||
dir="ltr"
|
||||
tabIndex={0}
|
||||
aria-label={t('places.tagColorCustom')}
|
||||
aria-valuetext={hex}
|
||||
@@ -111,10 +113,15 @@ export function TagColorField({
|
||||
return { h: hsv.h, s: p.x, v: 1 - p.y };
|
||||
})}
|
||||
>
|
||||
<span className={THUMB} style={{ left: `${hsv.s * 100}%`, top: `${(1 - hsv.v) * 100}%`, background: hex }} />
|
||||
<span
|
||||
className={THUMB}
|
||||
style={{ insetInlineStart: `${hsv.s * 100}%`, top: `${(1 - hsv.v) * 100}%`, background: hex }}
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
role="slider"
|
||||
// The gradient runs left to right in every language; so does the pick on it.
|
||||
dir="ltr"
|
||||
tabIndex={0}
|
||||
aria-label={t('places.tagColorHue')}
|
||||
aria-valuenow={Math.round(hsv.h)}
|
||||
@@ -132,7 +139,10 @@ export function TagColorField({
|
||||
}}
|
||||
{...drag((e) => ({ ...hsv, h: at(e).x * 359.9 }))}
|
||||
>
|
||||
<span className={`${THUMB} top-1/2`} style={{ left: `${(hsv.h / 360) * 100}%`, background: hueHex(hsv.h) }} />
|
||||
<span
|
||||
className={`${THUMB} top-1/2`}
|
||||
style={{ insetInlineStart: `${(hsv.h / 360) * 100}%`, background: hueHex(hsv.h) }}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<span
|
||||
|
||||
@@ -67,7 +67,7 @@ describe('typing and taking over (#2472)', () => {
|
||||
// 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')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -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')}
|
||||
/>
|
||||
</label>
|
||||
|
||||
|
||||
@@ -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 (
|
||||
<div>
|
||||
@@ -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 size={15} strokeWidth={2} className="flex-none" style={current?.color ? { color: current.color } : undefined} />
|
||||
{currentIcon}
|
||||
<span className={`${ROW_TEXT} font-medium ${current ? 'text-m-ink' : 'text-m-faint'}`}>
|
||||
{current ? current.name : t('places.noCategory')}
|
||||
</span>
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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, string | number>) => 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}
|
||||
/>
|
||||
</label>
|
||||
@@ -86,6 +91,7 @@ export function PlContactFields({
|
||||
placeholder="info@…"
|
||||
aria-label={t('places.formEmail')}
|
||||
className={BARE_INPUT}
|
||||
style={FIELD_TEXT}
|
||||
{...NO_AUTOFILL}
|
||||
/>
|
||||
</label>
|
||||
@@ -131,9 +137,13 @@ export function PlContactFields({
|
||||
const allDay = isAllDay(day);
|
||||
return (
|
||||
<div key={i} className={DAY_ROW}>
|
||||
<span className="text-[0.71875rem] font-semibold text-m-ink">{names[i]}</span>
|
||||
<span className="font-semibold text-m-ink" style={fs(11.5, 'caption')}>
|
||||
{names[i]}
|
||||
</span>
|
||||
{day.closed || allDay ? (
|
||||
<span className={DAY_STATE}>{day.closed ? t('places.hoursClosed') : t('places.hoursAllDay')}</span>
|
||||
<span className={DAY_STATE} style={fs(12.5, 'body')}>
|
||||
{day.closed ? t('places.hoursClosed') : t('places.hoursAllDay')}
|
||||
</span>
|
||||
) : (
|
||||
<div className="flex min-w-0 items-center gap-[3px]">
|
||||
<div className="min-w-0 flex-1">
|
||||
@@ -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
|
||||
</button>
|
||||
|
||||
@@ -41,10 +41,10 @@ export default function PlFileAttach({ planner, files, onAdd, onRemove, canAttac
|
||||
<Eyebrow className="mb-[5px] mt-3 uppercase">{t('files.title')}</Eyebrow>
|
||||
{(canAttach || canLink) && (
|
||||
<div className={`grid gap-2 ${canAttach && canLink ? 'grid-cols-2' : 'grid-cols-1'}`}>
|
||||
{canAttach && <AddFieldButton icon={Paperclip} label={t('files.attach')} onClick={() => inputRef.current?.click()} />}
|
||||
{canLink && (
|
||||
<AddFieldButton icon={Link2} label={t('files.link')} onClick={() => setPicking(v => !v)} pressed={picking} ariaExpanded={picking} />
|
||||
)}
|
||||
{canAttach && <AddFieldButton icon={Paperclip} label={t('files.attach')} onClick={() => inputRef.current?.click()} />}
|
||||
</div>
|
||||
)}
|
||||
<input
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { usePlaceTextTabs, type PlaceTextField } from '../../../../components/Planner/usePlaceTextTabs';
|
||||
import { fs } from '../../../../components/shared/DialogShell';
|
||||
import MSegmented from '../../../components/MSegmented';
|
||||
import { Eyebrow, FIELD_AREA_CLS } from './PlSheetChrome';
|
||||
|
||||
@@ -34,7 +35,7 @@ export function PlPlaceTexts({
|
||||
return (
|
||||
<div className="flex flex-col gap-2">
|
||||
<Eyebrow className="-mb-[3px] mt-3 uppercase">{t('places.textsLabel')}</Eyebrow>
|
||||
<MSegmented
|
||||
<MSegmented<PlaceTextField>
|
||||
value={shown.field}
|
||||
onChange={setActive}
|
||||
options={tabs.map((tab) => ({
|
||||
@@ -57,7 +58,9 @@ export function PlPlaceTexts({
|
||||
aria-label={tab.aria}
|
||||
className={FIELD_AREA_CLS}
|
||||
/>
|
||||
<p className="m-0 mt-[5px] px-[6px] font-geist text-[0.65625rem] leading-snug text-m-faint">{tab.hint}</p>
|
||||
<p className="m-0 mt-[5px] px-[6px] font-geist leading-snug text-m-faint" style={fs(10.5, 'caption')}>
|
||||
{tab.hint}
|
||||
</p>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -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'}`}
|
||||
>
|
||||
<Icon size={14} strokeWidth={2} aria-hidden="true" className="flex-none" />
|
||||
<span className="min-w-0 flex-1 truncate text-[0.84375rem] font-medium">{label}</span>
|
||||
<span className="min-w-0 flex-1 truncate font-medium" style={fs(13.5, 'body')}>{label}</span>
|
||||
<Plus size={14} strokeWidth={2.2} aria-hidden="true" className="flex-none" />
|
||||
</button>
|
||||
)
|
||||
|
||||
@@ -20,14 +20,14 @@ const CHIP =
|
||||
const CHIP_OFF = 'border-[color:var(--m-rowbr)] bg-[color:var(--m-card)]';
|
||||
const DOT_BUTTON = 'grid h-[30px] w-[26px] flex-none place-items-center ps-[3px]';
|
||||
const DOT = 'h-[12px] w-[12px] rounded-full ring-1 ring-inset ring-[color:var(--m-rowbr)]';
|
||||
const NAME_BUTTON = 'inline-flex h-full min-w-0 items-center gap-[5px] text-[0.75rem] font-semibold';
|
||||
const NAME_BUTTON = 'inline-flex h-full min-w-0 items-center gap-[5px] text-caption font-semibold';
|
||||
/** The tick of a picked tag, in a round white badge. */
|
||||
const TICK =
|
||||
'me-[3px] grid h-[22px] w-[22px] flex-none place-items-center rounded-full bg-[color:var(--m-card)] shadow-sm';
|
||||
/** Where a new tag is typed: the rest of the field's line, at least wide enough for a short name. */
|
||||
const NEW_TAG = 'flex h-[30px] min-w-[9rem] flex-1 items-center gap-[6px]';
|
||||
const NEW_INPUT =
|
||||
'min-w-0 flex-1 bg-transparent font-[inherit] text-[0.75rem] font-semibold text-m-ink outline-none placeholder:font-medium placeholder:text-m-faint';
|
||||
'min-w-0 flex-1 bg-transparent font-[inherit] text-caption font-semibold text-m-ink outline-none placeholder:font-medium placeholder:text-m-faint';
|
||||
const ADD_BUTTON = 'grid h-[30px] w-[30px] flex-none place-items-center rounded-full';
|
||||
/** The palette laid into the sheet under the field, in the sheet's own surface. */
|
||||
const PALETTE =
|
||||
|
||||
@@ -77,7 +77,7 @@ describe('MPlaceEditSheet', () => {
|
||||
expect(screen.getByPlaceholderText('places.formLatLabel')).toHaveValue('35.7148')
|
||||
expect(screen.getByPlaceholderText('places.formLngLabel')).toHaveValue('139.7967')
|
||||
expect(screen.getByPlaceholderText('https://')).toHaveValue('https://senso-ji.jp')
|
||||
expect(screen.getByRole('button', { name: /Food/ }).className).toContain('bg-m-act')
|
||||
expect(screen.getByRole('button', { name: /^places.formCategory:/ })).toHaveAccessibleName('places.formCategory: Food')
|
||||
expect(submit()).toHaveTextContent('common.save')
|
||||
})
|
||||
|
||||
@@ -135,6 +135,7 @@ describe('MPlaceEditSheet', () => {
|
||||
fireEvent.change(nameField(), { target: { value: 'Nakamise' } })
|
||||
fireEvent.change(screen.getByPlaceholderText('places.formLatLabel'), { target: { value: '35.71' } })
|
||||
fireEvent.change(screen.getByPlaceholderText('places.formLngLabel'), { target: { value: '139.79' } })
|
||||
fireEvent.click(screen.getByRole('button', { name: /^places.formCategory:/ }))
|
||||
fireEvent.click(screen.getByRole('button', { name: /Food/ }))
|
||||
fireEvent.click(submit())
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ describe('PlCategoryPicker', () => {
|
||||
setup({}, '4')
|
||||
expect(field()).toHaveAccessibleName('places.formCategory: Museums')
|
||||
openList()
|
||||
expect(screen.getByRole('button', { name: /Museums/ })).toHaveAttribute('aria-pressed', 'true')
|
||||
expect(screen.getByRole('button', { name: 'Museums' })).toHaveAttribute('aria-pressed', 'true')
|
||||
expect(screen.getByRole('button', { name: /^places.noCategory$/ })).toHaveAttribute('aria-pressed', 'false')
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user