in src/components/ShellCommand/index.tsx [13:34]
export default function ShellCommand({ className, style, command }: Props) {
const [copied, setCopied] = useState(false);
function copyCommand() {
if (copied) return;
window.navigator.clipboard.writeText(command);
setCopied(true);
setTimeout(() => setCopied(false), 2000);
}
return (
<div
className={clsx(styles['shell-command-block'], className)}
style={style}
>
{Highlighter(command)}
<button className={styles['copy-icon']} onClick={copyCommand}>
{copied ? <CheckedIcon /> : <CopyIcon />}
</button>
</div>
);
}