TimeRangeInput: minimal width, remove button overlays the corner
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
c099858ad7
commit
835fa7bd99
|
|
@ -20,14 +20,15 @@ export function TimeRangeInput({
|
|||
className?: string
|
||||
}) {
|
||||
const invalid = Boolean(value.from && value.to && value.to <= value.from)
|
||||
// Ширина ровно под «ЧЧ:ММ»: моноширинный шрифт, без иконки часов и внутренних отступов браузера.
|
||||
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 (
|
||||
<div
|
||||
aria-invalid={invalid}
|
||||
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",
|
||||
className,
|
||||
)}
|
||||
|
|
@ -39,7 +40,7 @@ export function TimeRangeInput({
|
|||
onChange={(e) => onChange({ ...value, from: e.target.value })}
|
||||
className={input}
|
||||
/>
|
||||
<span className="text-xs text-muted-foreground">–</span>
|
||||
<span className="text-[11px] text-muted-foreground">–</span>
|
||||
<input
|
||||
type="time"
|
||||
aria-label="По"
|
||||
|
|
@ -52,9 +53,10 @@ export function TimeRangeInput({
|
|||
type="button"
|
||||
aria-label="Удалить время"
|
||||
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>
|
||||
)}
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue