diff --git a/desktop-next/AGENTS.md b/desktop-next/AGENTS.md index 1ae429ab4a..3244d42cca 100644 --- a/desktop-next/AGENTS.md +++ b/desktop-next/AGENTS.md @@ -32,10 +32,16 @@ Port 1430, so it can run alongside the existing client on 1420. ```bash pnpm typecheck # tsc --noEmit -pnpm check # biome +pnpm check # biome + the type-system guard +pnpm check:type # the type-system guard alone pnpm biome check --write . # auto-fix ``` +`scripts/check-type.mjs` enforces four things the type system cannot express as +a token: no arbitrary text sizes (px **or** rem), no `uppercase`, no +hand-applied `tracking-*`, and no size role paired with a weight or leading +utility. Each one is a defect the existing client already paid for. + --- ## Stack, and why @@ -52,6 +58,53 @@ dependency. --- +## The type system + +Same three layers as colour, and the same rule: only roles are used when +building a screen. + +``` +LAYER 1 --type-size-1…9 --type-leading-* --type-tracking-* --type-weight-* +LAYER 2 --text-body: var(--type-size-4) + its line height, tracking, weight +LAYER 3 text-body +``` + +**A role carries its whole typographic setting**, using Tailwind v4's +`--text---` convention. So `text-body` sets size, line height, +letter spacing, and weight together — never pair a size role with a separate +`font-medium` or `leading-*`, because that is how two supposedly identical labels +drift apart. + +Ten roles: `text-display`, `text-title`, `text-heading`, `text-subheading`, +`text-body-lg`, `text-body`, `text-label`, `text-caption`, `text-meta`, +`text-code`. Two faces: `font-sans` (Inter Variable) and `font-mono` +(JetBrains Mono) — both already shipped in every current Buzz client. + +Hard rules: + +- **Never a px size.** Everything derives from one virtual rem, so keyboard zoom + and the font-size preference both work by construction. A px literal breaks + both, which the existing client learned by shipping the regression. +- **No `uppercase`, no hand-applied `tracking-*`.** All-caps labels are less + legible and read as enterprise chrome; tracking is already corrected per step. +- **Size roles and colour roles never collide.** Colour registers in + Tailwind's `--color-*` namespace and is named for emphasis (`text-primary`); + size registers in `--text-*` and is named for an editorial job (`text-body`). + So `text-primary text-body` is one colour plus one setting, and no name ever + means both. + +### Borders register in their own namespace + +`--color-*` is a single namespace, and text and borders share the emphasis names +`primary` / `secondary` / `tertiary` while holding different values — text at the +dark end of the neutral ramp, borders at the light end. Border roles therefore +register as `--border-color-*`, not `--color-border-*`. + +Get this wrong and there is no error: `border-primary` silently resolves to the +*text* colour and every hairline in the product draws at near-black. That is not +hypothetical — it shipped, and it is why the first design system site had black +dividers while the tokens said `#d4d4d4`. + ## The colour system Three layers. Only the role layer is ever used when building a screen. @@ -134,8 +187,9 @@ time as the product repeats something — see DESIGN.md § Components. Deliberately, so nobody assumes it was forgotten: -- **Typography, spacing, radius, and motion tokens.** Their `/design` pages state - what is still to decide rather than pretending to a system. Typography is next. +- **Spacing, radius, and motion tokens.** Their `/design` pages state what is + still to decide rather than pretending to a system. Typography has landed; + spacing is next. - **Any product component.** No Button, no Dialog, no input layer. - **Tauri.** This is a web app for now; the native shell comes with the app shell. - **Relay, auth, event handling.** None of it. When it arrives it comes from the diff --git a/desktop-next/DESIGN.md b/desktop-next/DESIGN.md index 0f5be1e4a4..2e964b4ca0 100644 --- a/desktop-next/DESIGN.md +++ b/desktop-next/DESIGN.md @@ -11,7 +11,9 @@ Buzz is a place where people build together and bring their agents into the room ## Surface and depth - **Panels sit on the backdrop; the backdrop is a gradient.** Everything else is a panel in a different place. The navigation column is not a special kind of surface. -- **Depth comes from hairline borders and near-invisible shadows, not from many surface colours.** Reach for a border before reaching for a new fill. +- **A region is separated by a soft fill, not by an outline.** Reach for `bg-inset` before reaching for a border. A bordered box announces its own edges; a filled one lets the content sit in a place. Grouping is the common case, so the quiet treatment is the default one. +- **A border is for a genuine boundary, and never above `border-secondary`.** A hairline that reads as a line — rather than as the edge where two surfaces meet — is too strong. Text and borders share the emphasis names but not their values: text lives at the dark end of the neutral ramp, borders at the light end. If a divider looks like text, it is pointed at the wrong role. +- **No page-wide gradient behind documentation or dense reading.** The gradient is the product's backdrop for chrome and panels. Behind a column of prose it fights the text and makes contrast position-dependent — such surfaces sit on `bg-panel`. - **Shadows stay at the threshold of perception.** If a shadow is obvious, it is too strong. The two elevation values are the whole vocabulary. - **Elevation is carried by shadow in light mode and by lightness in dark mode.** On a near-black background there is nothing darker for a shadow to cast, so a floating surface becomes a step lighter instead. Never reach for a stronger shadow to make something float in dark mode. - **On a translucent surface, elevation reads as less translucency, not as a lighter colour.** A glass container with a fully opaque child looks layered; the same container with a merely brighter child looks unchanged. @@ -36,6 +38,15 @@ Buzz is a place where people build together and bring their agents into the room - **Borders use the same three levels, and they mean the same thing.** Learn the ramp once. - **Weight and size carry hierarchy before colour does.** Reaching for a louder colour to fix hierarchy usually means the size relationship is wrong. +## Type + +- **A type role carries its whole setting.** Size, line height, letter spacing, and weight are one decision, not four. `text-body` alone produces correctly set text — never pair a size role with a separate weight or leading utility, because that is how two supposedly identical labels drift apart. +- **Roles are named for the job the text does, never for its size.** `text-title`, not `text-28`. A size name is a value in disguise and goes stale the moment the ramp moves. +- **Never all-caps, and never tracked-out labels.** A capitalised label is harder to read than its sentence-case version and reads as enterprise chrome. A quiet label earns its quietness from size and colour — `text-meta` on `text-tertiary` — rather than from being shouted. There is deliberately no uppercase utility in this system. +- **Every size is relative.** Nothing may be expressed in px: fixed pixel text freezes against keyboard zoom and ignores the person's font-size preference. The existing client shipped a regression from exactly this. +- **Tracking is an optical correction, not a style.** Inter needs progressively tighter spacing as it grows. The ramp already applies it per step; do not add tracking by hand. +- **Code is one step below body.** At equal size a monospace face reads larger than Inter and pulls the eye off the sentence. + ## Both modes - **Design in both modes, not in light and then dark.** Dark is not a filter applied afterwards: elevation, glass, and accent text all behave differently there. diff --git a/desktop-next/package.json b/desktop-next/package.json index c0c8917de9..aa996daad8 100644 --- a/desktop-next/package.json +++ b/desktop-next/package.json @@ -9,12 +9,14 @@ "typecheck": "tsc --noEmit", "preview": "vite preview", "lint": "biome lint .", - "check": "biome check .", - "format": "biome format --write ." + "check": "biome check . && node scripts/check-type.mjs", + "format": "biome format --write .", + "check:type": "node scripts/check-type.mjs" }, "dependencies": { "@base-ui-components/react": "1.0.0-rc.0", "@fontsource-variable/inter": "^5.2.8", + "@fontsource/jetbrains-mono": "^5.3.0", "@tanstack/react-router": "^1.168.10", "react": "^19.1.0", "react-dom": "^19.1.0" diff --git a/desktop-next/scripts/check-type.mjs b/desktop-next/scripts/check-type.mjs new file mode 100644 index 0000000000..3833679f1f --- /dev/null +++ b/desktop-next/scripts/check-type.mjs @@ -0,0 +1,125 @@ +#!/usr/bin/env node +/** + * Type-system guard. + * + * Three rules from DESIGN.md § Type, enforced rather than trusted. Each one has + * already cost the existing client real work: + * + * 1. No arbitrary text sizes — `text-[15px]`, `text-[0.9rem]`, `font-size:`. + * Fixed px froze against keyboard zoom and shipped a message-timeline + * regression; arbitrary rem re-fragments the scale we just consolidated. + * 2. No `uppercase` / `tracking-*` utilities. All-caps labels are less legible + * and read as enterprise chrome, and tracking is corrected per ramp step. + * 3. No size role paired with a weight or leading utility. A role carries its + * whole setting; pairing one with `font-medium` is how two supposedly + * identical labels drift apart. + * + * Run: pnpm check:type + */ + +import { readdirSync, readFileSync, statSync } from "node:fs"; +import { join, relative } from "node:path"; + +const SRC = new URL("../src", import.meta.url).pathname; + +/** Size roles a component may use. Kept in sync with typography.css. */ +const SIZE_ROLES = [ + "display", + "title", + "heading", + "subheading", + "body-lg", + "body", + "label", + "caption", + "meta", + "code", +]; + +const RULES = [ + { + id: "arbitrary-text-size", + // text-[...] with any unit, plus raw CSS font-size declarations. + pattern: /\btext-\[[^\]]*(?:px|rem|em|pt|%)[^\]]*\]|font-size\s*:/g, + message: + "arbitrary text size — use a named role (text-body, text-label, …). px freezes against zoom; arbitrary rem re-fragments the scale.", + }, + { + id: "uppercase", + // Only inside a className/class string — otherwise prose describing the + // rule trips it, and a guard that cries wolf gets ignored. + pattern: /class(?:Name)?=(?:"|'|`)[^"'`]*\buppercase\b/g, + message: + "all-caps text — DESIGN.md § Type forbids it. A quiet label uses text-meta on text-tertiary instead.", + }, + { + id: "manual-tracking", + pattern: /\btracking-(?:tighter|tight|normal|wide|wider|widest|\[)/g, + message: + "hand-applied tracking — the ramp already corrects tracking per step.", + }, + { + id: "role-plus-weight", + // A size role sharing a *className string* with a weight or leading + // utility. Anchoring to the attribute keeps the ramp's own + // `--text-body--line-height` declarations out of it — those are the + // definitions, not a component overriding one. + pattern: new RegExp( + `class(?:Name)?=(?:"|'|\`)[^"'\`]*\\btext-(?:${SIZE_ROLES.join("|")})\\b[^"'\`]*\\b(?:font-(?:thin|extralight|light|normal|medium|semibold|bold|extrabold|black)|leading-)`, + "g", + ), + message: + "size role paired with a weight/leading utility — a role already carries its whole setting.", + }, +]; + +function walk(dir) { + return readdirSync(dir).flatMap((entry) => { + const full = join(dir, entry); + if (statSync(full).isDirectory()) return walk(full); + return /\.(tsx?|css)$/.test(full) ? [full] : []; + }); +} + +const failures = []; + +for (const file of walk(SRC)) { + const source = readFileSync(file, "utf8"); + // The typography ramp itself is the one place literals are legal — it is + // layer 1, where values live by design. + const isRamp = file.endsWith("typography.css"); + const lines = source.split("\n"); + + lines.forEach((line, index) => { + // Skip comment-only lines: the docs quote the very patterns they forbid. + const trimmed = line.trim(); + if ( + trimmed.startsWith("*") || + trimmed.startsWith("//") || + trimmed.startsWith("/*") + ) { + return; + } + + for (const rule of RULES) { + if (isRamp && rule.id === "arbitrary-text-size") continue; + rule.pattern.lastIndex = 0; + const match = rule.pattern.exec(line); + if (match) { + failures.push( + `${relative(process.cwd(), file)}:${index + 1} ${rule.id}\n ${trimmed}\n → ${rule.message}`, + ); + } + } + }); +} + +if (failures.length > 0) { + console.error( + `\n✗ Type system: ${failures.length} violation${failures.length === 1 ? "" : "s"}\n`, + ); + console.error(`${failures.join("\n\n")}\n`); + process.exit(1); +} + +console.log("✓ Type system: no violations"); diff --git a/desktop-next/src/app/routes/index.tsx b/desktop-next/src/app/routes/index.tsx index cab3393803..bf23e9dbea 100644 --- a/desktop-next/src/app/routes/index.tsx +++ b/desktop-next/src/app/routes/index.tsx @@ -3,14 +3,14 @@ import { Link, createFileRoute } from "@tanstack/react-router"; function Home() { return (
-

Buzz

-

+

Buzz

+

The new client. Nothing here yet — the shell and its capabilities come later. The design system is the foundation being built first.

Open the design system diff --git a/desktop-next/src/features/design-system/ui/ColourPage.tsx b/desktop-next/src/features/design-system/ui/ColourPage.tsx index a146faf766..05ab4037de 100644 --- a/desktop-next/src/features/design-system/ui/ColourPage.tsx +++ b/desktop-next/src/features/design-system/ui/ColourPage.tsx @@ -11,23 +11,23 @@ function RoleRow({ role }: { role: Role }) { return (
- {role.token} - {role.pointsAt} + {role.token} + {role.pointsAt} {role.status !== "core" ? ( - + {role.status} {role.owner ? ` · ${role.owner}` : ""} ) : null}
-

{role.use}

+

{role.use}

{role.exception ? ( -

+

Exception: {role.exception}

) : null} @@ -52,10 +52,8 @@ export function ColourPage() { {RAMPS.map((ramp) => (
-

- {ramp.name} -

-

+

{ramp.name}

+

{ramp.description}

@@ -89,14 +87,12 @@ export function ColourPage() { {ROLE_GROUPS.map((group) => (
-

- {group.name} -

-

+

{group.name}

+

{group.description}

-
+
{group.roles.map((role) => ( ))} @@ -112,14 +108,9 @@ export function ColourPage() { >
{EXCEPTIONS.map((exception) => ( -
- - {exception.name} - -

+

+ {exception.name} +

{exception.why}

diff --git a/desktop-next/src/features/design-system/ui/DesignSystemLayout.tsx b/desktop-next/src/features/design-system/ui/DesignSystemLayout.tsx index a6216225b7..7b1ba6408f 100644 --- a/desktop-next/src/features/design-system/ui/DesignSystemLayout.tsx +++ b/desktop-next/src/features/design-system/ui/DesignSystemLayout.tsx @@ -33,10 +33,10 @@ function NavLink({ to, children }: { to: string; children: ReactNode }) { return ( {children} @@ -48,37 +48,44 @@ export function DesignSystemLayout() { const { scheme, toggle } = useColorScheme(); return ( -
+ /* Narrow: the nav stacks above the content as a wrapped list, because a + 256px column beside a reading column leaves neither enough room. From lg + it becomes the sticky side rail. */ +
-
-
+
+
diff --git a/desktop-next/src/features/design-system/ui/ElevationPage.tsx b/desktop-next/src/features/design-system/ui/ElevationPage.tsx index 707bc183c9..cbaee31b71 100644 --- a/desktop-next/src/features/design-system/ui/ElevationPage.tsx +++ b/desktop-next/src/features/design-system/ui/ElevationPage.tsx @@ -18,11 +18,9 @@ export function ElevationPage() { className="flex h-24 w-44 items-center justify-center rounded-xl bg-panel" style={{ boxShadow: `var(${level.variable})` }} > - - {level.token} - + {level.token}
- + {level.use}
diff --git a/desktop-next/src/features/design-system/ui/GlassPage.tsx b/desktop-next/src/features/design-system/ui/GlassPage.tsx index 9485f000ab..3789c7e37f 100644 --- a/desktop-next/src/features/design-system/ui/GlassPage.tsx +++ b/desktop-next/src/features/design-system/ui/GlassPage.tsx @@ -18,8 +18,8 @@ function ChromePill() { type="button" className={ selected - ? "elevate-xs rounded-full bg-chrome-selected px-5 py-2 text-sm font-medium text-primary" - : "rounded-full px-5 py-2 text-sm text-secondary transition-colors hover:bg-chrome-glass-hover hover:text-primary" + ? "elevate-xs rounded-full bg-chrome-selected px-5 py-2 text-label text-primary" + : "rounded-full px-5 py-2 text-body text-secondary transition-colors hover:bg-chrome-glass-hover hover:text-primary" } > {label} @@ -44,7 +44,7 @@ export function GlassPage() {
-
+
container bg-chrome-glass +{" "} rim-glass +{" "} @@ -84,10 +84,8 @@ export function GlassPage() { className="flex flex-col items-center gap-2 rounded-lg bg-chrome-glass px-6 py-5" style={{ backdropFilter: `blur(${blur.value})` }} > - - {blur.token} - - {blur.value} + {blur.token} + {blur.value}
))}
@@ -98,7 +96,7 @@ export function GlassPage() { description="A deliberate exception: two literal values, not a ramp step and not one of the numbered gradients. Those are background treatments; this is a material detail. Real glass catches light along one edge and falls away on the opposite one, so the rim is a directional pair from one fixed light direction that every glass surface shares." >
- + {`box-shadow:\n inset 0 1px 0 var(--rim-lit),\n inset 0 -1px 0 var(--rim-shade);`}
diff --git a/desktop-next/src/features/design-system/ui/GrowthPage.tsx b/desktop-next/src/features/design-system/ui/GrowthPage.tsx index 71c9e7fb31..a38a49d5f0 100644 --- a/desktop-next/src/features/design-system/ui/GrowthPage.tsx +++ b/desktop-next/src/features/design-system/ui/GrowthPage.tsx @@ -48,15 +48,13 @@ export function GrowthPage() { title="The procedure" description="Runs per change, by whoever needs the value. Nothing here needs permission, and every addition arrives in the same change that needed it, carrying its values, its description, and its owner." > -
    +
      {GROWTH_PROCEDURE.map((step, index) => (
    1. - + {index + 1} - - {step} - + {step}
    2. ))}
    @@ -66,14 +64,16 @@ export function GrowthPage() { title="The audit" description="Runs on a schedule rather than per change. It reports rather than silently rewrites, except where the fix is unambiguous. Growth without pruning is how a system accumulates thirteen transparencies of one colour." > -
    +
    {AUDIT.map(([check, action]) => (
    - {check} - {action} + {check} + + {action} +
    ))}
    diff --git a/desktop-next/src/features/design-system/ui/MotionPage.tsx b/desktop-next/src/features/design-system/ui/MotionPage.tsx index 63f568fb82..5fb0ae6e0b 100644 --- a/desktop-next/src/features/design-system/ui/MotionPage.tsx +++ b/desktop-next/src/features/design-system/ui/MotionPage.tsx @@ -30,7 +30,7 @@ export function MotionPage() { "Never animate blur. Re-blurring a large surface every frame is expensive enough to feel. Animate opacity instead.", "Motion explains a change; it does not decorate one. If removing an animation loses no information, remove it.", ].map((rule) => ( -
  1. +
  2. {rule}
  3. ))} diff --git a/desktop-next/src/features/design-system/ui/OverviewPage.tsx b/desktop-next/src/features/design-system/ui/OverviewPage.tsx index 11fe050188..f45f7c8712 100644 --- a/desktop-next/src/features/design-system/ui/OverviewPage.tsx +++ b/desktop-next/src/features/design-system/ui/OverviewPage.tsx @@ -23,16 +23,16 @@ export function OverviewPage() { title="The layers" description="Only the role layer is ever used when building a screen. That separation is what lets the entire look change without editing a component." > -
    +
    {LAYERS.map(([layer, what, why]) => (
    - + {layer} - + {what} - {why} + {why}
    ))}
    @@ -40,9 +40,9 @@ export function OverviewPage() {
    - {GRAMMAR} + {GRAMMAR}
    -

    +

    The order is fixed, so there is one correct spelling. See{" "} the vocabulary @@ -53,24 +53,30 @@ export function OverviewPage() {

    Colour + + Typography + Glass Growing the system diff --git a/desktop-next/src/features/design-system/ui/TypographyPage.tsx b/desktop-next/src/features/design-system/ui/TypographyPage.tsx index c221aac87f..38282df09d 100644 --- a/desktop-next/src/features/design-system/ui/TypographyPage.tsx +++ b/desktop-next/src/features/design-system/ui/TypographyPage.tsx @@ -1,40 +1,141 @@ -import { PageHeader, Section, Stub } from "./primitives"; +import { + TYPE_FAMILIES, + TYPE_RAMPS, + TYPE_ROLES, + type TypeRole, +} from "@/shared/tokens/registry"; + +import { Note, PageHeader, Row, Rows, Section } from "./primitives"; + +/** + * Every specimen below is set in the role it documents, so the page is the + * system rather than a description of it. A role that reads badly here reads + * badly in the product. + */ +function RoleSpecimen({ role }: { role: TypeRole }) { + return ( + +
    +

    + {role.mono ? "createChannel(name, members)" : "Bring your agents in"} +

    +
    + {role.token} + {role.pointsAt} + + {role.size} / {role.lineHeight} / {role.tracking} / {role.weight} + +
    +

    {role.use}

    +
    +
    + ); +} export function TypographyPage() { return ( <> -
    - +
    + + {TYPE_FAMILIES.map((family) => ( + +
    +

    + {family.name} +

    + {family.token} +

    + {family.use} +

    +
    +
    + ))} +
    -
    -

    - The Cash Sans and BlockUI type variables that appear in the design - exploration are contamination from another Figma library linked into - that file. They exist nowhere in any Buzz codebase and need no - cleanup — only a decision not to inherit them. -

    -
    + + {TYPE_ROLES.map((role) => ( + + ))} +
    + + {TYPE_RAMPS.map((ramp) => ( +
    + + {ramp.steps.map((step) => ( + +
    + + {ramp.id} {step.step} + + + {step.value} + + {step.job} +
    +
    + ))} +
    +
    + ))} + +
    + + +

    + Every size is relative. Never px. +

    +

    + Fixed pixel text freezes against keyboard zoom and ignores the + person's font-size preference. The current client shipped a + message-timeline regression from exactly this and now has a CI + guard rejecting arbitrary size literals. This ramp derives + entirely from one virtual rem, so both dials work by construction. +

    +
    + +

    + No all-caps, and no tracked-out labels. +

    +

    + A capitalised label is harder to read than the sentence-case + version and reads as enterprise chrome. Section labels earn their + quietness from size and colour — text-meta on text-tertiary — + rather than from being shouted. There is no uppercase utility in + this system. +

    +
    +
    +
    + + + The Cash Sans and BlockUI type variables that appear in the design + exploration are contamination from another Figma library linked into + that file. They exist nowhere in any Buzz codebase and need no cleanup — + only a decision not to inherit them. + ); } diff --git a/desktop-next/src/features/design-system/ui/VocabularyPage.tsx b/desktop-next/src/features/design-system/ui/VocabularyPage.tsx index 850afdadaf..16b2bccad0 100644 --- a/desktop-next/src/features/design-system/ui/VocabularyPage.tsx +++ b/desktop-next/src/features/design-system/ui/VocabularyPage.tsx @@ -15,20 +15,20 @@ export function VocabularyPage() { />
    -
    +
    {VOCABULARY.map((group) => (
    - + {group.group}
    {group.words.map((word) => ( {word} @@ -44,21 +44,21 @@ export function VocabularyPage() { description="A name reads property, then role, then modifier, then material, then state. The order is fixed, so an agent writing a hover for a glass surface produces the same name every time instead of two equally plausible ones." >
    - {GRAMMAR} + {GRAMMAR}
    -
    -

    Legal

    +
    +

    Legal

    {GRAMMAR_EXAMPLES.legal.map((example) => ( - + {example} ))}
    -
    -

    Illegal

    +
    +

    Illegal

    {GRAMMAR_EXAMPLES.illegal.map((example) => ( - + {example} ))} diff --git a/desktop-next/src/features/design-system/ui/primitives.tsx b/desktop-next/src/features/design-system/ui/primitives.tsx index 9d80820515..f4d479a640 100644 --- a/desktop-next/src/features/design-system/ui/primitives.tsx +++ b/desktop-next/src/features/design-system/ui/primitives.tsx @@ -4,6 +4,11 @@ import type { ReactNode } from "react"; * Presentation pieces for the design system pages only. These are documentation * furniture, not product components — the shared primitive layer gets built one * component at a time as the product repeats something. + * + * Surface convention on these pages: a region is separated by a soft fill, not + * by an outline. Reach for `bg-inset` before reaching for a border; use a + * hairline only where a genuine boundary is needed, and never above + * `border-secondary`. See DESIGN.md § Surface and depth. */ export function PageHeader({ @@ -16,21 +21,19 @@ export function PageHeader({ status?: string; }) { return ( -
    +
    -

    {title}

    +

    {title}

    {status ? {status} : null}
    -

    - {intro} -

    +

    {intro}

    ); } export function StatusPill({ children }: { children: ReactNode }) { return ( - + {children} ); @@ -46,13 +49,11 @@ export function Section({ children: ReactNode; }) { return ( -
    -
    -

    {title}

    +
    +
    +

    {title}

    {description ? ( -

    - {description} -

    +

    {description}

    ) : null}
    {children} @@ -62,7 +63,7 @@ export function Section({ export function Note({ children }: { children: ReactNode }) { return ( -

    +

    {children}

    ); @@ -70,15 +71,13 @@ export function Note({ children }: { children: ReactNode }) { export function Stub({ what, decide }: { what: string; decide: string[] }) { return ( -
    -

    {what}

    -
    -

    - Still to decide -

    -
      +
      +

      {what}

      +
      +

      Still to decide

      +
        {decide.map((item) => ( -
      • +
      • {item}
      • ))} @@ -88,6 +87,25 @@ export function Stub({ what, decide }: { what: string; decide: string[] }) { ); } +/** + * A group of rows that reads as one region. + * + * The fill does the separating, so the container needs no outline. Rows inside + * are divided by the lightest hairline in the system, because dense data wants + * an edge-to-edge divider rather than a card each — see DESIGN.md § Density. + */ +export function Rows({ children }: { children: ReactNode }) { + return
        {children}
        ; +} + +export function Row({ children }: { children: ReactNode }) { + return ( +
        + {children} +
        + ); +} + /** Renders a live swatch of whatever a CSS custom property currently holds. */ export function Swatch({ variable, @@ -101,16 +119,16 @@ export function Swatch({ translucent?: boolean; }) { return ( -
        +
        - {label} + {label} {sublabel ? ( - {sublabel} + {sublabel} ) : null}
        ); diff --git a/desktop-next/src/shared/styles/globals.css b/desktop-next/src/shared/styles/globals.css index ddc273b6bf..ee3c46406c 100644 --- a/desktop-next/src/shared/styles/globals.css +++ b/desktop-next/src/shared/styles/globals.css @@ -1,13 +1,10 @@ @import "tailwindcss"; @import "@fontsource-variable/inter"; +@import "@fontsource/jetbrains-mono"; @import "./tokens.css"; +@import "./typography.css"; @layer base { - html { - font-family: "Inter Variable", Inter, system-ui, sans-serif; - -webkit-font-smoothing: antialiased; - } - body { margin: 0; background: var(--bg-app); diff --git a/desktop-next/src/shared/styles/tokens.css b/desktop-next/src/shared/styles/tokens.css index ca0d6803ef..77324fb975 100644 --- a/desktop-next/src/shared/styles/tokens.css +++ b/desktop-next/src/shared/styles/tokens.css @@ -301,6 +301,17 @@ --color-tertiary: var(--text-tertiary); --color-disabled: var(--text-disabled); + /* Borders register in their OWN namespace, not `--color-*`. + Text and borders share the emphasis names — primary, secondary, tertiary — + but hold different values: text is the dark end of the neutral ramp + (12/10/9), borders the light end (7/6/5). `--color-*` is a single namespace, + so registering borders there would make `border-primary` resolve to the text + colour and draw every hairline at near-black. It did exactly that until + these three lines existed. */ + --border-color-primary: var(--border-primary); + --border-color-secondary: var(--border-secondary); + --border-color-tertiary: var(--border-tertiary); + --color-accent: var(--bg-accent); --color-accent-tint: var(--bg-accent-tint); --color-accent-tint-hover: var(--bg-accent-tint-hover); diff --git a/desktop-next/src/shared/styles/typography.css b/desktop-next/src/shared/styles/typography.css new file mode 100644 index 0000000000..0b7370a73d --- /dev/null +++ b/desktop-next/src/shared/styles/typography.css @@ -0,0 +1,231 @@ +/* + * Buzz typography tokens. + * + * Same three layers as colour, and only the role layer is ever used when + * building a screen: + * + * LAYER 1 private ramps --type-size-*, --type-leading-*, --type-tracking-* + * LAYER 2 public roles --text-body, --text-title, ... + * LAYER 3 components text-body, text-title (Tailwind utilities) + * + * Rules, matching the colour system: + * - Literal sizes exist only in the ramp. A role points at a step; a component + * points at a role. No component holds a size. + * - A role carries its whole typographic setting — size, line height, letter + * spacing, weight — because those four are one decision, not four. Tailwind + * v4 supports this via the `--text---` convention, so + * `text-body` alone produces correctly set text. + * - Every size is relative. Nothing here may be expressed in px: fixed pixel + * text freezes against zoom and breaks the person's font-size preference. + * This is the one rule the existing client already learned the hard way. + * + * Naming note: colour roles are also spelled `--text-*` (`--text-primary`) but + * are registered in Tailwind's `--color-*` namespace, while sizes register in + * `--text-*`. So `text-primary` is a colour and `text-body` is a setting — the + * same split Tailwind itself makes. Size roles are named for editorial jobs + * (body, title, caption) and colour roles for emphasis levels (primary, + * secondary), so no one name ever means both. + * + * See DESIGN.md for the judgement these values cannot express. + */ + +/* ============================================================ + LAYER 1 — PRIVATE RAMPS + ============================================================ */ + +:root { + /* --- The zoom and preference dials. ----------------------- + Two independent controls compose here, as in the existing client: + + - Cmd +/- scales the real root font size, so every rem in the app — text, + gaps, radii — grows together. True zoom. + - The font-size preference sets --type-scale, nudging only the type ramp + below, so text changes size without moving the layout. + + Every size derives from this virtual rem, which is itself rem-relative and + therefore rides on top of zoom automatically. At the default preference it + equals 1rem, making --type-size-4 read as 14px. */ + --type-scale: 1; + --type-rem: calc(1rem * var(--type-scale)); + + /* --- Size. Nine steps, each step an editorial job. -------- + A modern ramp for a dense product: tight and frequent through the working + sizes where real interface text lives, opening up at the display end where + a step needs to be a visible jump rather than a near-miss. */ + --type-size-1: calc(var(--type-rem) * 0.6875); /* 11px meta */ + --type-size-2: calc(var(--type-rem) * 0.75); /* 12px caption */ + --type-size-3: calc(var(--type-rem) * 0.8125); /* 13px label */ + --type-size-4: calc(var(--type-rem) * 0.875); /* 14px body */ + --type-size-5: calc(var(--type-rem) * 1); /* 16px body large */ + --type-size-6: calc(var(--type-rem) * 1.125); /* 18px subheading */ + --type-size-7: calc(var(--type-rem) * 1.375); /* 22px heading */ + --type-size-8: calc(var(--type-rem) * 1.75); /* 28px title */ + --type-size-9: calc(var(--type-rem) * 2.25); /* 36px display */ + + /* --- Line height. Unitless, so it scales with its own size. + Tight for display text, generous for anything read in quantity, and exactly + 1 for single-line meta so a timestamp cannot enlarge its own row. */ + --type-leading-flat: 1; + --type-leading-tight: 1.2; + --type-leading-snug: 1.35; + --type-leading-normal: 1.5; + --type-leading-relaxed: 1.6; + + /* --- Tracking. An optical correction, not a style. -------- + Inter is drawn for interface text and needs negative tracking as it grows: + spacing that looks correct at 14px looks loose at 36px. The ramp mirrors + the size ramp so the correction is applied per step rather than guessed, + and turns slightly positive at meta sizes where letters need air to stay + legible. */ + --type-tracking-display: -0.022em; + --type-tracking-title: -0.019em; + --type-tracking-heading: -0.017em; + --type-tracking-subheading: -0.014em; + --type-tracking-large: -0.011em; + --type-tracking-body: -0.006em; + --type-tracking-label: -0.003em; + --type-tracking-caption: 0em; + --type-tracking-meta: 0.005em; + + /* --- Weight. Four, and the gaps are deliberate. ----------- + Inter Variable can render any weight, which is exactly why the system names + only these: 500 and 600 sit far enough apart to read as intent rather than + as a rendering artefact. */ + --type-weight-normal: 400; + --type-weight-medium: 500; + --type-weight-semibold: 600; + --type-weight-bold: 700; +} + +/* Conversation type contract, carried over from the existing client: + 13 / 14 / 15px before keyboard zoom. */ +:root[data-font-size="smaller"] { + --type-scale: calc(13 / 14); +} + +:root[data-font-size="larger"] { + --type-scale: calc(15 / 14); +} + +/* ============================================================ + LAYER 3 — PUBLIC ROLES, REGISTERED WITH TAILWIND + + Layers 2 and 3 are one block for typography. A colour role can be a bare + custom property because a component reads it through `bg-*` or `text-*`; a + type role has to be a Tailwind theme key or the paired line height, tracking, + and weight cannot travel with the size. So the role IS the registration. + + Named for the job the text does, never for its size — `text-title`, not + `text-28`. A size name is a value in disguise and goes stale the moment the + ramp moves. + ============================================================ */ + +@theme { + --font-sans: + "Inter Variable", Inter, ui-sans-serif, system-ui, -apple-system, sans-serif; + --font-mono: + "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; + + /* --- Display. One per page at most, and many pages need none. + The only step that is allowed to be decorative. */ + --text-display: var(--type-size-9); + --text-display--line-height: var(--type-leading-tight); + --text-display--letter-spacing: var(--type-tracking-display); + --text-display--font-weight: var(--type-weight-semibold); + + /* --- Title. The name of the thing you are looking at. ----- */ + --text-title: var(--type-size-8); + --text-title--line-height: var(--type-leading-tight); + --text-title--letter-spacing: var(--type-tracking-title); + --text-title--font-weight: var(--type-weight-semibold); + + /* --- Heading. A section within a page. ------------------- */ + --text-heading: var(--type-size-7); + --text-heading--line-height: var(--type-leading-snug); + --text-heading--letter-spacing: var(--type-tracking-heading); + --text-heading--font-weight: var(--type-weight-semibold); + + /* --- Subheading. A group within a section. --------------- */ + --text-subheading: var(--type-size-6); + --text-subheading--line-height: var(--type-leading-snug); + --text-subheading--letter-spacing: var(--type-tracking-subheading); + --text-subheading--font-weight: var(--type-weight-semibold); + + /* --- Body large. Introductions and reading columns, where a + paragraph is the point rather than a description of something else. */ + --text-body-lg: var(--type-size-5); + --text-body-lg--line-height: var(--type-leading-relaxed); + --text-body-lg--letter-spacing: var(--type-tracking-large); + --text-body-lg--font-weight: var(--type-weight-normal); + + /* --- Body. The default. If you are unsure, this is it. --- */ + --text-body: var(--type-size-4); + --text-body--line-height: var(--type-leading-normal); + --text-body--letter-spacing: var(--type-tracking-body); + --text-body--font-weight: var(--type-weight-normal); + + /* --- Label. Interface text that is acted on rather than + read: buttons, tabs, menu items, form labels, table headers. Medium weight + because a label competes with content around it and needs to hold its edge + without going up a size. */ + --text-label: var(--type-size-3); + --text-label--line-height: var(--type-leading-snug); + --text-label--letter-spacing: var(--type-tracking-label); + --text-label--font-weight: var(--type-weight-medium); + + /* --- Caption. A sentence about something else: help text, + descriptions, empty-state detail. */ + --text-caption: var(--type-size-2); + --text-caption--line-height: var(--type-leading-normal); + --text-caption--letter-spacing: var(--type-tracking-caption); + --text-caption--font-weight: var(--type-weight-normal); + + /* --- Meta. Timestamps, counts, tracking numbers. Flat line + height so a single-line value cannot grow its own row. */ + --text-meta: var(--type-size-1); + --text-meta--line-height: var(--type-leading-flat); + --text-meta--letter-spacing: var(--type-tracking-meta); + --text-meta--font-weight: var(--type-weight-medium); + + /* --- Code. Mono, one step down: at equal size a monospace + face reads larger than Inter and pulls the eye off the sentence. */ + --text-code: var(--type-size-3); + --text-code--line-height: var(--type-leading-normal); + --text-code--letter-spacing: var(--type-tracking-caption); + --text-code--font-weight: var(--type-weight-normal); +} + +/* ============================================================ + BASE + ============================================================ */ + +@layer base { + html { + font-family: var(--font-sans); + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + } + + body { + /* Every readable surface starts from the body role and steps away from it + deliberately. */ + font-size: var(--text-body); + line-height: var(--text-body--line-height); + letter-spacing: var(--text-body--letter-spacing); + + /* Never synthesise a weight Inter Variable can render properly, and never + let a font fall back mid-string. */ + font-synthesis-weight: none; + text-rendering: optimizeLegibility; + } + + code, + kbd, + pre, + samp { + font-family: var(--font-mono); + /* Mono digits and letters share one advance width, so a changing value does + not shift the text around it. */ + font-variant-numeric: tabular-nums; + } +} diff --git a/desktop-next/src/shared/tokens/registry.ts b/desktop-next/src/shared/tokens/registry.ts index 1557ccce1e..861f42728f 100644 --- a/desktop-next/src/shared/tokens/registry.ts +++ b/desktop-next/src/shared/tokens/registry.ts @@ -467,6 +467,187 @@ export const GROWTH_PROCEDURE = [ "Never write a raw value. If nothing above applies, say so rather than reaching for a literal.", ]; +/* ============================================================ + TYPOGRAPHY + ============================================================ */ + +/** A public type role. Carries its whole setting, because size, line height, + * tracking, and weight are one decision rather than four. */ +export interface TypeRole { + /** The Tailwind class, e.g. `text-body`. */ + token: string; + /** Step on the size ramp this points at, for display. */ + pointsAt: string; + /** Rendered size at the default preference and zoom, for display only — + * never a value a component may use. */ + size: string; + lineHeight: string; + tracking: string; + weight: string; + /** One sentence: when to use this. */ + use: string; + status: TokenStatus; + /** Set when the role renders in the mono face. */ + mono?: boolean; +} + +/** Ordered loudest to quietest, which is also the order they are chosen in. */ +export const TYPE_ROLES: TypeRole[] = [ + { + token: "text-display", + pointsAt: "size 9", + size: "36px", + lineHeight: "1.2", + tracking: "-0.022em", + weight: "600", + use: "One per page at most, and many pages need none. The only step allowed to be decorative.", + status: "core", + }, + { + token: "text-title", + pointsAt: "size 8", + size: "28px", + lineHeight: "1.2", + tracking: "-0.019em", + weight: "600", + use: "The name of the thing you are looking at.", + status: "core", + }, + { + token: "text-heading", + pointsAt: "size 7", + size: "22px", + lineHeight: "1.35", + tracking: "-0.017em", + weight: "600", + use: "A section within a page.", + status: "core", + }, + { + token: "text-subheading", + pointsAt: "size 6", + size: "18px", + lineHeight: "1.35", + tracking: "-0.014em", + weight: "600", + use: "A group within a section.", + status: "core", + }, + { + token: "text-body-lg", + pointsAt: "size 5", + size: "16px", + lineHeight: "1.6", + tracking: "-0.011em", + weight: "400", + use: "Introductions and reading columns, where a paragraph is the point rather than a description of something else.", + status: "core", + }, + { + token: "text-body", + pointsAt: "size 4", + size: "14px", + lineHeight: "1.5", + tracking: "-0.006em", + weight: "400", + use: "The default. If you are unsure, this is it.", + status: "core", + }, + { + token: "text-label", + pointsAt: "size 3", + size: "13px", + lineHeight: "1.35", + tracking: "-0.003em", + weight: "500", + use: "Interface text that is acted on rather than read: buttons, tabs, menu items, form labels, table headers.", + status: "core", + }, + { + token: "text-caption", + pointsAt: "size 2", + size: "12px", + lineHeight: "1.5", + tracking: "0em", + weight: "400", + use: "A sentence about something else: help text, descriptions, empty-state detail.", + status: "core", + }, + { + token: "text-meta", + pointsAt: "size 1", + size: "11px", + lineHeight: "1", + tracking: "0.005em", + weight: "500", + use: "Timestamps, counts, tracking labels. Flat line height so a single-line value cannot grow its own row.", + status: "core", + }, + { + token: "text-code", + pointsAt: "size 3", + size: "13px", + lineHeight: "1.5", + tracking: "0em", + weight: "400", + use: "Inline code and code blocks. One step below body, because at equal size a monospace face reads larger than Inter and pulls the eye off the sentence.", + status: "core", + mono: true, + }, +]; + +/** The two faces. Both already shipped in every current Buzz client. */ +export const TYPE_FAMILIES = [ + { + token: "font-sans", + name: "Inter Variable", + use: "Everything. Drawn for interface text at small sizes, and already the sans in desktop, web, and mobile.", + }, + { + token: "font-mono", + name: "JetBrains Mono", + use: "Code, keys, and identifiers. Already the mono in the existing client's terminal.", + }, +]; + +/** The private ramps a type role points at. Components never reference these. */ +export const TYPE_RAMPS = [ + { + id: "size", + name: "Size", + description: + "Nine steps, each step an editorial job. Tight and frequent through the working sizes where real interface text lives, opening up at the display end where a step needs to be a visible jump rather than a near-miss. Every value derives from a virtual rem, so the whole ramp follows the person's font-size preference and keyboard zoom.", + steps: [ + { step: 1, job: "meta", value: "11px" }, + { step: 2, job: "caption", value: "12px" }, + { step: 3, job: "label, code", value: "13px" }, + { step: 4, job: "body", value: "14px" }, + { step: 5, job: "body large", value: "16px" }, + { step: 6, job: "subheading", value: "18px" }, + { step: 7, job: "heading", value: "22px" }, + { step: 8, job: "title", value: "28px" }, + { step: 9, job: "display", value: "36px" }, + ], + }, + { + id: "tracking", + name: "Tracking", + description: + "An optical correction, not a style. Inter needs progressively tighter spacing as it grows — tracking that looks correct at 14px looks loose at 36px — so the ramp mirrors the size ramp and the correction is applied per step rather than guessed. It turns slightly positive at meta sizes, where letters need air to stay legible.", + steps: [ + { step: 9, job: "display", value: "-0.022em" }, + { step: 8, job: "title", value: "-0.019em" }, + { step: 7, job: "heading", value: "-0.017em" }, + { step: 6, job: "subheading", value: "-0.014em" }, + { step: 5, job: "body large", value: "-0.011em" }, + { step: 4, job: "body", value: "-0.006em" }, + { step: 3, job: "label", value: "-0.003em" }, + { step: 2, job: "caption", value: "0em" }, + { step: 1, job: "meta", value: "0.005em" }, + ], + }, +]; + export const ELEVATION = [ { token: "shadow-xs", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8cf7f5bc9f..d3aa086b10 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -310,6 +310,9 @@ importers: '@fontsource-variable/inter': specifier: ^5.2.8 version: 5.2.8 + '@fontsource/jetbrains-mono': + specifier: ^5.3.0 + version: 5.3.0 '@tanstack/react-router': specifier: ^1.168.10 version: 1.170.7(react-dom@19.2.8(react@19.2.8))(react@19.2.8)