Files
DeepSeek-TUI/web/components/install-code-block.tsx
CodeWhale Bot 7ad99f400e fix(web): unify site layout and surface runtime facts
Use one 76rem container and shared hero/section rhythm across navigation, footer, ticker, feed, install, runtime, and portal pages.

Also make clipboard feedback truthful, repair locale and anchor links, align digest/feed styling, and surface catalog/runtime facts without implying provider readiness.

Signed-off-by: CodeWhale Bot <bot@codewhale.net>
2026-08-13 21:12:10 -07:00

40 lines
1.2 KiB
TypeScript

"use client";
import { useState } from "react";
interface Props {
cmd: string;
copyLabel?: string;
copiedLabel?: string;
}
export function InstallCodeBlock({ cmd, copyLabel = "Copy", copiedLabel = "Copied ✓" }: Props) {
const [copied, setCopied] = useState(false);
const copy = async () => {
if (typeof navigator === "undefined" || !navigator.clipboard) return;
try {
await navigator.clipboard.writeText(cmd);
setCopied(true);
setTimeout(() => setCopied(false), 1400);
} catch {
// Clipboard write failed (permissions, non-secure context, or a focused
// write race) — never show a false "Copied" confirmation.
}
};
return (
<div className="relative">
<button
onClick={copy}
aria-label={copied ? copiedLabel : copyLabel}
data-copied={copied}
className="copy-btn absolute top-3 right-3 z-10 px-3 py-1 bg-paper hairline-t hairline-b hairline-l hairline-r font-mono text-[0.7rem] uppercase tracking-wider hover:bg-indigo hover:text-paper transition-colors"
>
{copied ? copiedLabel : copyLabel}
</button>
<pre className="code-block text-[0.78rem] m-0 max-w-full pr-20">{cmd}</pre>
</div>
);
}