Spec: First-party design system¶
- ID: 039-design-system
- Status: planned
- Owner: @bamr87
- Created: 2026-08-30
- Roadmap Epic: make the UI a managed, testable contract instead of two drifting idioms
- Constitution Compliance: confirmed against docs/constitution.md; §2 frontend-kit lock is amended by ADR 0006 (proposed — human maintainer must accept)
1. Problem & Motivation¶
Law AI ships two Next.js apps that look related and are styled independently:
frontend/— Tailwind utility soup, blue/indigo accent, two CSS variables, no primitive components.lsat-static/— a real (if unnamed) design system: 11 tokens + semantic classes inapp/globals.css.
Constitution §2, AGENTS.md, README, and the PRD all list shadcn/ui. It has never been installed. Agents following those docs import components that do not exist. .design-sync/ snapshots both apps into a 915 KB compiled stylesheet that does not regenerate in CI and is not a source of truth.
There is no way to change a color, a focus ring, or a button once and have both products follow. Screens the size of LsatLab.tsx (~1611 lines) and AgentDashboard.tsx (~1460 lines) re-implement atoms inline. The static LSAT QuestionCard is the only robust accessible radiogroup.
Inventory and findings: docs/ui-ux.md.
2. Origin & Background¶
- Backlog items claimed: none (no existing BL covered "build a design system").
- Review question (constitution §13): this spec does not rank, score, or summarize legal authority. It does require that primitives used next to authority signals (confidence badges, graph node size) stay label-only — they must not imply correctness. UPL chrome (
LegalDisclaimerBanner/ footer) is in scope as a primitive. - Who is the stronger here? A polished, confident UI without shared disclaimer/focus/empty-state primitives advantages the system operator (looks finished) over the under-resourced user (cannot tell advice from study aid, cannot tab through choices). The design system exists to make those obligations cheap to keep, not to make output look more authoritative.
3. Goals¶
- G1: One token file is the only palette; both apps consume it.
- G2: A small primitive set (not screens) that feature work must compose.
- G3: Docs, constitution §2, and the repo agree; agents have a catalog to follow.
- G4: The contract is testable (contrast, focus, no raw hex in migrated files).
4. Non-Goals¶
- NG1: Installing shadcn/ui, Radix, Storybook, or a CSS-in-JS runtime.
- NG2: A new top-level
packages/workspace. - NG3: Rewriting
LsatLab.tsx/AgentDashboard.tsx/ Analysis Studio (follow-ups). - NG4: Merging the two LSAT products' feature sets (API lab vs static export).
- NG5: Light theme, i18n, or a marketing redesign of the homepage.
- NG6: Wiring unused deps (TanStack Query, framer-motion, lucide, xyflow).
5. User Stories¶
- As a contributor, I want to change
--accent-brandonce and see it on NavBar and platform buttons, so palette drift stops. - As a contributor on
lsat-static, I want semantic classes that already map to those tokens, so the GitHub Pages export stays Tailwind-free. - As a prospective LSAT student, I want the same keyboard-accessible choices and visible focus I have on the static site, on every new control.
- As a reviewer of generated IRAC, I want the UPL banner to be a primitive that screens cannot forget.
- As an agent, I want
docs/ui-ux.md+frontend/ui/README.mdto list real import paths, so I stop scaffolding shadcn.
6. Functional Requirements¶
- FR-1: Add
frontend/ui/tokens.csswith named custom properties covering canvas, elevation, border, text,--accent-brand(blue),--accent-practice(amber),--ok,--warn,--no, radius, font-sans, font-mono,--page-max,--prose-max. Values lift from the current dark palette in docs/ui-ux.md. - FR-2:
frontend/app/globals.cssimports the tokens and maps them through Tailwind v4@themeso utilities likebg-canvas,text-fg,border-line,bg-accent-brandexist. Existing utility-class screens keep compiling. - FR-3:
lsat-static/app/globals.cssimportstokens.css+frontend/ui/semantic.css(relative or copied-at-build — implementation in plan) and deletes duplicated:roothex. Semantic class names (.btn,.card,.choice, …) remain the public API of the static app. - FR-4: Ship React primitives under
frontend/ui/components/:Button,Card,Input,Badge,Pill,Empty,Choice(radiogroup, portinglsat-staticQuestionCard keyboard behavior),LegalDisclaimerBanner,LegalDisclaimerFooter. Each accepts aclassNamemerge and uses tokens/semantic classes only. - FR-5: Migrate a proof set onto primitives + tokens:
NavBar,LegalDisclaimer.tsx(become re-exports or thin wrappers),lsat-static/components/QuestionCard.tsx. No raw hex in those files after migration. - Amendment 2026-09-05 (BL-20260831-01, spec 051):
NavBar.tsxwas deleted — dead since the spec 040 shell replaced it. The proof set is nowLegalDisclaimer.tsx+QuestionCard.tsx; the shipped migration is unchanged. - FR-6: Catalog at
frontend/ui/README.mdlisting every primitive, when to use it, and the two accent roles. docs/ui-ux.md stays the narrative inventory and is updated to describe the new layout as current once primitives land. - FR-7: Accept ADR 0006 in the same PR that amends constitution §2 (drop shadcn/ui; name
frontend/ui/) and §9 (UI changes updatedocs/ui-ux.md). Update AGENTS.md, README, and the ADR index. PRD/Proposal get a one-line pointer rather than a stack rewrite. - FR-8: Retarget
.design-sync/ds/styles.src.cssto importfrontend/ui/tokens.css+semantic.cssinstead of duplicating:root. Document in.design-sync/NOTES.mdthat the DS consumesfrontend/ui/. Do not treat design-sync as a second palette. - FR-9: Every primitive ships a Vitest + RTL test under
frontend/__tests__/ui/.Choicecovers arrow-key movement and submit.LegalDisclaimerBannerasserts the UPL heading is present.
7. Non-Functional Requirements¶
- NFR-A11Y-1: Primitives expose a visible
:focus-visiblering using--accent-brand(platform) or--accent-practice(LSAT context). No primitive usesoutline-nonewithout a replacement ring. Contrast of--textand--text-mutedon--bg/--bg-elevmeets WCAG 2.2 AA. - NFR-A11Y-2:
Choicepreserves the static site's radiogroup pattern (roving tabindex, Arrow selection-follows-focus, Space selects, Enter submits). - NFR-PERF-1:
lsat-staticremains a Tailwind-free static export. Design-system CSS imported into it must not pull the Tailwind runtime or the 915 KB safelist build. - NFR-SEC-1: No new runtime npm dependencies. Dev-only test helpers already in
frontend/package.jsonare fine. - NFR-AUDIT-1: No LLM, graph, or provenance changes. UPL chrome stays user-visible, not an audit event.
- NFR-HITL-1:
human_approval_requiredis false for this spec. Visual acceptance is the PR review (constitution Level 2). ADR 0006 itself requires a human maintainer (constitution last line). - NFR-DOCS-1: After implementation, constitution §2, AGENTS.md frontend bullets, README stack line, and
docs/ui-ux.mddescribe the same kit.
8. Data Model Impact¶
None.
9. API Surface¶
None. No backend routes.
10. Agent / Crew Impact¶
None to agents_runtime. Dev agents gain docs/ui-ux.md + frontend/ui/README.md as the UI catalog (AGENTS.md Important Context Files).
11. LegalBench Impact¶
- Tasks affected: none.
- Expected delta: 0 pp.
12. Acceptance Criteria¶
- AC-1: Given both apps'
globals.css, when tokens.css changes--bg, then both canvases pick up the new value without editing screen files. - AC-2: Given
lsat-staticproduction build, when the design system is imported, then the export still contains no Tailwind runtime and existing semantic class names still style Overview/Drill/QuestionCard. - AC-3: Given
Choice, when the user arrows through options and presses Enter, then the selected label is submitted and the correct/incorrect classes apply — matching today's QuestionCard. - AC-4: Given the migrated proof files (NavBar, LegalDisclaimer, QuestionCard), when grepped for raw
#rrggbb/rgb(, then there are zero matches outsidefrontend/ui/tokens.css. - Amendment 2026-09-05 (BL-20260831-01): the grep now covers LegalDisclaimer + QuestionCard only; NavBar no longer exists.
- AC-5: Given
make test-frontend, when the new__tests__/ui/files run, then they pass.python3 scripts/spec_validator.py specs/039-design-systemandpython3 scripts/backlog_lint.pyexit 0. - AC-6: Given constitution §2 after ADR 0006 is accepted, when an agent reads the locked stack, then it names
frontend/ui/and does not name shadcn/ui.
13. Risks & Open Questions¶
- R-1: Tailwind
@themetoken names colliding with default color ramps (blue-600still used by unmigrated screens). Mitigation: add token utilities alongside existing ramps; do not deleteslate/blueuntil follow-up migrations. - R-2: Relative import of
frontend/ui/*.cssfromlsat-staticmay break Next static export path resolution. Mitigation: plan records a copy-or-import decision; AC-2 is the gate. - R-3: Focus-ring change on NavBar could look "unfinished" next to unmigrated screens. Mitigation: proof set is chrome + disclaimer + one LSAT control, not a mixed form.
- R-4: Human maintainer rejects ADR 0006 and wants shadcn instead. Mitigation: implementation of FR-7 is gated on ADR acceptance; tokens/primitives (FR-1–FR-5) are valuable either way.
14. Out of Scope / Follow-ups¶
Recorded in tasks.md ## Follow-ups Discovered and mirrored to BACKLOG: unused frontend deps, god-component decomposition, timer unification, homepage copy/footer drift, NavBar honesty ("Local" pill / "LG" mark).