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, 04:45 UTC
| 1 | import { msg, useGT } from "gt-react"; |
| 2 | import { CheckIcon, CopyIcon } from "lucide-react"; |
| 3 | |
| 4 | import { useCopyToClipboard } from "~/hooks/useCopyToClipboard"; |
| 5 | import { cn } from "~/lib/utils"; |
| 6 | |
| 7 | import { Button } from "./ui/button"; |
| 8 | |
| 9 | export function CommandBlock({ |
| 10 | command, |
| 11 | className, |
| 12 | prominent = false, |
| 13 | }: { |
| 14 | readonly command: string; |
| 15 | readonly className?: string; |
| 16 | readonly prominent?: boolean; |
| 17 | }) { |
| 18 | const gt = useGT(); |
| 19 | const { copyToClipboard, isCopied } = useCopyToClipboard({ |
| 20 | timeout: 1500, |
| 21 | target: { |
| 22 | target: "command", |
| 23 | unavailableMessage: msg("Clipboard API is unavailable while copying command."), |
| 24 | failureMessage: msg("Failed to copy command to the clipboard."), |
| 25 | }, |
| 26 | }); |
| 27 | return ( |
| 28 | <div |
| 29 | className={cn( |
| 30 | "flex items-center justify-between gap-3 rounded-lg border border-border bg-muted/50 font-mono", |
| 31 | prominent ? "px-4 py-3.5 text-base" : "px-3 py-2.5 text-sm", |
| 32 | className, |
| 33 | )} |
| 34 | > |
| 35 | <span className="min-w-0 truncate"> |
| 36 | <span className="mr-2 text-muted-foreground">$</span> |
| 37 | {command} |
| 38 | </span> |
| 39 | <Button |
| 40 | size="icon-xs" |
| 41 | variant="ghost" |
| 42 | aria-label={gt("Copy command")} |
| 43 | onClick={() => copyToClipboard(command, undefined)} |
| 44 | > |
| 45 | {isCopied ? <CheckIcon className="size-3.5" /> : <CopyIcon className="size-3.5" />} |
| 46 | </Button> |
| 47 | </div> |
| 48 | ); |
| 49 | } |