From 26176a30a78dec1881e0c99cfbbceafcc56e7523 Mon Sep 17 00:00:00 2001 From: Ryan Hopper-Lowe Date: Mon, 16 Dec 2024 13:31:42 -0600 Subject: [PATCH] feat: update chat bar to encapsulate thread actions and submit button --- ui/admin/app/components/chat/Chat.tsx | 7 +- ui/admin/app/components/chat/ChatHelpers.tsx | 8 +- ui/admin/app/components/chat/Chatbar.tsx | 32 ++++--- ui/admin/app/components/ui/button.tsx | 4 +- ui/admin/app/components/ui/textarea.tsx | 92 ++++++++++++++++++-- 5 files changed, 112 insertions(+), 31 deletions(-) diff --git a/ui/admin/app/components/chat/Chat.tsx b/ui/admin/app/components/chat/Chat.tsx index 27a2810e6..8968f0963 100644 --- a/ui/admin/app/components/chat/Chat.tsx +++ b/ui/admin/app/components/chat/Chat.tsx @@ -3,7 +3,6 @@ import { useState } from "react"; import { cn } from "~/lib/utils"; import { useChat } from "~/components/chat/ChatContext"; -import { ChatHelpers } from "~/components/chat/ChatHelpers"; import { Chatbar } from "~/components/chat/Chatbar"; import { MessagePane } from "~/components/chat/MessagePane"; import { RunWorkflow } from "~/components/chat/RunWorkflow"; @@ -56,9 +55,7 @@ export function Chat({ className }: ChatProps) { setRunTriggered(true); invoke(params && JSON.stringify(params)); }} - className={cn({ - "w-full": threadId, - })} + className={cn({ "w-full": threadId })} popoverContentProps={{ className: cn({ "translate-y-[-50%]": !threadId }), }} @@ -69,8 +66,6 @@ export function Chat({ className }: ChatProps) { )} - - ); } diff --git a/ui/admin/app/components/chat/ChatHelpers.tsx b/ui/admin/app/components/chat/ChatHelpers.tsx index 1c596f44c..1465c4272 100644 --- a/ui/admin/app/components/chat/ChatHelpers.tsx +++ b/ui/admin/app/components/chat/ChatHelpers.tsx @@ -19,7 +19,7 @@ import { } from "~/components/ui/popover"; import { Switch } from "~/components/ui/switch"; -export function ChatHelpers() { +export function ChatHelpers({ className }: { className?: string }) { const { threadId } = useChat(); const { data: thread } = useSWR( @@ -42,7 +42,7 @@ export function ChatHelpers() { console.log(knowledge); return ( -
+
+ + +
+ } />
- - ); } diff --git a/ui/admin/app/components/ui/button.tsx b/ui/admin/app/components/ui/button.tsx index 5d8b1354d..6082330dc 100644 --- a/ui/admin/app/components/ui/button.tsx +++ b/ui/admin/app/components/ui/button.tsx @@ -11,11 +11,11 @@ const buttonVariants = cva( variants: { variant: { default: - "bg-primary text-primary-foreground shadow hover:bg-primary/80", + "bg-primary text-primary-foreground shadow hover:bg-primary/80 focus-visible:ring-foreground", destructive: "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/80", outline: - "border border-input bg-background shadow-sm hover:bg-muted/80", + "border border-input bg-transparent shadow-sm hover:bg-muted/80", secondary: "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80", ghost: "hover:bg-secondary hover:text-secondary-foreground", diff --git a/ui/admin/app/components/ui/textarea.tsx b/ui/admin/app/components/ui/textarea.tsx index e6f7eb488..6b35c544a 100644 --- a/ui/admin/app/components/ui/textarea.tsx +++ b/ui/admin/app/components/ui/textarea.tsx @@ -1,16 +1,49 @@ +import { VariantProps, cva } from "class-variance-authority"; import * as React from "react"; -import { useImperativeHandle } from "react"; +import { forwardRef, useImperativeHandle } from "react"; import { cn } from "~/lib/utils"; -export type TextareaProps = React.TextareaHTMLAttributes; +const textareaVariants = cva( + "flex w-full rounded-md bg-transparent text-sm placeholder:text-muted-foreground has-[:focus-visible]:ring-1 has-[:focus-visible]:ring-ring group group-disabled:cursor-not-allowed group-disabled:bg-opacity-50", + { + variants: { + variant: { + outlined: "border border-input shadow-sm", + flat: "border-none shadow-none bg-muted", + }, + }, + defaultVariants: { + variant: "outlined", + }, + } +); -const Textarea = React.forwardRef( - ({ className, ...props }, ref) => { +type TextAreaWrapperProps = React.HTMLAttributes & + VariantProps; +const TextAreaWrapper = forwardRef( + ({ className, variant, ...props }, ref) => { + return ( +
+ ); + } +); +TextAreaWrapper.displayName = "TextAreaWrapper"; + +type TextAreaBaseProps = React.TextareaHTMLAttributes & + VariantProps; + +const TextAreaBase = forwardRef( + ({ className, variant, ...props }, ref) => { return (