Skip to content

Commit ab06a33

Browse files
Move error into picker (#2780)
* Move error into picker * Use flex avoid negative margin * Fix border hover * Fix missing border and today dot error colour
1 parent ae7a989 commit ab06a33

File tree

3 files changed

+35
-25
lines changed

3 files changed

+35
-25
lines changed

app/components/form/fields/DateTimeRangePicker.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export function DateTimeRangePicker({
116116
return (
117117
<form className="flex">
118118
<Listbox
119-
className="z-10 w-[10rem] border-r border-r-default [&_button]:!rounded-r-none [&_button]:!border-r-0"
119+
className="z-10 w-[10rem] [&_button]:!rounded-r-none [&_button]:!border-r-0"
120120
name="preset"
121121
selected={preset}
122122
aria-label="Choose a time range preset"
@@ -140,7 +140,7 @@ export function DateTimeRangePicker({
140140
minValue={minValue}
141141
maxValue={maxValue}
142142
hideTimeZone
143-
className="[&_.rounded-l]:!rounded-l-none [&_button]:!border-l-0"
143+
className="[&_.rounded-l]:!rounded-l-none"
144144
/>
145145
</div>
146146
</form>

app/ui/lib/CalendarCell.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,14 @@ export function CalendarCell({ state, date }: CalendarCellProps) {
121121
</div>
122122

123123
{cellIsToday && (
124-
<div className="absolute bottom-[5px] left-1/2 h-[3px] w-[3px] -translate-x-1/2 rounded-full bg-[var(--content-accent-tertiary)] content-['']" />
124+
<div
125+
className={cn(
126+
"absolute bottom-[5px] left-1/2 h-[3px] w-[3px] -translate-x-1/2 rounded-full content-['']",
127+
isInvalid
128+
? 'bg-[var(--content-error-tertiary)]'
129+
: 'bg-[var(--content-accent-tertiary)]'
130+
)}
131+
/>
125132
)}
126133
</div>
127134
</td>

app/ui/lib/DateRangePicker.tsx

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export function DateRangePicker(props: DateRangePickerProps) {
6565
state.isOpen && 'z-10 ring-2',
6666
'relative flex h-11 items-center rounded-l rounded-r border text-sans-md border-default focus-within:ring-2 hover:border-raise focus:z-10',
6767
state.isInvalid
68-
? 'focus-error border-error ring-error-secondary'
68+
? 'focus-error border-error ring-error-secondary hover:border-error'
6969
: 'border-default ring-accent-secondary'
7070
)}
7171
>
@@ -82,32 +82,35 @@ export function DateRangePicker(props: DateRangePickerProps) {
8282
</div>
8383
</button>
8484
</div>
85-
{state.isInvalid && (
86-
<p {...errorMessageProps} className="py-2 text-sans-md text-error">
87-
Date range is invalid
88-
</p>
89-
)}
9085
{state.isOpen && (
9186
<Popover triggerRef={ref} state={state} placement="bottom start">
9287
<Dialog {...dialogProps}>
9388
<RangeCalendar {...calendarProps} />
94-
<div className="flex items-center space-x-2 border-t p-4 border-t-secondary">
95-
<TimeField
96-
label="Start time"
97-
value={state.timeRange?.start || null}
98-
onChange={(v) => state.setTime('start', v)}
99-
hourCycle={24}
100-
className="shrink-0 grow basis-0"
101-
/>
102-
<div className="text-quaternary"></div>
103-
<TimeField
104-
label="End time"
105-
value={state.timeRange?.end || null}
106-
onChange={(v) => state.setTime('end', v)}
107-
hourCycle={24}
108-
className="shrink-0 grow basis-0"
109-
/>
89+
<div className="flex flex-col items-center gap-3 border-t p-4 border-t-secondary">
90+
<div className="flex w-full items-center space-x-2">
91+
<TimeField
92+
label="Start time"
93+
value={state.timeRange?.start || null}
94+
onChange={(v) => state.setTime('start', v)}
95+
hourCycle={24}
96+
className="shrink-0 grow basis-0"
97+
/>
98+
<div className="text-quaternary"></div>
99+
<TimeField
100+
label="End time"
101+
value={state.timeRange?.end || null}
102+
onChange={(v) => state.setTime('end', v)}
103+
hourCycle={24}
104+
className="shrink-0 grow basis-0"
105+
/>
106+
</div>
107+
{state.isInvalid && (
108+
<p {...errorMessageProps} className="text-sans-md text-error">
109+
Date range is invalid
110+
</p>
111+
)}
110112
</div>
113+
<div className="flex items-center justify-center space-x-2 px-4 border-t-secondary"></div>
111114
</Dialog>
112115
</Popover>
113116
)}

0 commit comments

Comments
 (0)