/** * Accepted comment threads, in the prose. * * Accepted threads are durable plan content, rendered from their frozen record. * Collapsed they are one line that states the outcome; the quote and thread open on demand. */ import { useCellValue } from "@mdxeditor/gurx"; import { useId, useState } from "react"; import { ChevronIcon, MessageIcon } from "@chopin/icons"; import { when } from "../card"; import { MotionDisclosure, MotionDisclosureIcon } from "../disclosure-motion"; import { widgets$ } from "../widget-options"; import type { Decision, DecisionNode } from "@chopin/dialect"; import type { MotionDisclosureContract } from "../disclosure-motion"; export function DecisionCard( { defaultOpen = false, immediately = false, motion, value }: { defaultOpen?: boolean; immediately?: boolean; motion?: MotionDisclosureContract; value: Decision; }, ) { let [open, setOpen] = useState(defaultOpen); let bodyId = useId(); let stamp = value.at === undefined ? "" : when(value.at); let outcome = value.notes.at(-1)?.text ?? value.quote; let body = (
{value.quote}
{value.by && <>Accepted by @{value.by}} {stamp && ` · ${stamp}`}
); return (
{motion ? ( {body} ) : open &&
{body}
}
); } function AcceptedComment({ value }: { value: Decision }) { let options = useCellValue(widgets$); return ( ); } export function renderDecision(node: DecisionNode) { return ; }