Skip to content

Commit 76403c7

Browse files
committed
Fixed history popover scrolling + improved the styling
1 parent b5e0bf2 commit 76403c7

1 file changed

Lines changed: 31 additions & 20 deletions

File tree

  • apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.query

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.query/QueryHistoryPopover.tsx

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import { useState } from "react";
22
import { ClockRotateLeftIcon } from "~/assets/icons/ClockRotateLeftIcon";
33
import { Button } from "~/components/primitives/Buttons";
4-
import { Popover, PopoverContent, PopoverTrigger } from "~/components/primitives/Popover";
4+
import { Popover, PopoverTrigger } from "~/components/primitives/Popover";
5+
import * as PopoverPrimitive from "@radix-ui/react-popover";
56
import type { QueryHistoryItem } from "~/presenters/v3/QueryPresenter.server";
67
import { timeFilterRenderValues } from "~/components/runs/v3/SharedFilters";
8+
import { ChevronUpDownIcon } from "@heroicons/react/20/solid";
9+
import { cn } from "~/utils/cn";
710

811
const SQL_KEYWORDS = [
912
"SELECT",
@@ -91,23 +94,32 @@ export function QueryHistoryPopover({
9194
<PopoverTrigger asChild>
9295
<Button
9396
type="button"
94-
variant="tertiary/small"
97+
variant="secondary/small"
9598
LeadingIcon={ClockRotateLeftIcon}
99+
leadingIconClassName="-mr-1.5"
100+
TrailingIcon={ChevronUpDownIcon}
96101
disabled={history.length === 0}
97102
>
98103
History
99104
</Button>
100105
</PopoverTrigger>
101-
<PopoverContent
102-
className="w-[400px] min-w-0 overflow-hidden p-0"
106+
<PopoverPrimitive.Content
107+
className={cn(
108+
"z-50 w-[400px] min-w-0 overflow-hidden rounded border border-charcoal-700 bg-background-bright p-0 shadow-md outline-none animate-in data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2"
109+
)}
103110
align="start"
104111
sideOffset={6}
112+
style={{ maxHeight: "var(--radix-popover-content-available-height)" }}
105113
>
106-
<div className="max-h-80 overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-charcoal-600">
114+
<div className="max-h-[40rem] overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-charcoal-600">
107115
<div className="p-1">
108116
{history.map((item) => {
109117
// Format time filter display
110-
const { valueLabel } = timeFilterRenderValues({ period: item.filterPeriod ?? undefined, from: item.filterFrom ?? undefined, to: item.filterTo ?? undefined });
118+
const { valueLabel } = timeFilterRenderValues({
119+
period: item.filterPeriod ?? undefined,
120+
from: item.filterFrom ?? undefined,
121+
to: item.filterTo ?? undefined,
122+
});
111123

112124
return (
113125
<button
@@ -117,21 +129,16 @@ export function QueryHistoryPopover({
117129
onQuerySelected(item);
118130
setIsOpen(false);
119131
}}
120-
className="flex w-full items-center gap-2 rounded-sm px-2 py-2 outline-none transition-colors focus-custom hover:bg-charcoal-900"
132+
className="flex w-full flex-col gap-1 rounded-sm px-2 py-2 outline-none transition-colors focus-custom hover:bg-charcoal-750"
121133
>
122-
<div className="flex flex-1 flex-col items-start gap-0.5 overflow-hidden">
134+
<div className="flex w-full flex-col items-start">
123135
{item.title ? (
124-
<>
125-
<p className="w-full truncate text-left text-sm font-medium text-text-bright">
126-
{item.title}
127-
</p>
128-
<p className="line-clamp-4 w-full whitespace-pre-wrap text-left font-mono text-xs text-text-dimmed">
129-
{highlightSQL(item.query)}
130-
</p>
131-
</>
136+
<p className="mb-1 truncate text-left text-sm font-medium text-text-bright">
137+
{item.title}
138+
</p>
132139
) : (
133-
<p className="line-clamp-4 w-full whitespace-pre-wrap text-left font-mono text-xs text-[#9b99ff]">
134-
{highlightSQL(item.query)}
140+
<p className="mb-1 truncate text-left font-mono text-xs text-text-bright">
141+
{item.query.split("\n")[0].slice(0, 60)}
135142
</p>
136143
)}
137144
<div className="flex items-center gap-1.5 text-xs text-text-dimmed">
@@ -140,13 +147,17 @@ export function QueryHistoryPopover({
140147
{item.userName && <span>· {item.userName}</span>}
141148
</div>
142149
</div>
150+
<div className="w-full border-l-2 border-charcoal-600 pl-2.5">
151+
<p className="line-clamp-4 w-full whitespace-pre-wrap text-left font-mono text-xs text-text-dimmed">
152+
{highlightSQL(item.query)}
153+
</p>
154+
</div>
143155
</button>
144156
);
145157
})}
146158
</div>
147159
</div>
148-
</PopoverContent>
160+
</PopoverPrimitive.Content>
149161
</Popover>
150162
);
151163
}
152-

0 commit comments

Comments
 (0)