MCPcopy Create free account
hub / github.com/CommandCodeAI/BaseAI / CopyableCommand

Function CopyableCommand

apps/baseai.dev/src/components/home/hero.tsx:180–248  ·  view source on GitHub ↗
({ command }: CopyableCommandProps)

Source from the content-addressed store, hash-verified

178}
179
180function CopyableCommand({ command }: CopyableCommandProps) {
181 const [copied, setCopied] = useState(false);
182
183 const copyToClipboard = async () => {
184 try {
185 await navigator.clipboard.writeText(command);
186 setCopied(true);
187 setTimeout(() => setCopied(false), 2000);
188 } catch (err) {
189 console.error('Failed to copy text: ', err);
190 }
191 };
192
193 return (
194 <div
195 className="group my-4 flex w-full cursor-pointer items-center justify-center font-mono text-sm transition-colors lg:items-start lg:justify-start "
196 // "mx-auto mt-8 flex w-full items-center justify-center space-x-2 lg:items-start lg:justify-start"
197 onClick={copyToClipboard}
198 role="button"
199 tabIndex={0}
200 onKeyDown={e => e.key === 'Enter' && copyToClipboard()}
201 aria-label={`Copy command: ${command}`}
202 >
203 <div className="group flex items-center space-x-2 transition-colors group-hover:text-indigo-400">
204 <span className="text-muted-foreground/50 group-hover:text-indigo-400 sm:text-sm 2xl:text-[1vw] 2xl:leading-[1.5vw]">
205 <span className="xtext-indigo-400">⌘</span>
206 <span className="group-hover:text-muted-foreground/50">
207 {' '}
208 ~
209 </span>
210 </span>
211 <span className="font-mono text-muted-foreground/50 transition-colors group-hover:text-indigo-400 sm:text-sm 2xl:leading-[1.5vw] ">
212 {command}
213 </span>
214 <div className="ml-2 text-muted-foreground/50 transition-colors group-hover:text-indigo-400 sm:text-sm 2xl:leading-[1.5vw]">
215 {copied ? (
216 <svg
217 xmlns="http://www.w3.org/2000/svg"
218 className="h-[1em] w-[1em]"
219 viewBox="0 0 20 20"
220 fill="currentColor"
221 >
222 <path
223 fillRule="evenodd"
224 d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z"
225 clipRule="evenodd"
226 />
227 </svg>
228 ) : (
229 <svg
230 xmlns="http://www.w3.org/2000/svg"
231 className="h-[1em] w-[1em]"
232 fill="none"
233 viewBox="0 0 24 24"
234 stroke="currentColor"
235 >
236 <path
237 strokeLinecap="round"

Callers

nothing calls this directly

Calls 1

copyToClipboardFunction · 0.70

Tested by

no test coverage detected