MCPcopy
hub / github.com/intentui/intentui / PullRegistry

Function PullRegistry

src/components/code/pull-registry.tsx:60–110  ·  view source on GitHub ↗
({ readMore, processedSourceCode, blockExample }: PullRegistryProps)

Source from the content-addressed store, hash-verified

58}
59
60export function PullRegistry({ readMore, processedSourceCode, blockExample }: PullRegistryProps) {
61 const [copy, setCopy] = useState({ code: false, command: false })
62 const { copy: copyToClipboard } = useClipboard()
63
64 const handleCopy = async (key: 'code' | 'command', value: string) => {
65 const didCopy = await copyToClipboard(value)
66 if (!didCopy) return
67 setCopy((prev) => ({ ...prev, [key]: true }))
68 setTimeout(() => setCopy((prev) => ({ ...prev, [key]: false })), 2000)
69 }
70
71 return (
72 <div className="relative flex items-center gap-x-0.5 sm:gap-x-3">
73 <CopyButton
74 label="Registry"
75 className="hidden sm:inline"
76 copiedLabel="Copied"
77 isCopied={copy.command}
78 onCopy={() => handleCopy('command', `${app.shadcn} add @intentui/${blockExample}`)}
79 />
80 <CopyButton
81 label="Copy"
82 copiedLabel="Copied"
83 isCopied={copy.code}
84 onCopy={() => {
85 const text = processedSourceCode as string
86 handleCopy('code', text)
87 track('copy to clipboard', {
88 text: text,
89 })
90 }}
91 />
92 {readMore && (
93 <Link
94 className="p-2 font-medium pressed:text-fg text-muted-fg text-sm/6 hover:text-fg"
95 href={readMore}
96 target="_blank"
97 >
98 Read more
99 </Link>
100 )}
101 {/*<Link*/}
102 {/* className="hidden p-2 pressed:text-fg text-muted-fg text-sm/6 hover:text-fg"*/}
103 {/* href={openInV0Url(blockExample)}*/}
104 {/* target="_blank"*/}
105 {/*>*/}
106 {/* Open in V0*/}
107 {/*</Link>*/}
108 </div>
109 )
110}

Callers

nothing calls this directly

Calls 2

useClipboardFunction · 0.90
handleCopyFunction · 0.70

Tested by

no test coverage detected