MCPcopy
hub / github.com/chronark/highstorm / CopyButton

Function CopyButton

apps/web/components/copy-button.tsx:26–53  ·  view source on GitHub ↗
({ value, className, src, ...props }: CopyButtonProps)

Source from the content-addressed store, hash-verified

24}
25
26export function CopyButton({ value, className, src, ...props }: CopyButtonProps) {
27 const [hasCopied, setHasCopied] = React.useState(false);
28
29 React.useEffect(() => {
30 setTimeout(() => {
31 setHasCopied(false);
32 }, 2000);
33 }, [hasCopied]);
34
35 return (
36 <button
37 className={cn(
38 "relative z-20 inline-flex h-8 items-center justify-center rounded-md border-zinc-200 p-2 text-sm font-medium text-zinc-900 transition-all hover:bg-zinc-100 focus:outline-none dark:text-zinc-100 dark:hover:bg-zinc-800",
39 className,
40 )}
41 onClick={() => {
42 copyToClipboardWithMeta(value, {
43 component: src,
44 });
45 setHasCopied(true);
46 }}
47 {...props}
48 >
49 <span className="sr-only">Copy</span>
50 {hasCopied ? <Icons.check className="w-4 h-4" /> : <Icons.copy className="w-4 h-4" />}
51 </button>
52 );
53}
54
55interface CopyWithClassNamesProps extends DropdownMenuTriggerProps {
56 value: string;

Callers

nothing calls this directly

Calls 2

cnFunction · 0.90
copyToClipboardWithMetaFunction · 0.85

Tested by

no test coverage detected