dd61f99b1d
Entrance reveals on scroll, considered hover/focus states, restrained depth on the terminal and card surfaces, and feedback on state changes — sized to a print object coming to life rather than a landing page. Every effect has a reduced-motion path written alongside it, not bolted on: all four components check `prefers-reduced-motion` and the CSS carries its own block. That block also avoids the usual reduced-motion bug — freezing the ticker would strand every entry past the fold, so the track stops moving and becomes scrollable instead of simply halting. No animation library. `package.json` is untouched; this is CSS transitions, the Web Animations API, and IntersectionObserver. Nothing animated triggers layout. The properties in play are transform, color, border-color, and background-size (underline draws) — all paint, so cumulative layout shift stays zero. The brief asked for transform/opacity only; the paint-only additions keep that intent. The accessibility work from the previous pass is intact and re-checked: the white/55 contrast value, the roving tabindex and aria-controls wiring, and the mobile-menu focus return all survive. Known, judged acceptable: focus stays inside the menu during its 170ms exit fade and returns to the toggle on unmount; pointer interaction is disabled for that window. Drafted by Kimi K3 in Codewhale exec on an isolated worktree. Gates re-run here: 250 tests, eslint clean.
36 lines
1.0 KiB
TypeScript
36 lines
1.0 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 = () => {
|
|
if (typeof navigator !== "undefined" && navigator.clipboard) {
|
|
navigator.clipboard.writeText(cmd);
|
|
setCopied(true);
|
|
setTimeout(() => setCopied(false), 1400);
|
|
}
|
|
};
|
|
|
|
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>
|
|
);
|
|
}
|