TimeRangeInput: minimal width, remove button overlays the corner

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ilya Mukhortov 2026-10-24 08:07:36 +10:00
parent c099858ad7
commit 835fa7bd99
1 changed files with 7 additions and 5 deletions

View File

@ -20,14 +20,15 @@ export function TimeRangeInput({
className?: string className?: string
}) { }) {
const invalid = Boolean(value.from && value.to && value.to <= value.from) const invalid = Boolean(value.from && value.to && value.to <= value.from)
// Ширина ровно под «ЧЧ:ММ»: моноширинный шрифт, без иконки часов и внутренних отступов браузера.
const input = const input =
"h-7 w-[4.6rem] rounded-md bg-transparent px-1 font-mono text-xs tabular outline-none focus:bg-accent/60 [&::-webkit-calendar-picker-indicator]:hidden" "h-6 w-[calc(5ch+12px)] rounded bg-transparent px-[3px] font-mono text-xs tabular outline-none focus:bg-accent/60 [&::-webkit-calendar-picker-indicator]:hidden [&::-webkit-datetime-edit]:p-0 [&::-webkit-datetime-edit-fields-wrapper]:p-0"
return ( return (
<div <div
aria-invalid={invalid} aria-invalid={invalid}
className={cn( className={cn(
"group flex items-center rounded-lg border bg-card pr-0.5 transition focus-within:border-primary/50", "group relative inline-flex w-fit items-center rounded-md border bg-card px-0.5 transition focus-within:border-primary/50",
invalid && "border-destructive/60 bg-destructive/5", invalid && "border-destructive/60 bg-destructive/5",
className, className,
)} )}
@ -39,7 +40,7 @@ export function TimeRangeInput({
onChange={(e) => onChange({ ...value, from: e.target.value })} onChange={(e) => onChange({ ...value, from: e.target.value })}
className={input} className={input}
/> />
<span className="text-xs text-muted-foreground">–</span> <span className="text-[11px] text-muted-foreground">–</span>
<input <input
type="time" type="time"
aria-label="По" aria-label="По"
@ -52,9 +53,10 @@ export function TimeRangeInput({
type="button" type="button"
aria-label="Удалить время" aria-label="Удалить время"
onClick={onRemove} onClick={onRemove}
className="grid size-5 place-items-center rounded text-muted-foreground opacity-0 transition group-hover:opacity-100 hover:bg-muted hover:text-destructive focus-visible:opacity-100" // Крестик не занимает места: появляется поверх правого верхнего угла при наведении.
className="absolute -top-1.5 -right-1.5 grid size-4 place-items-center rounded-full border bg-card text-muted-foreground opacity-0 shadow-xs transition group-hover:opacity-100 hover:text-destructive focus-visible:opacity-100"
> >
<XIcon className="size-3" /> <XIcon className="size-2.5" />
</button> </button>
)} )}
</div> </div>