From 574b7e59cef6f29e4e95dca443c3a81f65f7bf5a Mon Sep 17 00:00:00 2001 From: Henry Li Date: Fri, 16 Jan 2026 19:50:23 +0800 Subject: [PATCH] feat: add copy button --- .../src/components/workspace/copy-button.tsx | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 frontend/src/components/workspace/copy-button.tsx diff --git a/frontend/src/components/workspace/copy-button.tsx b/frontend/src/components/workspace/copy-button.tsx new file mode 100644 index 0000000..b710939 --- /dev/null +++ b/frontend/src/components/workspace/copy-button.tsx @@ -0,0 +1,37 @@ +import { CheckIcon, CopyIcon } from "lucide-react"; +import { useCallback, useState, type ComponentProps } from "react"; + +import { Button } from "@/components/ui/button"; + +import { Tooltip } from "./tooltip"; + +export function CopyButton({ + clipboardData, + ...props +}: ComponentProps & { + clipboardData: string; +}) { + const [copied, setCopied] = useState(false); + const handleCopy = useCallback(() => { + void navigator.clipboard.writeText(clipboardData); + setCopied(true); + setTimeout(() => setCopied(false), 2000); + }, [clipboardData]); + return ( + + + + ); +}