"use client"; import { ClipboardIcon, CheckIcon } from "lucide-react"; import { useState } from "react"; interface CommandDisplayProps { command: string; } export function CommandDisplay({ command }: CommandDisplayProps) { const [copied, setCopied] = useState(false); const copyToClipboard = async () => { try { await navigator.clipboard.writeText(command); setCopied(true); setTimeout(() => setCopied(false), 2000); } catch (err) { console.error("Failed to copy text: ", err); } }; const defaultColors = [ "text-blue-300", "text-yellow-300", "text-green-300", "text-purple-300", ]; // Split the command into parts for syntax highlighting const parts = command.split(" ").map((part, index) => { const color = defaultColors[index % defaultColors.length]; return ( {part} ); }); return (