-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathCopyTextLink.tsx
More file actions
33 lines (30 loc) · 817 Bytes
/
CopyTextLink.tsx
File metadata and controls
33 lines (30 loc) · 817 Bytes
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
import { ClipboardCheckIcon, ClipboardIcon } from "lucide-react";
import { useCopy } from "~/hooks/useCopy";
import { cn } from "~/utils/cn";
type CopyTextLinkProps = {
value: string;
className?: string;
};
export function CopyTextLink({ value, className }: CopyTextLinkProps) {
const { copy, copied } = useCopy(value);
return (
<button
type="button"
onClick={copy}
className={cn(
"inline-flex cursor-pointer items-center gap-1 text-xs transition-colors",
copied
? "text-success"
: "text-text-dimmed hover:text-text-bright",
className
)}
>
{copied ? "Copied" : "Copy"}
{copied ? (
<ClipboardCheckIcon className="size-3" />
) : (
<ClipboardIcon className="size-3" />
)}
</button>
);
}