commit 68647d02334e2e52fa37edaa06e1a4c0baabacb7
parent a9cf3f98597e1d2376911f9dde233bbde4c16705
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Wed, 14 Oct 2026 00:41:21 -0400
umtool: the primitives — Panel, Card, Tabs, Table, Field, Dialog, Stepper, Kbd, EmptyState, Toolbar, Verdict, LitList, ReaderPane, CiteThread
Server-safe cva like button.tsx and badge.tsx, which are restyled onto
the roles with their exports kept (button gains go and quiet: the one
filled Signal action, and the borderless secondary). LitList is the
signature: roving focus, j/k and the arrows, one lit line with the
Signal edge and play-head notch, a 120 ms glide that is instant under
reduced motion, nested groups, every button disabled until hydration.
ReaderPane puts a source on the pale reader with its cite thread and
the cited cue lit.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
18 files changed, 836 insertions(+), 23 deletions(-)
diff --git a/umtool/components/ui/badge.tsx b/umtool/components/ui/badge.tsx
@@ -9,28 +9,31 @@ import { cn } from "@/lib/utils";
// client component. /browse and /browse/decisions are server-rendered with
// their filters as plain links, and a Radix component would quietly end that.
//
-// The variants name PALETTE MEANINGS rather than shadcn's defaults, because the
-// palette's rule is that colour means something: `on` is the interaction colour
-// (the only one), and blocking/open/info are the three severities the decisions
-// inbox already speaks in. There is no `primary`/`secondary` pair here because
-// this app has no such distinction to make.
+// Two jobs, by size:
+// - `md` is the canvas's FILTER CHIP (`.chip`): UI type, an outline, and the
+// chosen one (`on`) a raised surface with an ink edge -- a selection is a
+// state of the desk, not a Signal (Signal is for the lit line and the one
+// primary action).
+// - `sm` is a STATUS TAG: mono, caps, in the colour of what it reports.
+// The variants name ROLES (app/globals.css): blocking/open are the reject and
+// doubt words, `meter` is a measurement, neutral/info are ink.
// ---------------------------------------------------------------------------
export const badgeVariants = cva(
- "inline-flex items-center rounded border px-1.5 py-0.5 font-mono text-[11px] transition-colors",
+ "inline-flex items-center gap-1.5 whitespace-nowrap rounded-[3px] border transition-colors",
{
variants: {
variant: {
- neutral: "border-border text-muted-foreground hover:text-foreground",
- on: "border-primary text-primary",
- blocking: "border-destructive text-destructive",
- open: "border-[var(--color-dirty)] text-[var(--color-dirty)]",
- info: "border-border text-muted-foreground",
- meter: "border-[var(--color-meter)] text-[var(--color-meter)]",
+ neutral: "border-seam-2 text-text-2 hover:text-text",
+ on: "border-muted bg-panel-2 text-text",
+ blocking: "border-reject-text text-reject-text",
+ open: "border-doubt-text text-doubt-text",
+ info: "border-seam-2 text-muted",
+ meter: "border-meter text-meter",
},
size: {
- sm: "px-1.5 py-0.5 text-[10px] uppercase tracking-wider",
- md: "",
+ sm: "px-1.5 py-px font-mono text-[10px] uppercase tracking-wider",
+ md: "px-2 py-[3px] text-[12px]",
},
},
defaultVariants: { variant: "neutral", size: "md" },
diff --git a/umtool/components/ui/button.tsx b/umtool/components/ui/button.tsx
@@ -4,26 +4,40 @@ import { cn } from "@/lib/utils";
// Same posture as badge.tsx: the variants are a class helper first, so a <Link>
// can wear them without hydrating, and a <button> second.
//
+// The canvas's three buttons, by role (app/globals.css, "COLOUR MEANS
+// SOMETHING"):
+// - `go` FILLED Signal. The ONE primary action on a screen -- what the
+// operator came here to do. Never two on a screen.
+// - `outline` the default: every other action is an outline in ink.
+// - `quiet` no border; secondary moves like Park, prev / next.
+// and three kept from before, restyled onto the roles:
+// - `primary` an outline in Signal: an action that is interaction-led
+// but not THE action (there are screens with several).
+// - `destructive` an outline in the reject word; deletes are plan-then-confirm.
+// - `ghost` an alias of `quiet`, for the call sites that already say it.
+//
// Hit sizes are the ones this app already uses. It is a bench somebody sits
// with for hours, so nothing here is smaller than what the existing controls
-// are, and `sm` is the default because dense is the point.
+// are, and dense is the point.
export const buttonVariants = cva(
- "inline-flex items-center justify-center gap-1.5 rounded border transition-colors disabled:pointer-events-none disabled:opacity-50 focus-visible:outline-none focus-visible:border-primary",
+ "inline-flex items-center justify-center gap-1.5 whitespace-nowrap rounded-[3px] border font-medium transition-colors disabled:pointer-events-none disabled:opacity-50",
{
variants: {
variant: {
- outline: "border-border text-muted-foreground hover:text-foreground hover:bg-accent",
+ go: "border-signal bg-signal font-semibold text-on-signal hover:bg-[color-mix(in_srgb,var(--signal)_86%,var(--text))]",
+ outline: "border-seam-2 text-text hover:border-muted hover:bg-panel-2",
primary:
- "border-primary text-primary hover:bg-[color-mix(in_srgb,var(--color-primary)_14%,transparent)]",
+ "border-signal text-signal-text hover:bg-[color-mix(in_srgb,var(--signal)_14%,transparent)]",
destructive:
- "border-destructive text-destructive hover:bg-[color-mix(in_srgb,var(--color-destructive)_14%,transparent)]",
- ghost: "border-transparent text-muted-foreground hover:text-foreground hover:bg-accent",
+ "border-reject-text text-reject-text hover:bg-[color-mix(in_srgb,var(--reject)_14%,transparent)]",
+ quiet: "border-transparent text-muted-2 hover:text-text hover:bg-panel-2",
+ ghost: "border-transparent text-muted-2 hover:text-text hover:bg-panel-2",
},
size: {
- sm: "px-2 py-1 text-[11px]",
- md: "px-2.5 py-1 text-[12px]",
- lg: "px-3 py-1.5 text-[13px]",
+ sm: "px-2 py-[3px] text-[11.5px]",
+ md: "px-[11px] py-[5px] text-[12.5px]",
+ lg: "px-3.5 py-1.5 text-[13.5px]",
},
},
defaultVariants: { variant: "outline", size: "md" },
diff --git a/umtool/components/ui/cite-thread.tsx b/umtool/components/ui/cite-thread.tsx
@@ -0,0 +1,46 @@
+import { cn } from "@/lib/utils";
+import { clock } from "./clock";
+
+// Where a cited second sits in its source (canvas `.cthread` / `.pthread`): a
+// hairline the length of the recording, a notch at the cite. Information, not
+// decoration -- a quote at 1:02:14 of a four-hour VOD reads differently from one
+// at 0:00:40 of a clip.
+//
+// On the DESK (a result line) it is one row with "at / of" on the right, and
+// shows on the lit line only (wrap it in `data-lit-only`); on the READER (a
+// pane's header) it carries 0:00, the cite and the end under the line.
+export function CiteThread({
+ at,
+ duration,
+ className,
+}: {
+ /** The cited second. */
+ at: number;
+ /** The recording's length, seconds. */
+ duration: number;
+ className?: string;
+}) {
+ const pct = duration > 0 ? Math.min(100, Math.max(0, (at / duration) * 100)) : 0;
+ const label = `${clock(at)} of ${clock(duration)}`;
+ return (
+ <div className={cn("cite-thread", className)} role="img" aria-label={`Cited at ${label}`} data-cite-at={at}>
+ <i style={{ left: `${pct}%` }} />
+ <span>
+ {clock(at)} / {clock(duration)}
+ </span>
+ </div>
+ );
+}
+
+/** The reader's version: start, cite and end under the line. */
+export function ReaderThread({ at, duration, className }: { at: number; duration: number; className?: string }) {
+ const pct = duration > 0 ? Math.min(100, Math.max(0, (at / duration) * 100)) : 0;
+ return (
+ <div className={cn("cite-thread mt-2.5", className)} role="img" aria-label={`Cited at ${clock(at)} of ${clock(duration)}`} data-cite-at={at}>
+ <i style={{ left: `${pct}%` }} />
+ <span style={{ left: 0 }}>0:00</span>
+ <span style={{ left: `calc(${pct}% - 22px)` }}>{clock(at)}</span>
+ <span style={{ left: "auto", right: 0 }}>{clock(duration)}</span>
+ </div>
+ );
+}
diff --git a/umtool/components/ui/clock.ts b/umtool/components/ui/clock.ts
@@ -0,0 +1,9 @@
+/** Seconds as a timecode: 4973 → "1:22:53", 58 → "0:58". */
+export function clock(s: number): string {
+ const t = Math.max(0, Math.floor(s));
+ const h = Math.floor(t / 3600);
+ const m = Math.floor((t % 3600) / 60);
+ const sec = t % 60;
+ const ss = String(sec).padStart(2, "0");
+ return h > 0 ? `${h}:${String(m).padStart(2, "0")}:${ss}` : `${m}:${ss}`;
+}
diff --git a/umtool/components/ui/dialog.tsx b/umtool/components/ui/dialog.tsx
@@ -0,0 +1,51 @@
+"use client";
+
+import { useEffect, useRef } from "react";
+import { cn } from "@/lib/utils";
+
+// A modal on the NATIVE <dialog>: the browser owns the focus trap, Escape, the
+// top layer and the inert page behind it, so there is nothing here to get
+// wrong. `open` drives showModal()/close(); `onClose` hears every way it closes
+// (Escape, a form with method="dialog", the backdrop is NOT one -- a stray click
+// should not throw away a half-typed reason).
+export function Dialog({
+ open,
+ onClose,
+ title,
+ className,
+ children,
+ ...props
+}: Omit<React.ComponentProps<"dialog">, "open" | "title"> & {
+ open: boolean;
+ onClose: () => void;
+ title: React.ReactNode;
+}) {
+ const ref = useRef<HTMLDialogElement>(null);
+ useEffect(() => {
+ const d = ref.current;
+ if (!d) return;
+ if (open && !d.open) d.showModal();
+ if (!open && d.open) d.close();
+ }, [open]);
+ return (
+ <dialog
+ ref={ref}
+ onClose={onClose}
+ className={cn(
+ "ui-dialog m-auto w-[min(560px,calc(100vw-32px))] rounded-[3px] border border-seam-2 bg-panel p-0 text-text shadow-2xl",
+ className,
+ )}
+ {...props}
+ >
+ <div className="flex items-baseline gap-3 border-b border-seam px-4 py-3">
+ <h2 className="text-[14px] font-semibold">{title}</h2>
+ <form method="dialog" className="ml-auto">
+ <button type="submit" aria-label="Close" className="px-1 text-muted-2 hover:text-text">
+ ✕
+ </button>
+ </form>
+ </div>
+ <div className="px-4 py-3">{children}</div>
+ </dialog>
+ );
+}
diff --git a/umtool/components/ui/empty-state.tsx b/umtool/components/ui/empty-state.tsx
@@ -0,0 +1,20 @@
+import { cn } from "@/lib/utils";
+
+// Nothing here, said plainly, with the one thing to do about it when there is
+// one. Copy rule: what is absent, literally ("No umtool job running"), never a
+// mood ("All caught up!").
+export function EmptyState({
+ title,
+ action,
+ className,
+ children,
+ ...props
+}: Omit<React.ComponentProps<"div">, "title"> & { title: React.ReactNode; action?: React.ReactNode }) {
+ return (
+ <div data-empty="" className={cn("py-6 text-center text-[12.5px] text-muted", className)} {...props}>
+ <p className="text-text-2">{title}</p>
+ {children && <div className="mt-1">{children}</div>}
+ {action && <div className="mt-3">{action}</div>}
+ </div>
+ );
+}
diff --git a/umtool/components/ui/field.tsx b/umtool/components/ui/field.tsx
@@ -0,0 +1,51 @@
+import { cn } from "@/lib/utils";
+
+// Form controls on the desk. Server-safe class helpers plus thin elements, so a
+// plain GET form (the /browse/find idiom) stays zero-JS.
+//
+// Field a label over a control, with a hint or an error under it. The
+// error says what to fix ("Slug: letters, digits and dashes only").
+// Input / Select / Textarea one look: panel ground, seam-2 edge, Signal on
+// focus (the global :focus-visible ring).
+
+export const controlClass =
+ "rounded-[3px] border border-seam-2 bg-panel px-2.5 py-[5px] text-[13px] text-text placeholder:text-muted-2 disabled:opacity-50";
+
+export function Field({
+ label,
+ hint,
+ error,
+ className,
+ children,
+ ...props
+}: Omit<React.ComponentProps<"label">, "title"> & {
+ label: React.ReactNode;
+ hint?: React.ReactNode;
+ error?: React.ReactNode;
+}) {
+ return (
+ <label className={cn("flex flex-col gap-1", className)} {...props}>
+ <span className="text-[12px] font-medium text-text-2">{label}</span>
+ {children}
+ {error ? (
+ <span role="alert" className="text-[12px] text-reject-text">
+ {error}
+ </span>
+ ) : hint ? (
+ <span className="text-[11.5px] text-muted">{hint}</span>
+ ) : null}
+ </label>
+ );
+}
+
+export function Input({ className, ...props }: React.ComponentProps<"input">) {
+ return <input className={cn(controlClass, className)} {...props} />;
+}
+
+export function Select({ className, ...props }: React.ComponentProps<"select">) {
+ return <select className={cn(controlClass, "pr-7", className)} {...props} />;
+}
+
+export function Textarea({ className, ...props }: React.ComponentProps<"textarea">) {
+ return <textarea className={cn(controlClass, "leading-relaxed", className)} {...props} />;
+}
diff --git a/umtool/components/ui/kbd.tsx b/umtool/components/ui/kbd.tsx
@@ -0,0 +1,19 @@
+import { cn } from "@/lib/utils";
+
+// A key, as the legend under a bench names it. The look is global (kbd in
+// app/globals.css), so a bare <kbd> in old markup matches this.
+export function Kbd({ className, ...props }: React.ComponentProps<"kbd">) {
+ return <kbd className={cn(className)} {...props} />;
+}
+
+/** A key and what it does: `<KeyHint keys={["j", "k"]}>cue</KeyHint>`. */
+export function KeyHint({ keys, children }: { keys: string[]; children: React.ReactNode }) {
+ return (
+ <span className="inline-flex items-center gap-1 text-[11.5px] text-muted-2">
+ {keys.map((k) => (
+ <kbd key={k}>{k}</kbd>
+ ))}
+ <span>{children}</span>
+ </span>
+ );
+}
diff --git a/umtool/components/ui/lit-line.tsx b/umtool/components/ui/lit-line.tsx
@@ -0,0 +1,65 @@
+import { cn } from "@/lib/utils";
+
+// The parts of a lit list that need no client JS (lit-list.tsx is the client
+// half): a LINE, a GROUP of lines under a head, and a line's ACTIONS, which show
+// on the lit line. Server components render these straight into a <LitList>.
+
+export function LitLine({
+ id,
+ initial = false,
+ className,
+ children,
+ ...props
+}: Omit<React.ComponentProps<"div">, "id"> & {
+ /** Announced in the list's `lit` event. */
+ id?: string;
+ /** Lit on load (beats the list's `initial` index). */
+ initial?: boolean;
+}) {
+ return (
+ <div
+ data-lit-line=""
+ data-lit-id={id}
+ data-lit-initial={initial ? "" : undefined}
+ tabIndex={-1}
+ className={cn("lit-line", className)}
+ {...props}
+ >
+ {children}
+ </div>
+ );
+}
+
+/** A line's actions: shown on the lit line, and on hover or keyboard focus. */
+export function LitActions({ className, ...props }: React.ComponentProps<"div">) {
+ return <div data-lit-act="" className={cn("flex items-center gap-1.5", className)} {...props} />;
+}
+
+/** Only on the lit line (the cite thread: on every row it was a barcode). */
+export function LitOnly({ className, ...props }: React.ComponentProps<"div">) {
+ return <div data-lit-only="" className={className} {...props} />;
+}
+
+export function LitGroup({
+ title,
+ count,
+ note,
+ className,
+ children,
+ ...props
+}: Omit<React.ComponentProps<"section">, "title"> & {
+ title: React.ReactNode;
+ count?: number | string;
+ note?: React.ReactNode;
+}) {
+ return (
+ <section className={cn("lit-group", className)} {...props}>
+ <div className="lit-group-head">
+ <h3 className="micro">{title}</h3>
+ {count !== undefined && <span className="font-mono text-[11.5px] text-meter">{count}</span>}
+ {note && <span className="ml-auto text-[11.5px] text-muted-2">{note}</span>}
+ </div>
+ {children}
+ </section>
+ );
+}
diff --git a/umtool/components/ui/lit-list.tsx b/umtool/components/ui/lit-list.tsx
@@ -0,0 +1,207 @@
+"use client";
+
+import { useCallback, useEffect, useRef } from "react";
+import { cn } from "@/lib/utils";
+import { useHydrated } from "./use-hydrated";
+
+// ---------------------------------------------------------------------------
+// THE LIT LINE -- the signature (plans/umtool-redesign.md, "Signature").
+//
+// Every list is a stack of lines; the focused one is LIT: a Signal edge with
+// the play-head notch, ink text, its actions shown. The others sit dim. `j`/`k`
+// (and the arrows) glide the head about 120 ms -- the app's only motion -- and
+// with reduced motion it jumps (--glide is 0 ms then, app/globals.css).
+//
+// Lines are found in the DOM, not passed as data: anything marked
+// `data-lit-line` inside this list is a line, however deep (LitGroup nests them
+// under a head), and the lines themselves can be server-rendered (lit-line.tsx).
+// A line inside ANOTHER list nested in this one belongs to that one.
+//
+// Focus ROVES: the lit line is the one Tab stop into the list, the keys move
+// focus with the light, and Tab from the lit line reaches its own buttons. A
+// click or a focus anywhere on a line lights it.
+//
+// Every button in the list is disabled until hydration (the house rule,
+// components/VerdictChip.tsx) -- a <fieldset disabled> does it for the whole
+// list at once, server-rendered, and lifts on the first client render.
+//
+// `lit` is announced as a DOM event, so a client parent can follow it:
+// el.addEventListener("lit", (e) => e.detail.index, e.detail.id)
+// ---------------------------------------------------------------------------
+
+export type LitDetail = { index: number; id: string | null };
+
+const TYPING = "input, textarea, select, [contenteditable=''], [contenteditable='true']";
+
+export function LitList({
+ label,
+ initial,
+ global = false,
+ onLight,
+ className,
+ children,
+}: {
+ /** The list's accessible name ("Results", "Decisions"). */
+ label: string;
+ /** The line lit on load, by index; a line marked `initial` wins over it. */
+ initial?: number;
+ /**
+ * `j`/`k` anywhere on the page move this list (when nothing is being typed
+ * in), not only with focus inside it. For the ONE list a page is about.
+ */
+ global?: boolean;
+ onLight?: (d: LitDetail) => void;
+ className?: string;
+ children: React.ReactNode;
+}) {
+ const hydrated = useHydrated();
+ const ref = useRef<HTMLDivElement>(null);
+ const head = useRef<HTMLElement>(null);
+ const lit = useRef(-1);
+ const onLightRef = useRef(onLight);
+ onLightRef.current = onLight;
+
+ const lines = useCallback((): HTMLElement[] => {
+ const root = ref.current;
+ if (!root) return [];
+ return [...root.querySelectorAll<HTMLElement>("[data-lit-line]")].filter(
+ (el) => el.closest("[data-lit-list]") === root,
+ );
+ }, []);
+
+ const place = useCallback(() => {
+ const root = ref.current;
+ const h = head.current;
+ if (!root || !h) return;
+ const el = lines()[lit.current];
+ if (!el) {
+ h.setAttribute("data-off", "");
+ return;
+ }
+ const r = el.getBoundingClientRect();
+ const base = root.getBoundingClientRect();
+ h.removeAttribute("data-off");
+ h.style.top = `${r.top - base.top}px`;
+ h.style.height = `${r.height}px`;
+ // The first placement must not glide in from the top of the list.
+ if (!h.hasAttribute("data-placed")) requestAnimationFrame(() => h.setAttribute("data-placed", ""));
+ }, [lines]);
+
+ const light = useCallback(
+ (i: number, opts: { focus?: boolean } = {}) => {
+ const all = lines();
+ if (!all.length) return;
+ const n = Math.max(0, Math.min(all.length - 1, i));
+ all.forEach((el, k) => {
+ if (k === n) el.setAttribute("data-lit", "");
+ else el.removeAttribute("data-lit");
+ el.tabIndex = k === n ? 0 : -1;
+ });
+ const el = all[n];
+ const changed = lit.current !== n;
+ lit.current = n;
+ place();
+ if (opts.focus) {
+ el.focus({ preventScroll: true });
+ el.scrollIntoView({ block: "nearest" });
+ }
+ if (changed) {
+ const detail: LitDetail = { index: n, id: el.dataset.litId ?? null };
+ ref.current?.dispatchEvent(new CustomEvent<LitDetail>("lit", { detail }));
+ onLightRef.current?.(detail);
+ }
+ },
+ [lines, place],
+ );
+
+ // Light the first line once the list is live, and follow its size.
+ useEffect(() => {
+ const root = ref.current;
+ if (!root) return;
+ const all = lines();
+ const marked = all.findIndex((el) => el.hasAttribute("data-lit-initial"));
+ light(marked >= 0 ? marked : (initial ?? 0));
+ const ro = new ResizeObserver(() => place());
+ ro.observe(root);
+ window.addEventListener("resize", place);
+ void document.fonts?.ready.then(place);
+ return () => {
+ ro.disconnect();
+ window.removeEventListener("resize", place);
+ };
+ // `initial` is read once: after that the operator owns the light.
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [lines, light, place]);
+
+ const step = useCallback(
+ (e: KeyboardEvent | React.KeyboardEvent) => {
+ if (e.metaKey || e.ctrlKey || e.altKey) return false;
+ const t = e.target as HTMLElement | null;
+ if (t?.closest?.(TYPING)) return false;
+ const k = e.key;
+ const last = lines().length - 1;
+ const to =
+ k === "j" || k === "ArrowDown"
+ ? lit.current + 1
+ : k === "k" || k === "ArrowUp"
+ ? lit.current - 1
+ : k === "Home"
+ ? 0
+ : k === "End"
+ ? last
+ : null;
+ if (to === null || last < 0) return false;
+ e.preventDefault();
+ light(to, { focus: true });
+ return true;
+ },
+ [light, lines],
+ );
+
+ // A page's ONE list can take j/k from anywhere that is not typing.
+ useEffect(() => {
+ if (!global) return;
+ const onKey = (e: KeyboardEvent) => {
+ if (e.defaultPrevented) return;
+ const inOther = (e.target as HTMLElement | null)?.closest?.("[data-lit-list]");
+ if (inOther && inOther !== ref.current) return;
+ if (e.key !== "j" && e.key !== "k") return;
+ step(e);
+ };
+ document.addEventListener("keydown", onKey);
+ return () => document.removeEventListener("keydown", onKey);
+ }, [global, step]);
+
+ const fromEvent = (target: EventTarget | null) => {
+ const el = (target as HTMLElement | null)?.closest?.<HTMLElement>("[data-lit-line]");
+ if (!el || el.closest("[data-lit-list]") !== ref.current) return -1;
+ return lines().indexOf(el);
+ };
+
+ return (
+ <div
+ ref={ref}
+ data-lit-list=""
+ data-hydrated={hydrated ? "" : undefined}
+ aria-label={label}
+ role="group"
+ className={cn("lit-list", className)}
+ onKeyDown={(e) => {
+ if (!global || (e.key !== "j" && e.key !== "k")) step(e);
+ }}
+ onClick={(e) => {
+ const i = fromEvent(e.target);
+ if (i >= 0 && i !== lit.current) light(i);
+ }}
+ onFocus={(e) => {
+ const i = fromEvent(e.target);
+ if (i >= 0 && i !== lit.current) light(i);
+ }}
+ >
+ <i ref={head} className="lit-head" data-off="" aria-hidden="true" />
+ <fieldset disabled={!hydrated} className="m-0 min-w-0 border-0 p-0">
+ {children}
+ </fieldset>
+ </div>
+ );
+}
diff --git a/umtool/components/ui/panel.tsx b/umtool/components/ui/panel.tsx
@@ -0,0 +1,49 @@
+import { cn } from "@/lib/utils";
+
+// The desk's two boxes (canvas `.block`, `.nextcard`). Server-safe.
+//
+// Panel a titled region of a page: a micro title, an optional aside on the
+// right of it (a count, an "all →" link), and the body.
+// Card one thing to act on, raised off the panel. `lit` gives it the
+// Signal edge -- the Next card, the one thing to do here.
+
+export function Panel({
+ title,
+ aside,
+ className,
+ children,
+ ...props
+}: Omit<React.ComponentProps<"section">, "title"> & { title?: React.ReactNode; aside?: React.ReactNode }) {
+ return (
+ <section className={cn("rounded-[3px] border border-seam bg-panel px-4 py-3", className)} {...props}>
+ {(title || aside) && (
+ <div className="mb-2 flex items-baseline gap-3">
+ {title && <h2 className="micro">{title}</h2>}
+ {aside && <div className="ml-auto text-[12px]">{aside}</div>}
+ </div>
+ )}
+ {children}
+ </section>
+ );
+}
+
+export function Card({
+ lit = false,
+ className,
+ children,
+ ...props
+}: React.ComponentProps<"div"> & { lit?: boolean }) {
+ return (
+ <div
+ className={cn(
+ "relative rounded-[3px] border border-seam-2 bg-panel px-4 py-3",
+ lit &&
+ "before:absolute before:-left-px before:-top-px before:-bottom-px before:w-[3px] before:rounded-l-[3px] before:bg-signal before:content-['']",
+ className,
+ )}
+ {...props}
+ >
+ {children}
+ </div>
+ );
+}
diff --git a/umtool/components/ui/reader-pane.tsx b/umtool/components/ui/reader-pane.tsx
@@ -0,0 +1,114 @@
+import { cva } from "class-variance-authority";
+import { cn } from "@/lib/utils";
+import { ReaderThread } from "./cite-thread";
+import { clock } from "./clock";
+import { LitList } from "./lit-list";
+import { LitLine } from "./lit-line";
+
+// ---------------------------------------------------------------------------
+// THE READER (canvas `.paper`): anything a SOURCE said -- a transcript window,
+// a quote, a post -- on the pale microfilm surface, apart from the desk. Paper
+// is the record; ink is our work. Wherever something cited is focused (Inbox,
+// Research, an article, the claim bench) it is this component.
+//
+// header the source's title; channel · date · track; the cite thread
+// (start, the cite, the end) when the cite and the length are known
+// body the cues as a lit list, the cited cue lit; `»` marks a change of
+// speaker when the transcript knows one
+// footer the actions (paperButtonVariants), and a fine line (the citation)
+//
+// Rules from the canvas critique: no verdict colour on the reader, ever; the
+// reader's own Signal is `--reader-signal`, a teal dark enough for the paper.
+// ---------------------------------------------------------------------------
+
+export type Cue = { t: number; text: React.ReactNode; turn?: boolean; lit?: boolean; id?: string };
+
+export const paperButtonVariants = cva(
+ "inline-flex items-center justify-center gap-1.5 whitespace-nowrap rounded-[3px] border px-[11px] py-[5px] text-[12.5px] font-medium transition-colors disabled:pointer-events-none disabled:opacity-50",
+ {
+ variants: {
+ variant: {
+ outline: "border-reader-2 text-reader-ink hover:border-reader-ink",
+ go: "border-reader-signal bg-reader-signal font-semibold text-white",
+ },
+ },
+ defaultVariants: { variant: "outline" },
+ },
+);
+
+export function ReaderPane({
+ source,
+ byline,
+ cite,
+ note,
+ cues,
+ label = "Transcript",
+ footer,
+ fine,
+ className,
+ children,
+ ...props
+}: Omit<React.ComponentProps<"aside">, "children"> & {
+ /** The source's title. */
+ source: React.ReactNode;
+ /** channel · date · track, as nodes; joined with a middle dot. */
+ byline?: React.ReactNode[];
+ /** The cited second and the recording's length, for the thread. */
+ cite?: { at: number; duration: number };
+ /** A line under the header ("Speaker not identified"). */
+ note?: React.ReactNode;
+ cues?: Cue[];
+ label?: string;
+ footer?: React.ReactNode;
+ /** The fine print under the actions: the citation in the house format. */
+ fine?: React.ReactNode;
+ /** Instead of cues: anything else the source said (a post, a quote). */
+ children?: React.ReactNode;
+}) {
+ const parts = (byline ?? []).filter(Boolean);
+ return (
+ <aside aria-label="Reader" data-reader="" className={cn("reader", className)} {...props}>
+ <div className="border-b border-reader-seam px-[22px] pb-3 pt-4">
+ <div className="text-[13px] font-semibold leading-snug">{source}</div>
+ {parts.length > 0 && (
+ <div className="mt-[3px] text-[12px] text-reader-dim">
+ {parts.map((p, i) => (
+ <span key={i}>
+ {i > 0 && " · "}
+ {p}
+ </span>
+ ))}
+ </div>
+ )}
+ {cite && <ReaderThread at={cite.at} duration={cite.duration} />}
+ </div>
+ {note && <div className="px-[22px] pt-2 text-[11.5px] text-reader-dim">{note}</div>}
+ <div className="min-h-0 flex-1 overflow-auto py-2 pr-2.5">
+ {cues ? (
+ <LitList label={label}>
+ {cues.map((c, i) => (
+ <LitLine
+ key={c.id ?? `${c.t}-${i}`}
+ id={c.id}
+ initial={c.lit}
+ className="reader-cue"
+ data-turn={c.turn ? "" : undefined}
+ >
+ <span className="reader-t">{clock(c.t)}</span>
+ <p>{c.text}</p>
+ </LitLine>
+ ))}
+ </LitList>
+ ) : (
+ <div className="reader-text px-[22px]">{children}</div>
+ )}
+ </div>
+ {(footer || fine) && (
+ <div className="flex flex-wrap items-center gap-2 border-t border-reader-seam px-[22px] pb-3.5 pt-3">
+ {footer}
+ {fine && <span className="basis-full font-mono text-[11px] text-reader-dim">{fine}</span>}
+ </div>
+ )}
+ </aside>
+ );
+}
diff --git a/umtool/components/ui/stepper.tsx b/umtool/components/ui/stepper.tsx
@@ -0,0 +1,31 @@
+import { cn } from "@/lib/utils";
+
+// The stage stepper (canvas `.stepper`): Research → Article → Video → Deliver.
+// Done stages are ink, the current one Signal, the rest seams. Information, not
+// navigation: it says where a piece is, and the page's tabs take you there.
+export type Step = { label: string; state: "done" | "current" | "todo" };
+
+export function Stepper({ steps, className, ...props }: React.ComponentProps<"ol"> & { steps: Step[] }) {
+ return (
+ <ol className={cn("flex flex-wrap items-center", className)} aria-label="Stage" {...props}>
+ {steps.map((s, i) => (
+ <li key={s.label} data-step={s.state} className="flex items-center" aria-current={s.state === "current" ? "step" : undefined}>
+ {i > 0 && (
+ <span aria-hidden="true" className={cn("mx-2.5 h-px w-10", s.state === "todo" ? "bg-seam-2" : "bg-text-2")} />
+ )}
+ <span
+ className={cn(
+ "flex items-center gap-[7px] text-[12.5px]",
+ s.state === "done" && "text-text-2",
+ s.state === "current" && "font-semibold text-text",
+ s.state === "todo" && "text-muted-2",
+ )}
+ >
+ <i className="stepper-dot" aria-hidden="true" />
+ {s.label}
+ </span>
+ </li>
+ ))}
+ </ol>
+ );
+}
diff --git a/umtool/components/ui/table.tsx b/umtool/components/ui/table.tsx
@@ -0,0 +1,33 @@
+import { cn } from "@/lib/utils";
+
+// A data table on the desk (canvas `.itab`): hairline rows, micro heads, mono
+// for anything that is a number. Plain elements with the look attached, so a
+// server page builds one with no client JS.
+export function Table({ className, ...props }: React.ComponentProps<"table">) {
+ return (
+ <div className="overflow-x-auto">
+ <table className={cn("w-full border-collapse text-[12.5px]", className)} {...props} />
+ </div>
+ );
+}
+
+export function TH({ className, ...props }: React.ComponentProps<"th">) {
+ return (
+ <th
+ className={cn(
+ "border-b border-seam px-1.5 py-[7px] text-left text-[10.5px] font-semibold uppercase tracking-[0.08em] text-muted",
+ className,
+ )}
+ {...props}
+ />
+ );
+}
+
+export function TD({ className, numeric = false, ...props }: React.ComponentProps<"td"> & { numeric?: boolean }) {
+ return (
+ <td
+ className={cn("border-b border-seam px-1.5 py-[7px] align-top text-text-2", numeric && "font-mono text-[12px] text-right", className)}
+ {...props}
+ />
+ );
+}
diff --git a/umtool/components/ui/tabs.tsx b/umtool/components/ui/tabs.tsx
@@ -0,0 +1,35 @@
+import Link from "next/link";
+import { cn } from "@/lib/utils";
+
+// Tabs that are LINKS (canvas `.tabs`): each tab is an address, so a tab is
+// bookmarkable, the back button works, and a server page renders the right one
+// with no client state. The current one carries `aria-current="page"` and the
+// Signal underline; a count sits beside its label in Meter.
+export type TabItem = { href: string; label: React.ReactNode; current?: boolean; count?: number | string; testid?: string };
+
+export function Tabs({
+ items,
+ label,
+ className,
+ ...props
+}: React.ComponentProps<"nav"> & { items: TabItem[]; label: string }) {
+ return (
+ <nav aria-label={label} className={cn("flex flex-wrap gap-0.5 border-b border-seam", className)} {...props}>
+ {items.map((t) => (
+ <Link
+ key={t.href}
+ href={t.href}
+ data-testid={t.testid}
+ aria-current={t.current ? "page" : undefined}
+ className={cn(
+ "-mb-px border-b-2 px-3 pb-2 pt-2.5 text-[13px] no-underline",
+ t.current ? "border-signal text-text" : "border-transparent text-muted-2 hover:text-text",
+ )}
+ >
+ {t.label}
+ {t.count !== undefined && <span className="ml-1.5 font-mono text-[11px] text-meter">{t.count}</span>}
+ </Link>
+ ))}
+ </nav>
+ );
+}
diff --git a/umtool/components/ui/toolbar.tsx b/umtool/components/ui/toolbar.tsx
@@ -0,0 +1,27 @@
+import { cn } from "@/lib/utils";
+
+// A row of controls over a list: filters left, actions right (canvas
+// `.facetbar`). `ToolbarGroup` is one labelled cluster ("Stage", "Kind").
+export function Toolbar({ className, ...props }: React.ComponentProps<"div">) {
+ return (
+ <div
+ role="toolbar"
+ className={cn("flex flex-wrap items-center gap-x-4 gap-y-2 border-b border-seam px-4 py-2.5", className)}
+ {...props}
+ />
+ );
+}
+
+export function ToolbarGroup({
+ label,
+ className,
+ children,
+ ...props
+}: React.ComponentProps<"div"> & { label?: React.ReactNode }) {
+ return (
+ <div className={cn("flex flex-wrap items-center gap-1", className)} {...props}>
+ {label && <span className="micro mr-1">{label}</span>}
+ {children}
+ </div>
+ );
+}
diff --git a/umtool/components/ui/use-hydrated.ts b/umtool/components/ui/use-hydrated.ts
@@ -0,0 +1,17 @@
+"use client";
+
+import { useSyncExternalStore } from "react";
+
+// FALSE on the server and through hydration, TRUE from the first client render
+// after it. The house rule (components/VerdictChip.tsx): a button is disabled
+// until this is true, because a click that lands before React hydrates fires
+// nothing at all -- no request, no error -- and an action lost that way looks
+// like one never taken.
+const subscribe = () => () => {};
+export function useHydrated(): boolean {
+ return useSyncExternalStore(
+ subscribe,
+ () => true,
+ () => false,
+ );
+}
diff --git a/umtool/components/ui/verdict.tsx b/umtool/components/ui/verdict.tsx
@@ -0,0 +1,22 @@
+import { cn } from "@/lib/utils";
+
+// A judgement: glyph AND word, never colour alone (canvas `.v`). The glyph
+// carries the verdict colour; the word takes its text step, which in light is
+// darker than the glyph (app/globals.css, "COLOUR MEANS SOMETHING").
+//
+// Desk only. A verdict never sits on the reader: the record carries no
+// judgement, and on the pale surface the hues collapse for colour-blind eyes.
+export type VerdictKind = "kept" | "doubt" | "reject";
+
+export function Verdict({
+ kind,
+ className,
+ children,
+ ...props
+}: React.ComponentProps<"span"> & { kind: VerdictKind }) {
+ return (
+ <span data-verdict={kind} className={cn("verdict", className)} {...props}>
+ {children}
+ </span>
+ );
+}