stahl/DESIGN.md
Markus Zoppelt 6b0e5884c9 feat: a phone layout
On a phone, Stahl shows a slim bar on top, one page at a time, and a tab bar:
Overview, Holdings, Performance, and More, which lists every other page with
search, the guide, the theme and Settings. A selected holding's details take
the table's place. State::compact turns it on; the iOS shell sets it from
UIKit's horizontal size class, so an iPad in a narrow split gets it too.

The pages are the desktop's, made to fit a narrow column: ui::columns takes a
count for wide, medium and narrow, the hero stacks its figures under the total,
an allocation's target takes its own line, and headers wrap. That also fixes
the Policy editor collapsing and Settings' fixed-width fields in a narrow
desktop window. Each page now gets its own scroller, so it opens at its top
instead of where the last page was left.

The iOS shell paints the safe area in the app's background. Every phone
screen has a phone-* scene in examples/demo.rs, rendered at 390x844.
2026-11-07 14:23:41 +01:00

87 lines
4.7 KiB
Markdown

# Design language
Stahl Capital looks like the landing page at [zoppelt.net/stahl](https://zoppelt.net/stahl/): a private
bank with one client. That means steel, paper, a serif for the things worth announcing, and very
little decoration. This file is the reference for new screens. `tests/design.rs` enforces the parts
a test can check.
## Principles
1. **Steel and paper.** Dark is a steel-blue wall (`#0a0f13`). Light is the landing page's letter
paper (`#e9e6dd`) with dark ink. Both themes are first class, so check every screen in both.
2. **One serif voice.** Newsreader is for names and big numbers: page titles, section titles, the
total, key figures, the welcome sentence. Everything you read or operate (labels, tables,
buttons, captions) is Inter. Never set running text in the serif.
3. **Rules, not boxes.** Group related things with a hairline above them (`ui::ledger`). A box
(`ui::card`) is for things that must hold together: a table, a form, a list of findings. A box
inside a box is a smell.
4. **Colour carries meaning, never decoration.** Teal means a gain or all clear, red a loss or a
failure, amber a warning, cyan information. Each asset class keeps one colour on every page.
Everything else is steel greys. No coloured backgrounds behind pages or cards.
5. **Depth only for what floats.** The palette, a chart readout and menus get a shadow and a blur
(`ui::floating`). Nothing that sits on the page does.
6. **Quiet motion that means something.** Digits roll when a value changes, charts draw in once,
a refresh flashes the total. All of it respects reduced motion. Nothing loops for attention,
except the single breathing dot showing that prices are live.
7. **Plain words.** Say what it is and what happens. The private bank joke belongs on the welcome
screen and the landing page, not in labels or errors.
## Tokens
All of these live in `src/theme.rs`. A page never defines its own.
| Token | Use |
|---|---|
| `HERO` | The total value. Newsreader 60, light, tabular figures (`HERO_COMPACT`, 46, on a phone) |
| `STATEMENT` | The welcome screen's sentence. Newsreader 46 (`STATEMENT_COMPACT`, 32, on a phone) |
| `PAGE_TITLE` | Every page's name, with its section in a caption above. Newsreader 32 |
| `HOLDING_TITLE` | A holding's name in the details pane. Newsreader 24 |
| `FIGURE` | Key figures beside a label (`ui::stat`). Newsreader 24, tabular |
| `SECTION` | A section's name (`ui::title`). Newsreader 18 |
| `WORDMARK` | "Stahl Capital" in the sidebar. Newsreader 16 |
| `NUMBER` | Numbers in tables and badges. Inter 13, medium, tabular |
| `kit.ty.*` | Every other piece of text, from rune-kit, in Inter |
| `Theme::up/down/warn/info` | Gain, loss, warning, information. Nothing else |
| `Theme::class_color` | An asset class, the same on every page |
| `Theme::card`, `kit.c.border_*` | Boxes and hairlines |
Corner radii come from one scale: 1 to 3 for bars and dots, 6 for controls and rows, 8 for inner
panels, 12 for cards and floating panels. Spacing steps are 2, 4, 6, 8, 12, 16, 24 and 32. A page
has 32 points of side margin and 24 between its sections, and its content stops at 1240 points.
## Primitives
From `src/view/ui.rs`. Reach for these before writing layout.
| Primitive | What it is |
|---|---|
| `ui::door(size)` | The mark: the icon as a steel door. The sidebar has 28, the welcome screen 168 |
| `ui::wash(t, radius)` | The one soft light from above, behind a page |
| `ui::card(t)` | A flat box with a hairline border |
| `ui::ledger(t)` | A section with a rule over it and no box |
| `ui::rule(t)` | A hairline |
| `ui::floating(t)` | A surface over the page, with a shadow and a blur |
| `ui::title`, `ui::caption`, `ui::muted` | Section title, small label, secondary text |
| `ui::stat`, `ui::badge`, `ui::finding` | A labelled figure, a coloured value, a finding with its dot |
| `ui::share_bar`, `ui::stacked_bar`, `ui::gauge` | Shares of a whole, and progress against a target |
A new kind of thing on more than one page becomes a primitive here, with its look decided once.
## The icon
The icon is the steel door, rendered by the landing page's shader in `site/door.js` from the
flat rings in `assets/icons/icon.svg`. `site/render-icons.sh` regenerates every size from it:
`assets/icons/*`, `assets/door.png` (the mark inside the app), and the page's favicon and logo.
Change the shader, not the PNGs.
## Checking a screen
Tests can't judge looks. Render what you changed in both themes and look at it:
```sh
cargo run --example demo -- --snap /tmp/x.png --scene overview --at 2.5 --size 1320x860
cargo run --example demo -- --snap /tmp/x.png --scene light --at 2.5 --size 1320x860
```
Then regenerate `screenshots/` and the landing page's footage with `site/render-media.sh`, so the
page keeps showing the app as it is.