|
1 | 1 | import type { ReactNode } from "react"; |
2 | 2 | import { useCallback, useRef, useState } from "react"; |
3 | | -import { Check } from "lucide-react"; |
| 3 | +import { Check, LoaderCircle } from "lucide-react"; |
4 | 4 | import { Button } from "@/components/ui/button"; |
5 | 5 | import { CopyButton } from "@/components/code/copy-button"; |
6 | 6 | import { getBootstrapPromptApiPath } from "@/lib/bootstrap-prompt"; |
@@ -60,12 +60,13 @@ async function getBootstrapPrompt(): Promise<string> { |
60 | 60 | } |
61 | 61 |
|
62 | 62 | export function HeroSection(): ReactNode { |
63 | | - const [copyState, setCopyState] = useState<"idle" | "copied" | "error">( |
64 | | - "idle", |
65 | | - ); |
| 63 | + const [copyState, setCopyState] = useState< |
| 64 | + "idle" | "copying" | "copied" | "error" |
| 65 | + >("idle"); |
66 | 66 | const resetTimerRef = useRef<ReturnType<typeof setTimeout>>(undefined); |
67 | 67 |
|
68 | 68 | const handleCopyBootstrapPrompt = useCallback(async () => { |
| 69 | + setCopyState("copying"); |
69 | 70 | try { |
70 | 71 | const bootstrapPrompt = await getBootstrapPrompt(); |
71 | 72 | const copied = await copyTextToClipboard(bootstrapPrompt); |
@@ -108,11 +109,14 @@ export function HeroSection(): ReactNode { |
108 | 109 | </div> |
109 | 110 | <span className="text-sm text-black/35 dark:text-white/35">or</span> |
110 | 111 | <Button |
111 | | - className="h-11 rounded-full px-6 font-medium" |
| 112 | + className="h-11 w-40 rounded-full px-6 font-medium" |
112 | 113 | onClick={handleCopyBootstrapPrompt} |
| 114 | + disabled={copyState === "copying"} |
113 | 115 | title="Copies a setup guide you can paste into Cursor, Claude Code, or Codex" |
114 | 116 | > |
115 | | - {copyState === "copied" ? ( |
| 117 | + {copyState === "copying" ? ( |
| 118 | + <LoaderCircle className="h-4 w-4 animate-spin" /> |
| 119 | + ) : copyState === "copied" ? ( |
116 | 120 | <span className="inline-flex items-center gap-1.5"> |
117 | 121 | <Check className="h-4 w-4" /> |
118 | 122 | Copied |
|
0 commit comments