Make scrollable areas more consistent (#952)

Co-authored-by: wintonzheng <null>
This commit is contained in:
Shuchang Zheng
2024-10-10 06:59:03 -07:00
committed by GitHub
parent 39776842f3
commit 267adea411
4 changed files with 154 additions and 124 deletions

View File

@@ -12,15 +12,26 @@ const ScrollArea = React.forwardRef<
className={cn("relative overflow-hidden", className)} className={cn("relative overflow-hidden", className)}
{...props} {...props}
> >
<ScrollAreaPrimitive.Viewport className="h-full w-full rounded-[inherit]">
{children} {children}
</ScrollAreaPrimitive.Viewport>
<ScrollBar /> <ScrollBar />
<ScrollAreaPrimitive.Corner /> <ScrollAreaPrimitive.Corner />
</ScrollAreaPrimitive.Root> </ScrollAreaPrimitive.Root>
)); ));
ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName; ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName;
const ScrollAreaViewport = React.forwardRef<
React.ElementRef<typeof ScrollAreaPrimitive.ScrollAreaViewport>,
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.ScrollAreaViewport>
>(({ children, ...props }, ref) => {
return (
<ScrollAreaPrimitive.Viewport ref={ref} {...props}>
{children}
</ScrollAreaPrimitive.Viewport>
);
});
ScrollAreaViewport.displayName =
ScrollAreaPrimitive.ScrollAreaViewport.displayName;
const ScrollBar = React.forwardRef< const ScrollBar = React.forwardRef<
React.ElementRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>, React.ElementRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>,
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar> React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>
@@ -43,4 +54,4 @@ const ScrollBar = React.forwardRef<
)); ));
ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName; ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName;
export { ScrollArea, ScrollBar }; export { ScrollArea, ScrollBar, ScrollAreaViewport };

View File

@@ -10,7 +10,11 @@ import { AxiosError } from "axios";
import { useState } from "react"; import { useState } from "react";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import { stringify as convertToYAML } from "yaml"; import { stringify as convertToYAML } from "yaml";
import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area"; import {
ScrollArea,
ScrollAreaViewport,
ScrollBar,
} from "@/components/ui/scroll-area";
function createTaskFromTaskGenerationParameters( function createTaskFromTaskGenerationParameters(
values: TaskGenerationApiResponse, values: TaskGenerationApiResponse,
@@ -178,6 +182,7 @@ function PromptBox() {
</div> </div>
</div> </div>
<ScrollArea> <ScrollArea>
<ScrollAreaViewport className="h-full w-full rounded-[inherit]">
<div className="flex gap-4 rounded-sm bg-slate-elevation1 p-4"> <div className="flex gap-4 rounded-sm bg-slate-elevation1 p-4">
{examplePrompts.map((examplePrompt) => { {examplePrompts.map((examplePrompt) => {
return ( return (
@@ -193,6 +198,7 @@ function PromptBox() {
); );
})} })}
</div> </div>
</ScrollAreaViewport>
<ScrollBar orientation="horizontal" /> <ScrollBar orientation="horizontal" />
</ScrollArea> </ScrollArea>
</div> </div>

View File

@@ -2,6 +2,7 @@ import { getClient } from "@/api/AxiosClient";
import { Action, ActionTypes, ReadableActionTypes } from "@/api/types"; import { Action, ActionTypes, ReadableActionTypes } from "@/api/types";
import { Badge } from "@/components/ui/badge"; import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button"; import { Button } from "@/components/ui/button";
import { ScrollArea, ScrollAreaViewport } from "@/components/ui/scroll-area";
import { Separator } from "@/components/ui/separator"; import { Separator } from "@/components/ui/separator";
import { import {
Tooltip, Tooltip,
@@ -155,7 +156,9 @@ function ScrollableActionList({
<ArrowDownIcon /> <ArrowDownIcon />
</Button> </Button>
</div> </div>
<div className="w-full space-y-4 overflow-y-scroll px-4 pb-4"> <ScrollArea>
<ScrollAreaViewport className="h-full w-full rounded-[inherit]">
<div className="w-full space-y-4 px-4 pb-4">
{showStreamOption && ( {showStreamOption && (
<div <div
key="stream" key="stream"
@@ -178,6 +181,8 @@ function ScrollableActionList({
)} )}
{getReverseActions()} {getReverseActions()}
</div> </div>
</ScrollAreaViewport>
</ScrollArea>
</div> </div>
); );
} }

View File

@@ -26,6 +26,7 @@ import {
} from "@/components/ui/dropdown-menu"; } from "@/components/ui/dropdown-menu";
import { useReactFlow } from "@xyflow/react"; import { useReactFlow } from "@xyflow/react";
import { useWorkflowHasChangesStore } from "@/store/WorkflowHasChangesStore"; import { useWorkflowHasChangesStore } from "@/store/WorkflowHasChangesStore";
import { ScrollArea, ScrollAreaViewport } from "@/components/ui/scroll-area";
const WORKFLOW_EDIT_PANEL_WIDTH = 20 * 16; const WORKFLOW_EDIT_PANEL_WIDTH = 20 * 16;
const WORKFLOW_EDIT_PANEL_GAP = 1 * 16; const WORKFLOW_EDIT_PANEL_GAP = 1 * 16;
@@ -105,7 +106,9 @@ function WorkflowParametersPanel() {
</DropdownMenuContent> </DropdownMenuContent>
</DropdownMenu> </DropdownMenu>
<section className="max-h-[600px] space-y-2 overflow-y-scroll"> <ScrollArea>
<ScrollAreaViewport className="max-h-[600px]">
<section className="space-y-2">
{workflowParameters.map((parameter) => { {workflowParameters.map((parameter) => {
return ( return (
<div <div
@@ -168,8 +171,11 @@ function WorkflowParametersPanel() {
data: { data: {
...node.data, ...node.data,
parameterKeys: ( parameterKeys: (
node.data.parameterKeys as Array<string> node.data
).filter((key) => key !== parameter.key), .parameterKeys as Array<string>
).filter(
(key) => key !== parameter.key,
),
}, },
}; };
} }
@@ -188,6 +194,8 @@ function WorkflowParametersPanel() {
); );
})} })}
</section> </section>
</ScrollAreaViewport>
</ScrollArea>
</div> </div>
{operationPanelState.active && ( {operationPanelState.active && (
<div <div