Design system
The UI has no CSS framework and no runtime style dependency — just CSS custom
properties in ui/src/app.css, organized in three layers so that a theme is one
file and renderers never need editing to be re-skinned.
The three layers
-
Scales (theme-agnostic) — the raw vocabulary:
- spacing:
--space-1 … --space-8(a 4px base) - type:
--text-xs … --text-2xlwith paired--lh-*line-heights, and--measure(the reading column width) --radius-{sm,md,lg,pill},--shadow-{sm,md,lg}- motion:
--ease,--dur-fast,--dur-med - layout:
--rail-w,--header-h
- spacing:
-
Semantic tokens (per theme) — meaning, not raw values. Defined for dark (default) and overridden under
:root[data-theme="light"]:- surfaces:
--bg,--surface,--surface-elevated,--surface-hover - lines:
--border,--border-strong - text:
--text,--text-muted,--text-subtle - accent:
--accent,--accent-hover,--accent-contrast,--accent-subtle - state:
--danger-*,--ok-*; value/urgency tints (--tint-*,--u-*)
- surfaces:
-
Legacy aliases — the token names renderers already use (
--card-bg,--muted,--column-border,--tag-bg, …) alias the semantic tokens. This is why adding the light theme required zero renderer edits.
Rules of thumb
- Use tokens, not literals. Reach for
--space-3,--text-sm,--radius-mdrather than hand-picked px/rem, so rhythm stays consistent. - Tints are value-keyed. Status/urgency colors are applied via
[data-value="…"]/[data-urgency="…"]selectors inapp.css, never in a renderer (see How to add a feature). - Focus is global. One
:focus-visiblerule styles every interactive element; don’t remove outlines locally. - Respect reduced motion. Transitions collapse under
prefers-reduced-motion— keep animations compositor-only (transform/opacity). - Note-body decorations are closed-vocabulary, semantic-token, and sanitize-safe. Highlights,
callouts, and coloured text are
markedextensions inrender.tsthat run upstream of the single DOMPurify pass (pure syntax→HTML belongs in a marked extension; only async vault resolution is a post-sanitize DOM walk). They emit a DOMPurify-default element (mark/span/div) + a class drawn from a closed set (render-vocab.ts) — the sanitizer never learns the vocabulary, and an unknown value degrades to literal Markdown. Colours are semantic tokens (accent/ok/warn/…), never a colour name or hex, so a note stays truthful across themes; a new theme must define those tokens. A note body never carries arbitrary HTML/CSS (unportable- a shared-vault XSS hole). New body syntax follows this shape; user-supplied rendering is the off-by-default Lua hatch, never a widened render seam.
- A header shows identity + primaries; everything else goes behind
⋯. For a note/board/discussion pane header the operational test is: visible = identity (which vault, who edited) plus what mutates the note’s primary content in place (the status chip, Edit/Details); the⋯“more actions” overflow = lifecycle / cross-cutting / destructive actions (Copy to…, Delete), with the destructive one last and red. The trigger is⋯, never+—+means add / create (it is already “add media” and “new note”). When a new action is kind-specific, let the action declare which kinds it applies to; never keep a per-kind list of actions (that is a menu fork). This keeps the overflow from re-accreting into a junk drawer.
Adding a theme
Copy the :root[data-theme="light"] block, rename the theme, and change only the
semantic token values. Wire it into the theme toggle in App.svelte (which sets
document.documentElement.dataset.theme and persists to localStorage).