Spaces:
Running
Running
File size: 900 Bytes
55947a0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
import { CheckIcon, CopyIcon } from "lucide-react";
import { cn } from "@/lib/utils";
import { useCopy } from "@/lib/hooks/use-copy";
import { Button } from "./ui/button";
interface CopyButtonProps {
text: string;
className?: string;
}
export function CopyButton({ text, className }: CopyButtonProps) {
const { copied, copy } = useCopy();
return (
<Button
variant="ghost"
size="sm"
className={cn(
"transition-opacity opacity-0 group-hover/message:opacity-100 gap-1.5",
className
)}
onClick={() => copy(text)}
title="Copy to clipboard"
>
{copied ? (
<>
<CheckIcon className="h-4 w-4" />
<span className="text-xs">Copied!</span>
</>
) : (
<>
<CopyIcon className="h-4 w-4" />
<span className="text-xs">Copy</span>
</>
)}
</Button>
);
} |