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
| 1 | import { useState } from "react"; |
| 2 | import { useAgentPrompt } from "./agentPrompt"; |
| 3 | |
| 4 | export default function HeroCta() { |
| 5 | return ( |
| 6 | <> |
| 7 | <div className="hero-cta hero-cta--cards"> |
| 8 | <a className="hero-cta__card hero-cta__card--human" href="/getting-started"> |
| 9 | <span className="hero-cta__eyebrow">For humans</span> |
| 10 | <span className="hero-cta__title"> |
| 11 | Get started <span aria-hidden>→</span> |
| 12 | </span> |
| 13 | </a> |
| 14 | <CopyCard /> |
| 15 | </div> |
| 16 | <div className="hero-cta hero-cta--simple"> |
| 17 | <div className="hero-cta__buttons"> |
| 18 | <a className="alc-btn alc-btn--primary" href="/getting-started"> |
| 19 | Get started <span aria-hidden>→</span> |
| 20 | </a> |
| 21 | <a className="alc-btn alc-btn--secondary" href="/cloudflare/tutorial/part-1"> |
| 22 | Tutorial |
| 23 | </a> |
| 24 | </div> |
| 25 | <div className="hero-cta__line" data-nosnippet=""> |
| 26 | <span> |
| 27 | <span aria-hidden>🤖</span> Using a coding agent? |
| 28 | </span> |
| 29 | <InlineCopyChip /> |
| 30 | </div> |
| 31 | </div> |
| 32 | </> |
| 33 | ); |
| 34 | } |
| 35 | |
| 36 | function InlineCopyChip() { |
| 37 | const [copied, setCopied] = useState(false); |
| 38 | const PROMPT = useAgentPrompt(); |
| 39 | const onCopy = () => copy(PROMPT, setCopied); |
| 40 | return ( |
| 41 | <button |
| 42 | type="button" |
| 43 | className="hero-cta__chip" |
| 44 | onClick={onCopy} |
| 45 | aria-label={copied ? "Copied" : "Copy prompt"} |
| 46 | > |
| 47 | {copied ? <CheckIcon /> : <CopyIcon />} |
| 48 | <span>{copied ? "Copied" : "Copy prompt"}</span> |
| 49 | </button> |
| 50 | ); |
| 51 | } |
| 52 | |
| 53 | function CopyCard() { |
| 54 | const [copied, setCopied] = useState(false); |
| 55 | const PROMPT = useAgentPrompt(); |
| 56 | const onCopy = () => copy(PROMPT, setCopied); |
| 57 | return ( |
| 58 | <button |
| 59 | type="button" |
| 60 | className="hero-cta__card hero-cta__card--agent" |
| 61 | onClick={onCopy} |
| 62 | aria-label={copied ? "Copied prompt" : "Copy prompt for your coding agent"} |
| 63 | > |
| 64 | <span className="hero-cta__eyebrow"> |
| 65 | For coding agents |
| 66 | <span className="hero-cta__icon" aria-hidden> |
| 67 | {copied ? <CheckIcon /> : <CopyIcon />} |
| 68 | </span> |
| 69 | </span> |
| 70 | <code className="hero-cta__prompt-code" data-nosnippet=""> |
| 71 | {PROMPT} |
| 72 | </code> |
| 73 | </button> |
| 74 | ); |
| 75 | } |
| 76 | |
| 77 | function copy(text: string, setCopied: (b: boolean) => void) { |
| 78 | const finish = () => { |
| 79 | setCopied(true); |
| 80 | window.setTimeout(() => setCopied(false), 1600); |
| 81 | }; |
| 82 | if (navigator.clipboard?.writeText) { |
| 83 | navigator.clipboard.writeText(text).then(finish, finish); |
| 84 | return; |
| 85 | } |
| 86 | const ta = document.createElement("textarea"); |
| 87 | ta.value = text; |
| 88 | ta.style.position = "fixed"; |
| 89 | ta.style.opacity = "0"; |
| 90 | document.body.appendChild(ta); |
| 91 | ta.select(); |
| 92 | try { |
| 93 | document.execCommand("copy"); |
| 94 | } finally { |
| 95 | document.body.removeChild(ta); |
| 96 | } |
| 97 | finish(); |
| 98 | } |
| 99 | |
| 100 | function CopyIcon() { |
| 101 | return ( |
| 102 | <svg |
| 103 | aria-hidden |
| 104 | width="13" |
| 105 | height="13" |
| 106 | viewBox="0 0 24 24" |
| 107 | fill="none" |
| 108 | stroke="currentColor" |
| 109 | strokeWidth="2" |
| 110 | strokeLinecap="round" |
| 111 | strokeLinejoin="round" |
| 112 | > |
| 113 | <rect x="9" y="9" width="13" height="13" rx="2" /> |
| 114 | <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" /> |
| 115 | </svg> |
| 116 | ); |
| 117 | } |
| 118 | |
| 119 | function CheckIcon() { |
| 120 | return ( |
| 121 | <svg |
| 122 | aria-hidden |
| 123 | width="13" |
| 124 | height="13" |
| 125 | viewBox="0 0 24 24" |
| 126 | fill="none" |
| 127 | stroke="currentColor" |
| 128 | strokeWidth="2.25" |
| 129 | strokeLinecap="round" |
| 130 | strokeLinejoin="round" |
| 131 | > |
| 132 | <path d="M20 6 9 17l-5-5" /> |
| 133 | </svg> |
| 134 | ); |
| 135 | } |