mirror of
https://github.com/vercel/eve.git
synced 2026-09-20 05:35:39 +08:00
f44e16a3e5
Co-authored-by: Casey Gowrie <ctgowrie@gmail.com> Co-authored-by: Allen Zhou <46854522+allenzhou101@users.noreply.github.com> Co-authored-by: Rui Conti <ruiconti@gmail.com> Co-authored-by: JJ Kasper <jj@jjsweb.site> Co-authored-by: Timo Lins <1440854+timolins@users.noreply.github.com> Co-authored-by: Felix Arntz <3531426+felixarntz@users.noreply.github.com> Co-authored-by: Shar Dara <2982650+darafsheh@users.noreply.github.com> Co-authored-by: John Phamous <johnphammail@gmail.com>
58 lines
1.6 KiB
TypeScript
58 lines
1.6 KiB
TypeScript
"use client";
|
|
|
|
import { track } from "@vercel/analytics";
|
|
import {
|
|
InputGroup,
|
|
InputGroupAddon,
|
|
InputGroupButton,
|
|
} from "@vercel/geistdocs/components/input-group";
|
|
import { Input } from "@vercel/geistdocs/components/input";
|
|
import { CheckIcon, CopyIcon } from "lucide-react";
|
|
import { useState } from "react";
|
|
import { toast } from "sonner";
|
|
|
|
const COPY_TIMEOUT = 2000;
|
|
|
|
interface InstallerProps {
|
|
className?: string;
|
|
command: string;
|
|
}
|
|
|
|
export const Installer = ({ command, className = "w-48" }: InstallerProps) => {
|
|
const [copied, setCopied] = useState(false);
|
|
|
|
const handleCopy = () => {
|
|
navigator.clipboard.writeText(command);
|
|
toast.success("Copied to clipboard");
|
|
setCopied(true);
|
|
|
|
track("Copied installer command");
|
|
setTimeout(() => {
|
|
setCopied(false);
|
|
}, COPY_TIMEOUT);
|
|
};
|
|
|
|
const Icon = copied ? CheckIcon : CopyIcon;
|
|
|
|
return (
|
|
<InputGroup
|
|
className="h-10 cursor-pointer bg-background font-mono shadow-none"
|
|
onClick={handleCopy}
|
|
>
|
|
<InputGroupAddon>
|
|
<span className="font-normal text-muted-foreground">$</span>
|
|
</InputGroupAddon>
|
|
<Input
|
|
className={`${className} h-full flex-1 cursor-pointer rounded-none border-0 bg-transparent font-mono shadow-none focus-visible:ring-0 dark:bg-transparent`}
|
|
readOnly
|
|
value={command}
|
|
/>
|
|
<InputGroupAddon align="inline-end">
|
|
<InputGroupButton aria-label="Copy" onClick={handleCopy} size="icon-xs" title="Copy">
|
|
<Icon className="size-3.5" size={14} />
|
|
</InputGroupButton>
|
|
</InputGroupAddon>
|
|
</InputGroup>
|
|
);
|
|
};
|