@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 06:00 UTC

main
tsx 81 lines 1.9 KB
Raw
1 import { useState } from "react";
2 import { useAgentPrompt } from "./agentPrompt";
3
4 export default function CopyForAgent() {
5 const [copied, setCopied] = useState(false);
6 const PROMPT = useAgentPrompt();
7
8 const onCopy = async () => {
9 try {
10 await navigator.clipboard.writeText(PROMPT);
11 } catch {
12 const ta = document.createElement("textarea");
13 ta.value = PROMPT;
14 ta.style.position = "fixed";
15 ta.style.opacity = "0";
16 document.body.appendChild(ta);
17 ta.select();
18 try {
19 document.execCommand("copy");
20 } finally {
21 document.body.removeChild(ta);
22 }
23 }
24 setCopied(true);
25 window.setTimeout(() => setCopied(false), 1600);
26 };
27
28 return (
29 <div className="alc-copy-agent" data-nosnippet="">
30 <code className="alc-copy-agent__text" tabIndex={0} aria-label="Prompt for your coding agent">
31 {PROMPT}
32 </code>
33 <button
34 type="button"
35 onClick={onCopy}
36 className="alc-copy-agent__btn"
37 aria-label={copied ? "Copied to clipboard" : "Copy prompt to clipboard"}
38 title={copied ? "Copied" : "Copy prompt"}
39 >
40 {copied ? <CheckIcon /> : <CopyIcon />}
41 </button>
42 </div>
43 );
44 }
45
46 function CopyIcon() {
47 return (
48 <svg
49 aria-hidden
50 width="14"
51 height="14"
52 viewBox="0 0 24 24"
53 fill="none"
54 stroke="currentColor"
55 strokeWidth="2"
56 strokeLinecap="round"
57 strokeLinejoin="round"
58 >
59 <rect x="9" y="9" width="13" height="13" rx="2" />
60 <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" />
61 </svg>
62 );
63 }
64
65 function CheckIcon() {
66 return (
67 <svg
68 aria-hidden
69 width="14"
70 height="14"
71 viewBox="0 0 24 24"
72 fill="none"
73 stroke="currentColor"
74 strokeWidth="2.25"
75 strokeLinecap="round"
76 strokeLinejoin="round"
77 >
78 <path d="M20 6 9 17l-5-5" />
79 </svg>
80 );
81 }