import { useState } from "react";
import Link from "next/link";
import TermOutput from "./TermOutput";
const JUMP = [
{ id: "kit", label: "Kit" },
{ id: "problem", label: "Problem" },
{ id: "actors", label: "Actors" },
{ id: "setup", label: "Setup" },
{ id: "safeguards", label: "Safeguards" },
{ id: "method", label: "Method" },
{ id: "evidence", label: "Evidence" },
{ id: "tryit", label: "Try-it" },
];
function ShieldCheck() {
return (
);
}
function CheckMark() {
return (
);
}
async function copyText(text) {
try {
await navigator.clipboard.writeText(text);
return true;
} catch {
try {
const el = document.createElement("textarea");
el.value = text;
el.setAttribute("readonly", "");
el.style.position = "fixed";
el.style.left = "-9999px";
document.body.appendChild(el);
el.select();
const ok = document.execCommand("copy");
el.remove();
return ok;
} catch {
return false;
}
}
}
function WorkflowKit({ recipe }) {
const k = recipe.kit;
if (!k) return null;
const rows = [
["You run", k.youRun],
["Tools", (k.tools || []).join(" · ")],
["Files", (k.files || []).join(" · ")],
["Model", k.model],
["Time", recipe.time],
["Cost", recipe.cost],
["You produce", k.artifact],
].filter(([, v]) => v);
return (
{rows.map(([label, value]) => (
- {label}
- {value}
))}
);
}
function Field({ anchor, name, label, children }) {
return (
);
}
export default function WorkflowBlock({
recipe,
complete = false,
onToggleComplete,
focused = false,
index = 1,
total = 1,
}) {
const [copied, setCopied] = useState(false);
const a = recipe.anchor;
const onShare = async () => {
const ok = await copyText(recipe.shareBlurb);
if (!ok) return;
setCopied(true);
window.setTimeout(() => setCopied(false), 1800);
};
return (
Workflow {index} of {total} · {recipe.id} · v{recipe.version} · {recipe.time} · {recipe.cost}
{recipe.vertical}
{recipe.title}
{recipe.problem} {recipe.problemJob}
{recipe.actors.map((line) => (
- {line}
))}
{recipe.setup.map((line) => (
- {line}
))}
{recipe.safeguards.map((line) => (
{line}
))}
{recipe.method.map((step, i) => (
-
{step.text}
{step.term ? : null}
))}
{recipe.evidence.map((line) => (
{line}
))}
About {recipe.tryit.minutes} minutes. {recipe.tryit.sample}{" "}
{recipe.tryit.produce}
{recipe.tryit.done}{" "}
{recipe.tryit.hrefLabel}
◷ {recipe.tryit.chip}
{onToggleComplete ? (
) : null}
Copy a short result line. Share the outcome, not the recipe text.
Author: {recipe.author}
Sources: {recipe.sources}
Last updated: {recipe.lastUpdated}
{focused ? (
Back to the chapter
) : (
Open on paper
)}
);
}