Skip to content

Commit e7f974e

Browse files
committed
Adds animated resizable to run page
1 parent a681af8 commit e7f974e

3 files changed

Lines changed: 55 additions & 22 deletions

File tree

  • apps/webapp/app
    • components/primitives
    • routes
      • _app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam
      • storybook.animated-panel

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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,30 @@ const ResizableHandle = ({
6969
</PanelResizer>
7070
);
7171

72+
const RESIZABLE_PANEL_ANIMATION = {
73+
easing: "ease-in-out" as const,
74+
duration: 200,
75+
};
76+
77+
const COLLAPSIBLE_HANDLE_CLASSNAME = "transition-opacity duration-200";
78+
79+
function collapsibleHandleClassName(show: boolean) {
80+
return cn(COLLAPSIBLE_HANDLE_CLASSNAME, !show && "pointer-events-none opacity-0");
81+
}
82+
7283
function useFrozenValue<T>(value: T | null | undefined): T | null | undefined {
7384
const ref = useRef(value);
7485
if (value != null) ref.current = value;
7586
return ref.current;
7687
}
7788

78-
export { ResizableHandle, ResizablePanel, ResizablePanelGroup, useFrozenValue };
89+
export {
90+
RESIZABLE_PANEL_ANIMATION,
91+
ResizableHandle,
92+
ResizablePanel,
93+
ResizablePanelGroup,
94+
collapsibleHandleClassName,
95+
useFrozenValue,
96+
};
7997

8098
export type ResizableSnapshot = React.ComponentProps<typeof PanelGroup>["snapshot"];

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam/route.tsx

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,12 @@ import { Paragraph } from "~/components/primitives/Paragraph";
4848
import { Popover, PopoverArrowTrigger, PopoverContent } from "~/components/primitives/Popover";
4949
import * as Property from "~/components/primitives/PropertyTable";
5050
import {
51+
RESIZABLE_PANEL_ANIMATION,
5152
ResizableHandle,
5253
ResizablePanel,
5354
ResizablePanelGroup,
5455
type ResizableSnapshot,
56+
collapsibleHandleClassName,
5557
} from "~/components/primitives/Resizable";
5658
import { ShortcutKey, variants } from "~/components/primitives/ShortcutKey";
5759
import { Slider } from "~/components/primitives/Slider";
@@ -112,7 +114,7 @@ import { SpanView } from "../resources.orgs.$organizationSlug.projects.$projectP
112114

113115
const resizableSettings = {
114116
parent: {
115-
autosaveId: "panel-run-parent",
117+
autosaveId: "panel-run-parent-v2",
116118
handleId: "parent-handle",
117119
main: {
118120
id: "run",
@@ -542,24 +544,36 @@ function TraceView({
542544
treeSnapshot={resizable.tree as ResizableSnapshot}
543545
/>
544546
</ResizablePanel>
545-
<ResizableHandle id={resizableSettings.parent.handleId} />
546-
{selectedSpanId && (
547-
<ResizablePanel
548-
id={resizableSettings.parent.inspector.id}
549-
default={resizableSettings.parent.inspector.default}
550-
min={resizableSettings.parent.inspector.min}
551-
isStaticAtRest
547+
<ResizableHandle
548+
id={resizableSettings.parent.handleId}
549+
className={collapsibleHandleClassName(!!selectedSpanId)}
550+
/>
551+
<ResizablePanel
552+
id={resizableSettings.parent.inspector.id}
553+
default={resizableSettings.parent.inspector.default}
554+
min={resizableSettings.parent.inspector.min}
555+
className="overflow-hidden"
556+
collapsible
557+
collapsed={!selectedSpanId}
558+
onCollapseChange={() => {}}
559+
collapsedSize="0px"
560+
collapseAnimation={RESIZABLE_PANEL_ANIMATION}
561+
>
562+
<div
563+
className="h-full"
564+
style={{ minWidth: parseInt(resizableSettings.parent.inspector.min) }}
552565
>
553-
{" "}
554-
<SpanView
555-
runParam={run.friendlyId}
556-
spanId={selectedSpanId}
557-
spanOverrides={spanOverrides as SpanOverride | undefined}
558-
closePanel={() => replaceSearchParam("span")}
559-
linkedRunId={selectedSpanLinkedRunId}
560-
/>
561-
</ResizablePanel>
562-
)}
566+
{selectedSpanId && (
567+
<SpanView
568+
runParam={run.friendlyId}
569+
spanId={selectedSpanId}
570+
spanOverrides={spanOverrides as SpanOverride | undefined}
571+
closePanel={() => replaceSearchParam("span")}
572+
linkedRunId={selectedSpanLinkedRunId}
573+
/>
574+
)}
575+
</div>
576+
</ResizablePanel>
563577
</ResizablePanelGroup>
564578
</div>
565579
);

apps/webapp/app/routes/storybook.animated-panel/route.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ import { Header2 } from "~/components/primitives/Headers";
55
import { Paragraph } from "~/components/primitives/Paragraph";
66
import * as Property from "~/components/primitives/PropertyTable";
77
import {
8+
RESIZABLE_PANEL_ANIMATION,
89
ResizableHandle,
910
ResizablePanel,
1011
ResizablePanelGroup,
12+
collapsibleHandleClassName,
1113
useFrozenValue,
1214
} from "~/components/primitives/Resizable";
1315
import {
@@ -18,7 +20,6 @@ import {
1820
TableHeaderCell,
1921
TableRow,
2022
} from "~/components/primitives/Table";
21-
import { cn } from "~/utils/cn";
2223

2324
type DemoItem = {
2425
id: string;
@@ -145,7 +146,7 @@ export default function Story() {
145146
</ResizablePanel>
146147
<ResizableHandle
147148
id="animated-panel-handle"
148-
className={cn("transition-opacity duration-200", !show && "pointer-events-none opacity-0")}
149+
className={collapsibleHandleClassName(show)}
149150
/>
150151
<ResizablePanel
151152
id="animated-panel-detail"
@@ -157,7 +158,7 @@ export default function Story() {
157158
collapsed={!show}
158159
onCollapseChange={() => {}}
159160
collapsedSize="0px"
160-
collapseAnimation={{ easing: "ease-in-out", duration: 200 }}
161+
collapseAnimation={RESIZABLE_PANEL_ANIMATION}
161162
>
162163
<div className="h-full" style={{ minWidth: 280 }}>
163164
{displayItem && (

0 commit comments

Comments
 (0)