Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit 762161e6ae08824133b3e8f205f722c828b63cf3
parent 68647d02334e2e52fa37edaa06e1a4c0baabacb7
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Wed, 14 Oct 2026 00:41:21 -0400

umtool: AppShell and the rail; BrowseHeader wraps it with the same props

The rail (fixed, left; the body pads for it) carries the mark and the
one-word wordmark, today's places (home · browse · decisions · articles ·
mix · find · song ▸, unchanged until P3), + Create, the jump hint,
Pinned, Running (umtool's own job) and the Auto / Light / Dark control.
The page head is one Breadcrumb nav whose last crumb is the h1 in Archivo;
the note stays the header's last .micro. BrowseHeader renders AppShell
with the same props, so its 22 users change nothing; the hand-rolled
headers of /, /mix and the song deck move onto it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
Mumtool/app/[mode]/page.tsx | 16+++++++++++-----
Mumtool/app/mix/page.tsx | 43+++++++++++++++++++++----------------------
Mumtool/app/page.tsx | 19+++++++++++--------
Mumtool/components/AppNav.tsx | 68+++++++++++++++++++++++++++++---------------------------------------
Mumtool/components/BrowseHeader.tsx | 38+++++++++++---------------------------
Mumtool/components/Deck.tsx | 42+++++++++++++++++++++++-------------------
Mumtool/components/NavGroup.tsx | 39++++++++++++++-------------------------
Aumtool/components/shell/AppHeader.tsx | 105+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aumtool/components/shell/AppRail.tsx | 92+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aumtool/components/shell/AppShell.tsx | 47+++++++++++++++++++++++++++++++++++++++++++++++
Aumtool/components/shell/CreateMenu.tsx | 52++++++++++++++++++++++++++++++++++++++++++++++++++++
Aumtool/components/shell/ThemeControl.tsx | 38++++++++++++++++++++++++++++++++++++++
Aumtool/components/shell/Wordmark.tsx | 29+++++++++++++++++++++++++++++
13 files changed, 483 insertions(+), 145 deletions(-)

diff --git a/umtool/app/[mode]/page.tsx b/umtool/app/[mode]/page.tsx @@ -4,6 +4,7 @@ import { isMode } from "@/lib/types"; import { CURATED, COMPOUNDS, readVocab } from "@/lib/vocab"; import { REASONS, OTHER_CODE } from "../../song/reasons.mjs"; import Deck from "@/components/Deck"; +import AppRail from "@/components/shell/AppRail"; export const dynamic = "force-dynamic"; @@ -28,11 +29,16 @@ export default async function ModePage({ }); const custom = await readVocab(); + // The deck is a client component and the rail reads the server, so the rail + // is rendered here and the deck draws only its own head (AppHeader). return ( - <Deck - page={page} - vocab={{ curated: CURATED, compounds: COMPOUNDS, custom }} - reasons={{ bad: REASONS.bad, dirty: REASONS.dirty, other: OTHER_CODE }} - /> + <> + <AppRail active={mode} /> + <Deck + page={page} + vocab={{ curated: CURATED, compounds: COMPOUNDS, custom }} + reasons={{ bad: REASONS.bad, dirty: REASONS.dirty, other: OTHER_CODE }} + /> + </> ); } diff --git a/umtool/app/mix/page.tsx b/umtool/app/mix/page.tsx @@ -1,5 +1,5 @@ import Link from "next/link"; -import AppNav from "@/components/AppNav"; +import AppShell from "@/components/shell/AppShell"; import MixBench from "@/components/MixBench"; import { MEDIA_ROOTS } from "@/lib/paths"; import { isRefusal, resolvePreset } from "@/lib/mix-preset"; @@ -25,33 +25,32 @@ export default async function MixPage({ return ( <div className="flex h-full flex-col"> - <header className="flex flex-wrap items-center gap-3 border-b border-[var(--color-line)] bg-[var(--color-panel)] px-4 py-2"> - <AppNav active="mix" /> - {preset?.fromHref ? ( - <Link - href={preset.fromHref} - className="text-[12px] text-[var(--color-sel)] hover:underline" - data-mix-from={preset.from ?? ""} - > - ← {preset.from} - {preset.clip ? ` / ${preset.clip}` : ""} - </Link> - ) : ( - <div className="text-[12px] text-[var(--color-dim)]"> - set the handover and the end point, hear it, then render it - </div> - )} - <div className="num ml-auto hidden text-[10px] text-[var(--color-dim)] lg:block"> - {MEDIA_ROOTS.length} roots - </div> - </header> + <AppShell + active="mix" + crumbs={[{ label: "mix" }]} + meta={ + preset?.fromHref ? ( + <Link + href={preset.fromHref} + className="text-[12.5px] text-signal-text hover:underline" + data-mix-from={preset.from ?? ""} + > + ← {preset.from} + {preset.clip ? ` / ${preset.clip}` : ""} + </Link> + ) : ( + "set the handover and the end point, hear it, then render it" + ) + } + note={<span className="num hidden lg:inline">{MEDIA_ROOTS.length} roots</span>} + /> {refused && ( // Refused, not clamped. A link that quietly opened a DIFFERENT file than // it named would be worse than this message. <p data-mix-refused="" - className="border-b border-[var(--color-bad)] bg-[color-mix(in_srgb,var(--color-bad)_10%,transparent)] px-4 py-2 text-[12px] text-[var(--color-bad)]" + className="border-b border-reject-text bg-[color-mix(in_srgb,var(--reject)_10%,transparent)] px-4 py-2 text-[12.5px] text-reject-text" > that link was refused — {refused.reason} </p> diff --git a/umtool/app/page.tsx b/umtool/app/page.tsx @@ -1,5 +1,4 @@ import { statfs } from "node:fs/promises"; -import AppNav from "@/components/AppNav"; import DecisionsPanel from "@/components/dashboard/DecisionsPanel"; import DeliverablesPanel from "@/components/dashboard/DeliverablesPanel"; import NowPanel from "@/components/dashboard/NowPanel"; @@ -9,6 +8,7 @@ import SourcesPanel from "@/components/dashboard/SourcesPanel"; import StateStrip from "@/components/dashboard/StateStrip"; import ToolsPanel from "@/components/dashboard/ToolsPanel"; import NewProjectMenu from "@/components/NewProjectMenu"; +import AppShell from "@/components/shell/AppShell"; import ProjectGrid from "@/components/projects/ProjectGrid"; import { listActivity, runningActivity } from "@/lib/activity"; import { projectsNote, sourceBuckets, stateRows } from "@/lib/dashboard"; @@ -60,13 +60,16 @@ export default async function Home({ return ( <div className="flex h-full flex-col"> - <header className="flex flex-wrap items-center gap-3 border-b border-[var(--color-line)] bg-[var(--color-panel)] px-4 py-2"> - <AppNav active="home" /> - <ResumeChip /> - <div className="ml-auto flex items-center gap-2"> - <NewProjectMenu kinds={KINDS.map((k) => ({ id: k.id, label: k.label, scaffold: k.scaffold }))} from={from ?? null} /> - </div> - </header> + <AppShell + active="home" + crumbs={[{ label: "home" }]} + actions={ + <> + <ResumeChip /> + <NewProjectMenu kinds={KINDS.map((k) => ({ id: k.id, label: k.label, scaffold: k.scaffold }))} from={from ?? null} /> + </> + } + /> <main className="deck-main flex-1 p-4"> <div className="grid gap-3 lg:grid-cols-2 2xl:grid-cols-3"> diff --git a/umtool/components/AppNav.tsx b/umtool/components/AppNav.tsx @@ -1,67 +1,57 @@ import Link from "next/link"; import { MODES } from "@/lib/types"; +import { articlesHref, browseHref, decisionsHref, findHref, homeHref, mixHref, pileHref, sourcesHref } from "@/lib/hrefs"; import NavGroup from "./NavGroup"; // The places, in the order somebody works: the dashboard, every project, what -// is waiting, the two benches that are not a project (mix, find), and the song -// piles folded under one entry. +// is waiting, the articles, the two benches that are not a project (mix, find), +// and the song piles folded under one entry. They are the rail's list now +// (components/shell/AppRail.tsx), one place per line. // -// SEVEN visible entries (home, browse, decisions, articles, mix, find, song ▸), -// and the cap is still NINE. A tenth wraps the header on -// a laptop, and a nav that wraps stops reading as one row of places and starts -// reading as a list. The next tool goes UNDER one of these, not beside them -- -// which is exactly what happened to the four judging piles and the sources -// page: they are the `song ▸` group now, at the same URLs they always had, so -// `/sort`, `/keeps` and every bookmark still land where they did. +// These are TODAY's places, kept as they were -- labels included, since the +// specs name them -- until P3 (plans/umtool-redesign.md) makes the rail Inbox · +// Research · Work · Tools · Settings. The next tool goes UNDER one of these, not +// beside them: the four judging piles and the sources page are the `song ▸` +// group, at the same URLs they always had, so `/sort`, `/keeps` and every +// bookmark still land where they did. // -// The active link is `sel`, the one interaction colour. It used to be -// `--color-accent`, a second green two inches from `--color-good` on a verdict -// button -- a NAVIGATION state wearing a VERDICT's colour -- and accent is gone -// rather than retuned. +// The place you are in carries `aria-current="page"` and the Signal edge (the +// lit line, at rest; app/globals.css `.app-places`). It used to be +// `--color-accent`, a second green two inches from a verdict button -- a +// NAVIGATION state wearing a VERDICT's colour -- and accent is gone rather than +// retuned. const SONG_ITEMS = [ - ...MODES.map((m) => ({ href: `/${m}`, label: m as string })), + ...MODES.map((m) => ({ href: pileHref(m), label: m as string })), // Where the palette comes from, across every song at once. - { href: "/browse/sources", label: "sources" }, + { href: sourcesHref(), label: "sources" }, ]; export default function AppNav({ active }: { active: string }) { const items = [ - { href: "/", label: "home" }, - { href: "/browse", label: "browse" }, + { href: homeHref(), label: "home" }, + { href: browseHref(), label: "browse" }, // The worklist across every project, not a sixth pile. It sits beside // browse because that is where every decision it names gets settled. - { href: "/browse/decisions", label: "decisions" }, + { href: decisionsHref(), label: "decisions" }, // The articles -- the homepage's (/articles, release 26) and every site's // own pages (/sites, linked from it) -- published and drafts, with their // notes, their evidence and the workspace they were written in. Both pages // mark this entry: the editor's /sites is the sites themselves, and two // "sites" a tab apart were two places with one name. - { href: "/articles", label: "articles" }, - { href: "/mix", label: "mix" }, + { href: articlesHref(), label: "articles" }, + { href: mixHref(), label: "mix" }, // Every occurrence of a word across the corpus. It sits with browse because // what it retrieves is raw material for a build, not a pile to judge. - { href: "/browse/find", label: "find" }, + { href: findHref(), label: "find" }, ]; const songActive = SONG_ITEMS.some((it) => it.label === active); return ( - <nav className="flex gap-1" aria-label="Main"> - {items.map((it) => { - const on = it.label === active; - return ( - <Link - key={it.href} - href={it.href} - aria-current={on ? "page" : undefined} - className={`rounded px-2.5 py-1 text-sm ${ - on - ? "bg-[var(--color-panel-2)] text-[var(--color-sel)]" - : "text-[var(--color-dim)] hover:text-[var(--color-text)]" - }`} - > - {it.label} - </Link> - ); - })} + <nav className="app-places grid gap-px px-2 py-1 text-[13.5px]" aria-label="Main"> + {items.map((it) => ( + <Link key={it.href} href={it.href} aria-current={it.label === active ? "page" : undefined}> + {it.label} + </Link> + ))} <NavGroup label="song" items={SONG_ITEMS} active={active} on={songActive} /> </nav> ); diff --git a/umtool/components/BrowseHeader.tsx b/umtool/components/BrowseHeader.tsx @@ -1,14 +1,17 @@ -import Link from "next/link"; -import AppNav from "@/components/AppNav"; +import AppShell from "@/components/shell/AppShell"; +import type { Crumb } from "@/components/shell/AppHeader"; -export type Crumb = { href?: string; label: string }; +export type { Crumb }; /** - * The header the three browse levels share. + * The header the browse levels share -- now a thin wrapper over the shell + * (components/shell/AppShell.tsx): the rail, and the page head with these + * crumbs and this note. * - * app/mix/page.tsx writes its header inline, which is fine for one page. Three - * copies of it would be two too many, and the breadcrumb is the only part that - * differs between the levels. + * Kept, with the SAME props, until P6 deletes it: it has 22 call sites, + * release 28's ReportProject, NarrationPage and app/bench/page.tsx among them, + * and every one of them gets the rail by changing nothing. New pages use + * AppShell directly. */ export default function BrowseHeader({ crumbs, @@ -20,24 +23,5 @@ export default function BrowseHeader({ /** Which nav item is lit. Defaults to browse, which is the common case. */ active?: string; }) { - return ( - <header className="flex flex-wrap items-center gap-3 border-b border-[var(--color-line)] bg-[var(--color-panel)] px-4 py-2"> - <AppNav active={active} /> - <nav className="flex items-center gap-1.5 text-[12px]" aria-label="Breadcrumb"> - {crumbs.map((c, i) => ( - <span key={`${c.label}-${i}`} className="flex items-center gap-1.5"> - {i > 0 && <span className="text-[var(--color-line)]">/</span>} - {c.href ? ( - <Link href={c.href} className="text-[var(--color-dim)] hover:text-[var(--color-text)]"> - {c.label} - </Link> - ) : ( - <span className="text-[var(--color-text)]">{c.label}</span> - )} - </span> - ))} - </nav> - {note && <div className="micro ml-auto">{note}</div>} - </header> - ); + return <AppShell active={active} crumbs={crumbs} note={note} />; } diff --git a/umtool/components/Deck.tsx b/umtool/components/Deck.tsx @@ -1,7 +1,7 @@ "use client"; import { useCallback, useEffect, useMemo, useRef, useState } from "react"; -import AppNav from "./AppNav"; +import AppHeader from "./shell/AppHeader"; import PitchRail, { type CorpusPitch } from "./PitchRail"; import Waveform, { type Peaks } from "./Waveform"; import WordSelector, { type Vocab } from "./WordSelector"; @@ -1004,24 +1004,28 @@ export default function Deck({ page, vocab: initialVocab, reasons }: Props) { const header = useMemo( () => ( - <header className="flex flex-wrap items-center gap-3 border-b border-[var(--color-line)] bg-[var(--color-panel)] px-4 py-2"> - <AppNav active={mode} /> - <div className="text-[12px] text-[var(--color-dim)]"> - {clips.length} on this page of {total} · {orderNote} - </div> - <div className="ml-auto flex gap-4 text-[12px]"> - <span> - palette <b className="text-[var(--color-good)]">{counts.accepted}</b> - </span> - <span> - unclean <b className="text-[var(--color-dirty)]">{counts.unclean}</b> - </span> - <span> - dirty <b>{counts.impure}</b> - </span> - <span className="text-[var(--color-dim)]">rejected {counts.rejected}</span> - </div> - </header> + <AppHeader + crumbs={[{ label: "song" }, { label: mode }]} + meta={ + <> + {clips.length} on this page of {total} · {orderNote} + </> + } + actions={ + <div className="flex gap-4 text-[12.5px]"> + <span> + palette <b className="num text-[var(--color-good)]">{counts.accepted}</b> + </span> + <span> + unclean <b className="num text-[var(--color-dirty)]">{counts.unclean}</b> + </span> + <span> + dirty <b className="num">{counts.impure}</b> + </span> + <span className="text-muted">rejected {counts.rejected}</span> + </div> + } + /> ), [mode, clips.length, total, orderNote, counts], ); diff --git a/umtool/components/NavGroup.tsx b/umtool/components/NavGroup.tsx @@ -3,12 +3,14 @@ import Link from "next/link"; import { useEffect, useRef, useState } from "react"; -// One nav entry that opens into several. Click (or Enter/Space) to expand, +// One rail entry that opens into several. Click (or Enter/Space) to expand, // Escape or a click elsewhere to close; the items are real links, so the // keyboard reaches every one of them and the URLs are unchanged. // -// Native <details> would do most of this with no JS, but it cannot close on an -// outside click and it renders its own marker; this is small enough to own. +// It opens IN PLACE, under its button, not as a popover: the rail scrolls, and +// a popover inside it would be clipped. Native <details> would do most of this +// with no JS, but it cannot close on an outside click and it renders its own +// marker; this is small enough to own. export default function NavGroup({ label, items, @@ -40,26 +42,15 @@ export default function NavGroup({ }, [open]); return ( - <div ref={ref} className="relative" data-nav-group={label}> - <button - type="button" - aria-haspopup="menu" - aria-expanded={open} - aria-current={on ? "page" : undefined} - onClick={() => setOpen((v) => !v)} - className={`rounded px-2.5 py-1 text-sm ${ - on - ? "bg-[var(--color-panel-2)] text-[var(--color-sel)]" - : "text-[var(--color-dim)] hover:text-[var(--color-text)]" - }`} - > - {label} <span aria-hidden="true">▸</span> + <div ref={ref} data-nav-group={label}> + <button type="button" aria-haspopup="menu" aria-expanded={open} aria-current={on ? "page" : undefined} onClick={() => setOpen((v) => !v)}> + {label} + <span aria-hidden="true" className="ml-auto text-muted-2"> + {open ? "▾" : "▸"} + </span> </button> {open && ( - <div - role="menu" - className="absolute left-0 top-full z-20 mt-1 flex min-w-32 flex-col rounded border border-[var(--color-line)] bg-[var(--color-panel)] p-1 shadow-lg" - > + <div role="menu" className="ml-3 mt-px grid gap-px border-l border-seam-2 pl-1.5"> {items.map((it) => { const lit = it.label === active; return ( @@ -69,10 +60,8 @@ export default function NavGroup({ role="menuitem" aria-current={lit ? "page" : undefined} onClick={() => setOpen(false)} - className={`rounded px-2.5 py-1 text-sm ${ - lit - ? "bg-[var(--color-panel-2)] text-[var(--color-sel)]" - : "text-[var(--color-dim)] hover:text-[var(--color-text)]" + className={`rounded-[3px] px-2.5 py-1 text-[13px] ${ + lit ? "bg-panel-2 text-text" : "text-muted-2 hover:bg-panel-2 hover:text-text" }`} > {it.label} diff --git a/umtool/components/shell/AppHeader.tsx b/umtool/components/shell/AppHeader.tsx @@ -0,0 +1,105 @@ +import Link from "next/link"; +import { cn } from "@/lib/utils"; +import { Mark } from "./Wordmark"; + +export type Crumb = { href?: string; label: string }; + +// --------------------------------------------------------------------------- +// The page head (canvas `.pagehead`), the top of the work column. +// +// The breadcrumb is ONE nav (aria-label "Breadcrumb"): the trail above, small, +// and the page's own name under it as the <h1> -- set in Archivo at 125% width, +// the face kept for place and piece titles. The name stays INSIDE the nav, so +// the breadcrumb still contains every crumb (specs read it) and no text is on +// the page twice. +// +// `note` is the page's one-line status (`.micro`), always the LAST `.micro` in +// the header -- dashboard.spec reads /browse's that way. `actions` sit to its +// left. A BENCH header is one compact row (canvas `.benchtop`): a bench fits +// 1366×768 and its rail is collapsed, so the mark links home from here. +// +// No hooks, no server imports: a client page (the song deck) renders it too. +// --------------------------------------------------------------------------- + +export default function AppHeader({ + crumbs, + note, + actions, + meta, + variant = "page", + className, +}: { + crumbs: Crumb[]; + note?: React.ReactNode; + /** Controls on the right, before the note. */ + actions?: React.ReactNode; + /** A line under the title (counts, a hint); muted. */ + meta?: React.ReactNode; + variant?: "page" | "bench"; + className?: string; +}) { + const trail = crumbs.slice(0, -1); + const here = crumbs[crumbs.length - 1]; + const bench = variant === "bench"; + return ( + <header + data-app-header={variant} + className={cn( + "flex flex-wrap items-end gap-x-[18px] gap-y-2 border-b border-seam", + bench ? "items-center bg-panel px-4 py-2.5" : "px-4 pb-3.5 pt-4", + className, + )} + > + {bench && ( + <Link href="/" aria-label="umtool home" className="shrink-0"> + <Mark size={18} /> + </Link> + )} + <nav aria-label="Breadcrumb" className={cn("min-w-0", bench ? "flex items-center gap-1.5 text-[12.5px]" : "flex flex-col gap-1")}> + {trail.length > 0 && ( + <span className="flex flex-wrap items-center gap-1.5 text-[12px]"> + {trail.map((c, i) => ( + <span key={`${c.label}-${i}`} className="flex items-center gap-1.5"> + {i > 0 && <span className="text-seam-2">/</span>} + {c.href ? ( + <Link href={c.href} className="text-muted-2 hover:text-text"> + {c.label} + </Link> + ) : ( + <span className="text-muted-2">{c.label}</span> + )} + </span> + ))} + {bench && <span className="text-seam-2">/</span>} + </span> + )} + {here && + (bench ? ( + <span aria-current="page" className="font-mono text-[13px] font-medium text-text"> + {here.href ? <Link href={here.href}>{here.label}</Link> : here.label} + </span> + ) : ( + <h1 + aria-current="page" + className={cn( + "display m-0 truncate leading-none text-text", + here.label.length > 36 ? "text-[20px]" : "text-[26px]", + // A place (no trail) is a title in sentence case; a piece's id + // stays exactly as it is spelled. + trail.length === 0 && "first-letter:uppercase", + )} + > + {here.href ? <Link href={here.href}>{here.label}</Link> : here.label} + </h1> + ))} + </nav> + {meta && <div className="text-[12.5px] text-muted">{meta}</div>} + {(actions || note) && ( + <div className="ml-auto flex flex-wrap items-center gap-3"> + {actions} + {note && <div className="micro">{note}</div>} + </div> + )} + </header> + ); +} diff --git a/umtool/components/shell/AppRail.tsx b/umtool/components/shell/AppRail.tsx @@ -0,0 +1,92 @@ +import Link from "next/link"; +import { cookies } from "next/headers"; +import AppNav from "@/components/AppNav"; +import { runningActivity } from "@/lib/activity"; +import { homeHref } from "@/lib/hrefs"; +import { THEME_COOKIE, parseTheme } from "@/lib/theme"; +import CreateMenu from "./CreateMenu"; +import ThemeControl from "./ThemeControl"; +import { Mark, Wordmark } from "./Wordmark"; + +// --------------------------------------------------------------------------- +// The rail (canvas `.rail`): every page's left column. Top to bottom: +// the mark and the wordmark (home), the places, + Create, the jump hint, +// Pinned, and at the foot what is Running and the theme. +// +// SERVER ONLY: it reads the theme cookie and the in-process job registries. +// A client page (the song deck) gets it from its server page instead. +// +// What is not built yet says so plainly rather than pretending: +// - Jump (⌘K) is P3's palette; the hint is here, inert, so the rail has its +// final shape. +// - Pinned has no store until the piece page (P4a); it is empty. +// - Running lists umtool's own job (a build, a fetch, a render). The editor's +// jobs and their spend join it in P2b. +// --------------------------------------------------------------------------- + +export default async function AppRail({ active }: { active: string }) { + const theme = parseTheme((await cookies()).get(THEME_COOKIE)?.value); + const running = runningActivity(); + return ( + <div className="app-rail" data-app-rail=""> + <Link href={homeHref()} aria-label="umtool home" className="flex items-center gap-[9px] px-4 pb-3.5 pt-4 no-underline"> + <Mark /> + <Wordmark /> + </Link> + + <AppNav active={active} /> + + <CreateMenu /> + + <div + data-rail-section="jump" + aria-disabled="true" + title="Not built yet" + className="mx-4 mb-2 mt-0.5 flex items-center gap-2 px-0.5 py-1 text-[12.5px] text-muted-2" + > + Jump to… + <kbd className="ml-auto">⌘K</kbd> + </div> + + <section data-rail-section="pins" aria-label="Pinned"> + <h2 className="micro px-5 pb-1.5 pt-4">Pinned</h2> + <p className="px-5 text-[12px] text-muted-2">Nothing pinned</p> + </section> + + <section + data-rail-section="running" + aria-label="Running" + className="mt-auto border-t border-seam pb-2 pt-3" + > + <h2 className="micro flex justify-between px-5 pb-2"> + <span>Running</span> + <span className="font-mono normal-case tracking-normal text-meter">{running ? 1 : 0}</span> + </h2> + {running ? ( + <Link href={running.href} data-running={running.id} className="grid grid-cols-[1fr_auto] gap-x-2 gap-y-0.5 px-5 text-[12px] text-text-2 no-underline hover:text-text"> + <span className="truncate">{running.label}</span> + {running.progress && ( + <span className="font-mono text-[11px] text-muted-2"> + {running.progress.step}/{running.progress.of} + </span> + )} + {running.progress && ( + <span className="relative col-span-2 h-0.5 overflow-hidden bg-seam"> + <i + className="absolute inset-y-0 left-0 bg-meter" + style={{ width: `${Math.round((running.progress.step / Math.max(1, running.progress.of)) * 100)}%` }} + /> + </span> + )} + </Link> + ) : ( + <p className="px-5 text-[12px] text-muted-2">No umtool job running</p> + )} + </section> + + <div className="px-4 pb-4 pt-3"> + <ThemeControl initial={theme} /> + </div> + </div> + ); +} diff --git a/umtool/components/shell/AppShell.tsx b/umtool/components/shell/AppShell.tsx @@ -0,0 +1,47 @@ +import AppHeader, { type Crumb } from "./AppHeader"; +import AppRail from "./AppRail"; + +export type { Crumb }; + +// --------------------------------------------------------------------------- +// The shell: the rail (fixed, left) and the page head, rendered as the FIRST +// children of a page's own `flex h-full flex-col` column -- the shape every +// page here already has. The rail is out of flow and the body pads for it +// (app/globals.css, `body:has(.app-rail)`), so no page changes shape to get it. +// +// `rail="collapsed"` is a bench (canvas "Clip bench"): no rail, a compact head +// whose mark links home, and the whole width for the work. +// +// SERVER ONLY (the rail reads the cookie and the job registries). A client page +// renders <AppRail> from its server page and <AppHeader> itself. +// --------------------------------------------------------------------------- + +export default function AppShell({ + active, + crumbs, + note, + actions, + meta, + rail = "open", +}: { + /** The rail entry that is lit. */ + active: string; + crumbs: Crumb[]; + note?: React.ReactNode; + actions?: React.ReactNode; + meta?: React.ReactNode; + rail?: "open" | "collapsed"; +}) { + return ( + <> + {rail === "open" && <AppRail active={active} />} + <AppHeader + crumbs={crumbs} + note={note} + actions={actions} + meta={meta} + variant={rail === "collapsed" ? "bench" : "page"} + /> + </> + ); +} diff --git a/umtool/components/shell/CreateMenu.tsx b/umtool/components/shell/CreateMenu.tsx @@ -0,0 +1,52 @@ +"use client"; + +import Link from "next/link"; +import { useEffect, useRef, useState } from "react"; +import { browseHref, newArticleHref } from "@/lib/hrefs"; + +// + Create. Until /create exists (P5) it opens onto today's two doors: a new +// article (/articles/new) and a new project (/browse carries the "+ new +// project" form). Inline in the rail, not a popover: the rail scrolls, and a +// popover would be clipped by it. +export default function CreateMenu() { + const [open, setOpen] = useState(false); + const ref = useRef<HTMLDivElement>(null); + useEffect(() => { + if (!open) return; + const away = (e: MouseEvent) => { + if (ref.current && !ref.current.contains(e.target as Node)) setOpen(false); + }; + const key = (e: KeyboardEvent) => e.key === "Escape" && setOpen(false); + document.addEventListener("mousedown", away); + document.addEventListener("keydown", key); + return () => { + document.removeEventListener("mousedown", away); + document.removeEventListener("keydown", key); + }; + }, [open]); + return ( + <div ref={ref} data-rail-create="" className="mx-4 mb-1 mt-2.5"> + <button + type="button" + aria-expanded={open} + onClick={() => setOpen((v) => !v)} + className="flex w-full items-center gap-2 rounded-[3px] border border-seam-2 px-2.5 py-[6px] text-left font-medium text-text hover:border-muted" + > + + Create + <span aria-hidden="true" className="ml-auto text-muted-2"> + {open ? "▾" : "▸"} + </span> + </button> + {open && ( + <div className="mt-1 flex flex-col"> + <Link href={newArticleHref()} onClick={() => setOpen(false)} className="rounded-[3px] px-2.5 py-1 text-[12.5px] text-text-2 hover:bg-panel-2 hover:text-text"> + An article + </Link> + <Link href={browseHref()} onClick={() => setOpen(false)} className="rounded-[3px] px-2.5 py-1 text-[12.5px] text-text-2 hover:bg-panel-2 hover:text-text"> + A project (video, song, sweep) + </Link> + </div> + )} + </div> + ); +} diff --git a/umtool/components/shell/ThemeControl.tsx b/umtool/components/shell/ThemeControl.tsx @@ -0,0 +1,38 @@ +"use client"; + +import { useState } from "react"; +import { useHydrated } from "@/components/ui/use-hydrated"; +import { THEMES, themeAttr, themeCookie, type Theme } from "@/lib/theme"; + +// Auto / Light / Dark, at the foot of the rail. A choice writes the cookie the +// root layout reads (lib/theme.ts) and stamps <html> at once, so this page +// changes now and every later page is served in it -- no reload, no flash. +export default function ThemeControl({ initial }: { initial: Theme }) { + const hydrated = useHydrated(); + const [theme, setTheme] = useState<Theme>(initial); + const choose = (t: Theme) => { + document.cookie = themeCookie(t); + const attr = themeAttr(t); + if (attr) document.documentElement.dataset.theme = attr; + else delete document.documentElement.dataset.theme; + setTheme(t); + }; + return ( + <div role="group" aria-label="Theme" data-theme-control={theme} className="flex overflow-hidden rounded-[3px] border border-seam-2"> + {THEMES.map((t, i) => ( + <button + key={t} + type="button" + disabled={!hydrated} + aria-pressed={theme === t} + onClick={() => choose(t)} + className={`flex-1 px-2 py-[3px] text-[11.5px] font-medium ${i > 0 ? "border-l border-seam-2" : ""} ${ + theme === t ? "bg-panel-2 text-text" : "text-muted hover:text-text" + }`} + > + {t === "auto" ? "Auto" : t === "light" ? "Light" : "Dark"} + </button> + ))} + </div> + ); +} diff --git a/umtool/components/shell/Wordmark.tsx b/umtool/components/shell/Wordmark.tsx @@ -0,0 +1,29 @@ +// The Found-line mark and the wordmark (canvas `.wmk`). "umtool" is ONE word: +// a bold lead "um" (Archivo 850) and a light "tool" (400), no gap, no space -- +// the brand's two-weight wordmark split. The mark's lines are the lit line's +// origin: the lit one wears --mark, the others --mark-dim. +export function Mark({ size = 20 }: { size?: number }) { + return ( + <svg width={size} height={size} viewBox="0 0 512 512" aria-hidden="true" className="shrink-0"> + <g transform="translate(51.2 51.2) scale(0.8)"> + <rect x="112" y="128" width="288" height="44" rx="22" fill="var(--mark-dim)" /> + <polygon points="112,210 172,234 112,258" fill="var(--mark)" /> + <rect x="188" y="212" width="212" height="44" rx="22" fill="var(--mark)" /> + <rect x="112" y="296" width="232" height="44" rx="22" fill="var(--mark-dim)" /> + <rect x="112" y="380" width="152" height="44" rx="22" fill="var(--mark-dim)" /> + </g> + </svg> + ); +} + +export function Wordmark({ size = 17 }: { size?: number }) { + return ( + <span + className="whitespace-nowrap font-display leading-none" + style={{ fontSize: size, fontVariationSettings: '"wdth" 125' }} + > + <b className="font-[850]">um</b> + <span className="font-normal text-text-2">tool</span> + </span> + ); +}