Skip to content

Commit 7d2848c

Browse files
chore(evm-address): Option to copy the address for evm contracts and copy feedback (#752)
* copy address for evm contracts and copy feedback * no margin
1 parent dca9b0d commit 7d2848c

File tree

2 files changed

+189
-180
lines changed

2 files changed

+189
-180
lines changed

components/CopyAddress.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
import copy from "copy-to-clipboard";
21
import CopyIcon from "./icons/CopyIcon";
2+
import { useCopyToClipboard } from "../utils/useCopyToClipboard";
33

44
const CopyAddress = ({ address, url }: { address: string; url?: string }) => {
5+
const { copiedText, copyToClipboard } = useCopyToClipboard();
6+
const isCopied = copiedText === address;
7+
58
return (
69
<div
710
className="-ml-1 inline-flex cursor-pointer items-center px-1 font-mono hover:bg-light hover:text-dark dark:hover:bg-dark dark:hover:text-light"
811
onClick={() => {
9-
copy(address);
12+
copyToClipboard(address);
1013
}}
1114
>
1215
<span className="mr-2 hidden lg:block">
@@ -26,8 +29,12 @@ const CopyAddress = ({ address, url }: { address: string; url?: string }) => {
2629
) : (
2730
address.slice(0, 6) + "..." + address.slice(-6)
2831
)}
29-
</span>{" "}
30-
<CopyIcon className="shrink-0" />
32+
</span>
33+
{isCopied ? (
34+
<span className="text-green-500 text-xs font-bold"></span>
35+
) : (
36+
<CopyIcon className="shrink-0" />
37+
)}
3138
</div>
3239
);
3340
};

0 commit comments

Comments
 (0)