Skip to content

Commit 02a9c16

Browse files
committed
Show a tooltip when clearing
1 parent db8e57d commit 02a9c16

1 file changed

Lines changed: 33 additions & 14 deletions

File tree

apps/webapp/app/components/primitives/DateTimePicker.tsx

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
"use client";
22

33
import * as React from "react";
4-
import { ChevronDownIcon } from "@heroicons/react/20/solid";
4+
import { ChevronUpDownIcon } from "@heroicons/react/20/solid";
55
import { format } from "date-fns";
66
import { Calendar } from "./Calendar";
77
import { Popover, PopoverContent, PopoverTrigger } from "./Popover";
88
import { Button } from "./Buttons";
99
import { cn } from "~/utils/cn";
10+
import { SimpleTooltip } from "./Tooltip";
11+
import { XIcon } from "lucide-react";
1012

1113
type DateTimePickerProps = {
1214
label: string;
@@ -77,12 +79,12 @@ export function DateTimePicker({
7779
<button
7880
type="button"
7981
className={cn(
80-
"flex h-6 items-center justify-between gap-2 rounded border border-charcoal-600 bg-charcoal-750 px-2 text-xs tabular-nums transition hover:border-charcoal-500",
82+
"flex h-[1.8rem] items-center justify-between gap-2 whitespace-nowrap rounded border border-charcoal-600 bg-charcoal-750 px-2 text-xs tabular-nums transition hover:border-charcoal-500",
8183
value ? "text-text-bright" : "text-text-dimmed"
8284
)}
8385
>
8486
{value ? format(value, "yyyy/MM/dd") : "Select date"}
85-
<ChevronDownIcon className="size-4 text-text-dimmed" />
87+
<ChevronUpDownIcon className="size-3.5 text-text-dimmed" />
8688
</button>
8789
</PopoverTrigger>
8890
<PopoverContent className="w-auto p-0" align="start">
@@ -100,23 +102,40 @@ export function DateTimePicker({
100102
value={value ? timeValue : ""}
101103
onChange={handleTimeChange}
102104
className={cn(
103-
"h-6 rounded border border-charcoal-600 bg-charcoal-750 px-2 text-xs tabular-nums transition hover:border-charcoal-500",
105+
"h-[1.8rem] rounded border border-charcoal-600 bg-charcoal-750 px-2 text-xs tabular-nums transition hover:border-charcoal-500",
104106
"text-text-bright placeholder:text-text-dimmed",
105107
"focus:border-charcoal-500 focus:outline-none",
106108
"[&::-webkit-calendar-picker-indicator]:hidden [&::-webkit-calendar-picker-indicator]:appearance-none"
107109
)}
108110
aria-label={`${label} time`}
109111
/>
110-
{showNowButton && (
111-
<Button type="button" variant="tertiary/small" onClick={handleNowClick}>
112-
Now
113-
</Button>
114-
)}
115-
{showClearButton && (
116-
<Button type="button" variant="tertiary/small" onClick={handleClearClick}>
117-
Clear
118-
</Button>
119-
)}
112+
<div className="flex w-full items-center justify-between gap-1">
113+
{showNowButton && (
114+
<Button
115+
type="button"
116+
variant="secondary/small"
117+
className="h-[1.8rem]"
118+
onClick={handleNowClick}
119+
>
120+
Now
121+
</Button>
122+
)}
123+
{showClearButton && (
124+
<SimpleTooltip
125+
button={
126+
<button
127+
type="button"
128+
className="flex h-[1.8rem] items-center justify-center px-1 text-text-dimmed transition hover:text-text-bright"
129+
onClick={handleClearClick}
130+
>
131+
<XIcon className="size-3.5" />
132+
</button>
133+
}
134+
content="Clear"
135+
disableHoverableContent
136+
/>
137+
)}
138+
</div>
120139
</div>
121140
);
122141
}

0 commit comments

Comments
 (0)