Skip to content

Commit acb0cc1

Browse files
committed
[INSIGHT-508] Fix Insight blueprint card alignment + Set max height on blueprint playground
1 parent d8b4e09 commit acb0cc1

File tree

2 files changed

+42
-74
lines changed

2 files changed

+42
-74
lines changed

apps/dashboard/src/app/team/[team_slug]/[project_slug]/insight/[blueprint_slug]/blueprint-playground.client.tsx

Lines changed: 27 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"use client";
22

33
import { SingleNetworkSelector } from "@/components/blocks/NetworkSelectors";
4-
import { useHeightObserver } from "@/components/ui/DynamicHeight";
54
import { Spinner } from "@/components/ui/Spinner/Spinner";
65
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
76
import { Badge } from "@/components/ui/badge";
@@ -28,6 +27,7 @@ import Link from "next/link";
2827
import { useEffect, useMemo, useState } from "react";
2928
import { type UseFormReturn, useForm } from "react-hook-form";
3029
import { z } from "zod";
30+
import { ScrollShadow } from "../../../../../../@/components/ui/ScrollShadow/ScrollShadow";
3131
import { useTrack } from "../../../../../../hooks/analytics/useTrack";
3232
import { getVercelEnv } from "../../../../../../lib/vercel-utils";
3333
import type { BlueprintParameter, BlueprintPathMetadata } from "../utils";
@@ -195,11 +195,6 @@ export function BlueprintPlaygroundUI(props: {
195195
props.onRun(url);
196196
}
197197

198-
// This allows us to always limit the grid height to whatever is the height of left section on desktop
199-
// so that entire left section is always visible, but the right section has a scrollbar if it exceeds the height of left section
200-
const { height, elementRef: leftSectionRef } = useHeightObserver();
201-
const isMobile = useIsMobileViewport();
202-
203198
return (
204199
<Form {...form}>
205200
<form onSubmit={form.handleSubmit(onSubmit)}>
@@ -240,10 +235,7 @@ export function BlueprintPlaygroundUI(props: {
240235
clientId={props.clientId}
241236
/>
242237
<div className="grid grow grid-cols-1 lg:grid-cols-2">
243-
<div
244-
className="flex grow flex-col max-sm:border-b lg:border-r"
245-
ref={leftSectionRef}
246-
>
238+
<div className="flex max-h-[500px] grow flex-col max-sm:border-b lg:max-h-[740px] lg:border-r">
247239
<RequestConfigSection
248240
domain={props.domain}
249241
parameters={parameters}
@@ -253,12 +245,7 @@ export function BlueprintPlaygroundUI(props: {
253245
/>
254246
</div>
255247

256-
<div
257-
className="flex min-h-[500px] grow flex-col lg:min-h-[740px]"
258-
style={{
259-
height: !isMobile && height ? `${height}px` : "auto",
260-
}}
261-
>
248+
<div className="flex h-[500px] grow flex-col lg:h-[740px]">
262249
<ResponseSection
263250
isPending={props.isPending}
264251
response={props.response}
@@ -417,35 +404,37 @@ function RequestConfigSection(props: {
417404
const queryParams = props.parameters.filter((param) => param.in === "query");
418405

419406
return (
420-
<div className="flex grow flex-col">
407+
<div className="flex grow flex-col overflow-hidden">
421408
<div className="flex min-h-[60px] items-center gap-2 border-b p-4 text-sm">
422409
<ArrowUpRightIcon className="size-5" />
423410
Request
424411
</div>
425412

426-
{pathVariables.length > 0 && (
427-
<ParameterSection
428-
parameters={pathVariables}
429-
title="Path Variables"
430-
form={props.form}
431-
domain={props.domain}
432-
path={props.path}
433-
supportedChainIds={props.supportedChainIds}
434-
/>
435-
)}
413+
<ScrollShadow className="flex-1" scrollableClassName="max-h-full">
414+
{pathVariables.length > 0 && (
415+
<ParameterSection
416+
parameters={pathVariables}
417+
title="Path Variables"
418+
form={props.form}
419+
domain={props.domain}
420+
path={props.path}
421+
supportedChainIds={props.supportedChainIds}
422+
/>
423+
)}
436424

437-
{pathVariables.length > 0 && queryParams.length > 0 && <Separator />}
425+
{pathVariables.length > 0 && queryParams.length > 0 && <Separator />}
438426

439-
{queryParams.length > 0 && (
440-
<ParameterSection
441-
parameters={queryParams}
442-
title="Query Parameters"
443-
form={props.form}
444-
domain={props.domain}
445-
path={props.path}
446-
supportedChainIds={props.supportedChainIds}
447-
/>
448-
)}
427+
{queryParams.length > 0 && (
428+
<ParameterSection
429+
parameters={queryParams}
430+
title="Query Parameters"
431+
form={props.form}
432+
domain={props.domain}
433+
path={props.path}
434+
supportedChainIds={props.supportedChainIds}
435+
/>
436+
)}
437+
</ScrollShadow>
449438
</div>
450439
);
451440
}
@@ -758,22 +747,3 @@ function ElapsedTimeCounter() {
758747
</span>
759748
);
760749
}
761-
762-
const isMobileMedia = () => {
763-
if (typeof window === "undefined") return false;
764-
return window.matchMedia("(max-width: 640px)").matches;
765-
};
766-
767-
function useIsMobileViewport() {
768-
const [state, setState] = useState(isMobileMedia);
769-
770-
// eslint-disable-next-line no-restricted-syntax
771-
useEffect(() => {
772-
if (typeof window === "undefined") return;
773-
const handleResize = () => setState(isMobileMedia());
774-
window.addEventListener("resize", handleResize);
775-
return () => window.removeEventListener("resize", handleResize);
776-
}, []);
777-
778-
return state;
779-
}

apps/dashboard/src/app/team/[team_slug]/[project_slug]/insight/page.tsx

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -98,26 +98,24 @@ function BlueprintCard(props: {
9898
description: string;
9999
}) {
100100
return (
101-
<div className="relative rounded-lg border border-border bg-muted/50 p-4 hover:bg-muted/70">
102-
<div className="flex items-center gap-3">
103-
<div className="rounded-xl border p-1">
104-
<div className="rounded-lg border bg-muted p-1">
105-
<BoxIcon className="size-5 text-muted-foreground" />
106-
</div>
101+
<div className="relative flex items-center gap-3 rounded-lg border border-border bg-muted/50 px-4 py-5 hover:bg-muted/70">
102+
<div className="shrink-0 rounded-xl border p-1">
103+
<div className="rounded-lg border bg-muted p-1">
104+
<BoxIcon className="size-5 text-muted-foreground" />
107105
</div>
106+
</div>
108107

109-
<div>
110-
<Link
111-
className="group static before:absolute before:top-0 before:right-0 before:bottom-0 before:left-0 before:z-0"
112-
href={props.href}
113-
>
114-
<h2 className="font-medium text-base">{props.title}</h2>
115-
</Link>
108+
<div className="flex flex-col gap-1">
109+
<Link
110+
className="group static before:absolute before:top-0 before:right-0 before:bottom-0 before:left-0 before:z-0"
111+
href={props.href}
112+
>
113+
<h2 className="font-medium text-base">{props.title}</h2>
114+
</Link>
116115

117-
<p className="line-clamp-1 text-muted-foreground text-sm">
118-
{props.description}
119-
</p>
120-
</div>
116+
<p className="line-clamp-1 text-muted-foreground text-sm">
117+
{props.description}
118+
</p>
121119
</div>
122120
</div>
123121
);

0 commit comments

Comments
 (0)