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