import { useState } from "preact/hooks"; import { signal } from "@preact/signals"; import { config } from "../state"; import { composeCode, highlightPython } from "../content/code"; export const codeModalOpen = signal(false); export function PyTorchCodeModal() { if (!codeModalOpen.value) return null; const cfg = config.value; const code = composeCode(cfg); const html = highlightPython(code); const [copied, setCopied] = useState(false); async function copy() { try { await navigator.clipboard.writeText(code); setCopied(true); setTimeout(() => setCopied(false), 1200); } catch { setCopied(false); } } return ( ); }