MCPcopy Index your code
hub / github.com/CommandCodeAI/BaseAI / InlineCopy

Function InlineCopy

apps/baseai.dev/src/components/mdx/InlineCodeCopy.tsx:11–45  ·  view source on GitHub ↗
({
	content,
	children
}: {
	content: string;
	children: React.ReactNode;
})

Source from the content-addressed store, hash-verified

9import cn from 'mxcn';
10
11export function InlineCopy({
12 content,
13 children
14}: {
15 content: string;
16 children: React.ReactNode;
17}) {
18 const { isCopied, copyToClipboard } = useCopyToClipboard({ timeout: 2000 });
19 const totalChars = content.length;
20
21 const onCopy = () => {
22 navigator.clipboard.writeText(content);
23 if (isCopied) return;
24 copyToClipboard(content);
25 };
26
27 return (
28 <span className="inline-flex items-center gap-1 whitespace-nowrap">
29 <code className={cn(totalChars > 25 && 'w-[50%] sm:w-full overflow-scroll')}>{content}</code>
30 <Button
31 variant="ghost"
32 className="h-4 w-4 p-0 focus:ring-0"
33 size="icon"
34 onClick={onCopy}
35 >
36 {isCopied ? (
37 <ClipboardDocumentCheckIcon className="w-4" />
38 ) : (
39 <DocumentDuplicateIcon className="w-4" />
40 )}
41 <span className="sr-only">Copy</span>
42 </Button>
43 </span>
44 );
45}

Callers

nothing calls this directly

Calls 2

useCopyToClipboardFunction · 0.90
cnFunction · 0.50

Tested by

no test coverage detected