mirror of
https://github.com/luxfhe/example-redact.git
synced 2026-10-30 18:13:20 +00:00
27 lines
851 B
TypeScript
27 lines
851 B
TypeScript
import { useState } from "react";
|
|
import CopyToClipboard from "react-copy-to-clipboard";
|
|
import { CheckCircleIcon, DocumentDuplicateIcon } from "@heroicons/react/24/outline";
|
|
|
|
export const AddressCopyIcon = ({ className, address }: { className?: string; address: string }) => {
|
|
const [addressCopied, setAddressCopied] = useState(false);
|
|
return (
|
|
<CopyToClipboard
|
|
text={address}
|
|
onCopy={() => {
|
|
setAddressCopied(true);
|
|
setTimeout(() => {
|
|
setAddressCopied(false);
|
|
}, 800);
|
|
}}
|
|
>
|
|
<button onClick={e => e.stopPropagation()} type="button">
|
|
{addressCopied ? (
|
|
<CheckCircleIcon className={className} aria-hidden="true" />
|
|
) : (
|
|
<DocumentDuplicateIcon className={className} aria-hidden="true" />
|
|
)}
|
|
</button>
|
|
</CopyToClipboard>
|
|
);
|
|
};
|