mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-15 14:03:52 +00:00
32 lines
757 B
TypeScript
32 lines
757 B
TypeScript
'use client';
|
|
|
|
import { useState } from 'react';
|
|
import { Copy, CheckCircle2 } from 'lucide-react';
|
|
|
|
interface CopyButtonProps {
|
|
text: string;
|
|
}
|
|
|
|
export function CopyButton({ text }: CopyButtonProps) {
|
|
const [copied, setCopied] = useState(false);
|
|
|
|
const handleCopy = async () => {
|
|
await navigator.clipboard.writeText(text);
|
|
setCopied(true);
|
|
setTimeout(() => setCopied(false), 2000);
|
|
};
|
|
|
|
return (
|
|
<button
|
|
onClick={handleCopy}
|
|
className="p-2 hover:bg-white/10 rounded-md transition-colors text-zinc-500 hover:text-white"
|
|
aria-label="Copy to clipboard"
|
|
>
|
|
{copied ? (
|
|
<CheckCircle2 className="w-4 h-4 text-green-400" />
|
|
) : (
|
|
<Copy className="w-4 h-4" />
|
|
)}
|
|
</button>
|
|
);
|
|
}
|