Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/elements/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"media-chrome": "^4.17.2",
"motion": "^12.26.2",
"nanoid": "^5.1.6",
"radix-ui": "latest",
"react": "19.2.3",
"react-dom": "19.2.3",
"react-jsx-parser": "^2.2.0",
Expand Down
39 changes: 30 additions & 9 deletions packages/elements/src/conversation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { cn } from "@repo/shadcn-ui/lib/utils";
import { ArrowDownIcon, DownloadIcon } from "lucide-react";
import { useCallback } from "react";
import { StickToBottom, useStickToBottomContext } from "use-stick-to-bottom";
import { ScrollArea as ScrollAreaPrimitive } from "radix-ui";
import { ScrollBar } from "@repo/shadcn-ui/components/ui/scroll-area";

export type ConversationProps = ComponentProps<typeof StickToBottom>;

Expand All @@ -20,19 +22,38 @@ export const Conversation = ({ className, ...props }: ConversationProps) => (
/>
);

export type ConversationContentProps = ComponentProps<
typeof StickToBottom.Content
>;
export type ConversationContentProps = ComponentProps<typeof ScrollAreaPrimitive.Root> & {
scrollClassName?: string;
scrollBarClassName?: string;
};

export const ConversationContent = ({
children,
className,
scrollClassName,
scrollBarClassName,
...props
}: ConversationContentProps) => (
<StickToBottom.Content
className={cn("flex flex-col gap-8 p-4", className)}
{...props}
/>
);
}: ConversationContentProps) => {
const context = useStickToBottomContext();

return (
<ScrollAreaPrimitive.Root className="size-full" {...props}>
<ScrollAreaPrimitive.Viewport
ref={context.scrollRef}
className={cn("size-full overflow-y-auto", scrollClassName)}
style={{ scrollbarGutter: "stable both-edges" }}
>
<div
ref={context.contentRef}
className={cn("flex flex-col gap-8 p-4", className)}
>
{children}
</div>
</ScrollAreaPrimitive.Viewport>
<ScrollBar className={cn("w-2", scrollBarClassName)} />
</ScrollAreaPrimitive.Root>
);
};

export type ConversationEmptyStateProps = ComponentProps<"div"> & {
title?: string;
Expand Down