diff --git a/client/src/components/shared/CustomTimePicker.tsx b/client/src/components/shared/CustomTimePicker.tsx index 1b64e7519..c7b6d962c 100644 --- a/client/src/components/shared/CustomTimePicker.tsx +++ b/client/src/components/shared/CustomTimePicker.tsx @@ -1,9 +1,14 @@ import React, { useState, useRef, useEffect } from 'react' import { createPortal } from 'react-dom' -import { Clock, ChevronUp, ChevronDown } from 'lucide-react' +import { Clock } from 'lucide-react' import { useSettingsStore } from '../../store/settingsStore' import { formatClockTime, parseMeridiemTime } from '../../utils/formatters' import { useAnchoredPosition } from '../../hooks/useAnchoredPosition' +import { TimeSpinnerColumn } from './TimeSpinnerColumn' +import { spinnerButtonStyle } from './timeSpinnerStyle' + +// The hour and minute boxes, wide enough for two digits that do not jump as they change. +const DIGITS: React.CSSProperties = { width: 44, fontSize: 'calc(22px * var(--fs-scale-title, 1))', fontVariantNumeric: 'tabular-nums' } interface CustomTimePickerProps { value: string @@ -72,10 +77,9 @@ export default function CustomTimePicker({ value, onChange, placeholder = '00:00 update(newH, newM) } - const btnStyle: React.CSSProperties = { - background: 'none', border: 'none', cursor: 'pointer', padding: 2, - color: 'var(--text-faint)', display: 'flex', borderRadius: 4, - transition: 'color 0.15s', + const toggleMeridiem = () => { + if (hour === null) return + if (hour < 12) update(hour + 12, minute ?? 0); else update(hour - 12, minute ?? 0) } const handleInput = (e: React.ChangeEvent) => { @@ -179,78 +183,29 @@ export default function CustomTimePicker({ value, onChange, placeholder = '00:00 backdropFilter: 'blur(24px)', WebkitBackdropFilter: 'blur(24px)', }}> {/* Hours */} -
- -
- {hour !== null ? (is12h ? String(hour === 0 ? 12 : hour > 12 ? hour - 12 : hour) : String(hour).padStart(2, '0')) : '--'} -
- -
+ + {hour !== null ? (is12h ? String(hour === 0 ? 12 : hour > 12 ? hour - 12 : hour) : String(hour).padStart(2, '0')) : '--'} + : {/* Minutes */} -
- -
- {minute !== null ? String(minute).padStart(2, '0') : '--'} -
- -
+ + {minute !== null ? String(minute).padStart(2, '0') : '--'} + {/* AM/PM Toggle */} {is12h && hour !== null && ( -
- -
- {hour >= 12 ? 'PM' : 'AM'} -
- -
+ + {hour >= 12 ? 'PM' : 'AM'} + )} {/* Clear */} {value && ( + ); +} diff --git a/client/src/components/shared/timeSpinnerStyle.ts b/client/src/components/shared/timeSpinnerStyle.ts new file mode 100644 index 000000000..0de2bc797 --- /dev/null +++ b/client/src/components/shared/timeSpinnerStyle.ts @@ -0,0 +1,13 @@ +import type { CSSProperties } from 'react'; + +/** The look of the time picker's small chevron and clear buttons. */ +export const spinnerButtonStyle: CSSProperties = { + background: 'none', + border: 'none', + cursor: 'pointer', + padding: 2, + color: 'var(--text-faint)', + display: 'flex', + borderRadius: 4, + transition: 'color 0.15s', +};