From fa7209783850bb47d3cf70cb6ac4b2131246f4d9 Mon Sep 17 00:00:00 2001 From: "dayuan.jiang" Date: Wed, 26 Mar 2025 10:32:33 +0000 Subject: [PATCH] refactor: replace Tooltip components with ButtonWithTooltip in ChatInput --- components/button-with-tooltip.tsx | 34 +++++++++++++++ components/chat-input.tsx | 69 +++++++++++------------------- 2 files changed, 58 insertions(+), 45 deletions(-) create mode 100644 components/button-with-tooltip.tsx diff --git a/components/button-with-tooltip.tsx b/components/button-with-tooltip.tsx new file mode 100644 index 0000000..bb8f53d --- /dev/null +++ b/components/button-with-tooltip.tsx @@ -0,0 +1,34 @@ +import React from "react"; +import { Button, buttonVariants } from "@/components/ui/button"; +import { + Tooltip, + TooltipContent, + TooltipProvider, + TooltipTrigger, +} from "@/components/ui/tooltip"; +import { type VariantProps } from "class-variance-authority"; + +interface ButtonWithTooltipProps + extends React.ComponentProps<"button">, + VariantProps { + tooltipContent: string; + children: React.ReactNode; + asChild?: boolean; +} + +export function ButtonWithTooltip({ + tooltipContent, + children, + ...buttonProps +}: ButtonWithTooltipProps) { + return ( + + + + + + {tooltipContent} + + + ); +} diff --git a/components/chat-input.tsx b/components/chat-input.tsx index 08bfcb1..4be3980 100644 --- a/components/chat-input.tsx +++ b/components/chat-input.tsx @@ -12,12 +12,7 @@ import { X, History, } from "lucide-react"; -import { - Tooltip, - TooltipContent, - TooltipProvider, - TooltipTrigger, -} from "@/components/ui/tooltip"; +import { ButtonWithTooltip } from "@/components/button-with-tooltip"; import Image from "next/image"; import { useDiagram } from "@/contexts/diagram-context"; @@ -207,23 +202,15 @@ export function ChatInput({
- - - - - - - Clear current conversation and diagram - - - + setShowClearDialog(true)} + tooltipContent="Clear current conversation and diagram" + > + + {/* Warning Modal */}
{/* History Button */} - - - - - - - View diagram history - - - + setShowHistory(true)} + disabled={ + status === "streaming" || + diagramHistory.length === 0 + } + title="Diagram History" + tooltipContent="View diagram history" + > + +