import { ArrowDownIcon } from 'lucide-react' import type { ComponentProps, ReactNode } from 'react' import { useCallback } from 'react' import { Button, cn, FloatingPlate } from 'ui' import { StickToBottom, useStickToBottomContext } from 'use-stick-to-bottom' type ConversationProps = Omit, 'children'> & { children?: ReactNode } type ConversationContentProps = ComponentProps & { scrollClassName?: string } type ConversationScrollButtonProps = ComponentProps /** * Horizontal gutter the conversation reserves around its content. The fades overlay the scroll * container, whose scrollbar runs down the right edge, so they stop at this gutter instead of * spanning the full width. */ const CONTENT_GUTTER = 'px-7' const FADE_GUTTER = 'inset-x-7' export const Conversation = ({ className, children, ...props }: ConversationProps) => (
{children} ) export const ConversationContent = ({ className, scrollClassName, children, ...props }: ConversationContentProps) => { const context = useStickToBottomContext() return (
{typeof children === 'function' ? children(context) : children}
) } export const ConversationScrollButton = ({ className, ...props }: ConversationScrollButtonProps) => { const { isAtBottom, scrollToBottom } = useStickToBottomContext() const handleScrollToBottom = useCallback(() => { scrollToBottom() }, [scrollToBottom]) return ( !isAtBottom && ( ) ) }