Files
proton-stream/docs/DESIGN-TOKENS.md
nvrl 0d53d1cf72 feat(core,app,android,ios): solid accents, a copper scale and one scrim curve
- The accent is a flat fill. With gradients on (now off by default) it
  shades into a darker tone of itself, never into orchid.
- Copper gets a 100-700 scale; as an accent on dark it uses the lit 400.
  iOS shows the copper rating star and new-episodes badge like Android.
- Every scrim over artwork follows one eased curve (SCRIM_STOPS), layered
  by job instead of one many-stop ramp. The desktop banner is taller and
  loses its full-picture wash.
- One solid focus ring on every client; the TV gradient border and the
  desktop's inner copper ring are gone.
- Missing art is a plain card with initials, not a hashed colour ramp.
- A portrait poster in a landscape card fills the frame with a dimmed
  crop of itself.
2026-11-24 19:05:31 +01:00

232 lines
12 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Design tokens
What the desktop and Android clients agree on, and where each one keeps its copy.
## The suite
Proton Stream, Proton Gallery and Proton Drive for Linux, and their websites,
share one look. This section is the same in each repository's copy. The icons
follow `images/BRANDING.md`.
| Token | Value |
|---|---|
| Dark page / raised / card / card hover / elevated | `#100E17` / `#17141F` / `#1E1A29` / `#2E283D` / `#3A324B` |
| Dark text / muted | `#F4F2FA` / `#AAA4BD` |
| Light page / bar / card / card hover | `#FAF9FC` / `#F4F1FA` / `#F1EEF8` / `#E3DEED` |
| Light text / muted | `#1B1340` / `#615970` |
| Violet (the accent) | `#6D4AFF`; 300 `#A48BFF`, 400 `#8A6DFF`, 600 `#5B36F2` |
| Orchid (icons only) | `#B65BD6` |
| Copper (the highlight) | 100 `#FBEBDD`, 200 `#F2C9AA`, 300 `#E5B08D`, **400 `#D69B77`** (on dark), **500 `#B47456`** (on light), 600 `#8F5940`, 700 `#703E30` |
| Radii | 6 badge and chip, 8 small control, 12 card, 16 sheet, dialog and hero, 24 floating bar, pill for buttons and tabs |
| Type | Inter; Inter Display for the largest size |
**Violet** is the one strong colour, and marks what can be pressed. In the apps
it is a flat fill. The violet-to-orchid ramp belongs to the icons' faces and
nowhere else: across every button and bar it read as a template's decoration,
not a decision. **Copper** is the metal behind every icon. In the apps it is
the colour of news and of the viewer's own things: a new-episodes badge and a
rating star. It is never a fill under body text and never a large area. The
scale (`pstr_core::appearance::copper`) is there so a client that needs a
tint behind a copper label or a copper border on a light page takes a step of
it, not a mix of its own.
In this repository the dark set is the **Proton** palette and the light set
**Proton Light** (`pstr_core::appearance`). Copper is the palette's
`highlight`, which every palette has: Catppuccin's peach, Persona 5's yellow.
Colour needs no spec: `pstr_core::appearance` resolves one `Palette` and both
clients read it, so a flavour is right in both places or wrong in both. The rest
of the token set has no such bridge — Compose cannot consume a Rust constant, and
type and shape do not survive a round trip through `PaletteRecord` — so this file
is the contract, and each side's copy is asserted against it by a test.
| Token | Owner | Android's copy | Pinned by |
|---|---|---|---|
| Colour roles | `pstr_core::appearance::Palette` | `ui/theme/Theme.kt` `schemeOf` | `SchemeRolesTest` |
| Type ramp | `pstr_app::theme::Role` | `ui/theme/Type.kt` | `TypeRampTest` |
| Corner radius | `pstr_app::theme::radius` | `ui/theme/Shape.kt` | `TypeRampTest` |
| Highlight | `Palette::highlight` | `ui/theme/Theme.kt` `LocalBrand` | `appearance.rs` tests |
| Gradient rule | `Palette::resolve` | — (derived, see below) | `appearance.rs` tests |
| Depth | `pstr_app::theme::{tile_shadow, bar_shadow}` | Material elevation | — |
| Spacing | `pstr_app::theme::space` | Compose `dp` literals | — |
| Motion | `pstr_app::theme::motion` | Compose defaults | — |
## Type
Ten rungs. The desktop names them; Android restates them because Material's own
scale is a different one (`displayLarge` is 57sp, which is a size for a lock
screen and not for anything in a library grid).
| Role | Size | What it is |
|---|---|---|
| Hero | 34 | the banner's name and a title page's name, where no logo stands in |
| Display | 26 | the name of the thing you are looking at, once per page |
| Title | 20 | an empty state, or a page heading with no display line |
| Heading | 18 | the name beside the mark in the nav bar; a dialog's heading |
| Section | 17 | a run of content under a rule |
| Subhead | 15 | a row that groups the rows under it — a season header |
| Body | 14 | everything that is prose |
| Label | 13 | the text on a small control |
| Caption | 12 | context rather than content: counts, sizes, errors under a field |
| Micro | 11 | the smallest thing that stays legible — a badge over artwork |
Weight and leading are each side's own. The desktop bundles Inter
(`pstr-app/assets/fonts`, OFL) and sets Display, Title, Heading and Section in
its semibold cut, which egui sees as a family of its own (`theme::semibold`);
everything below Section is the regular cut. Hero is set in Inter Display Bold,
the optical size Inter draws for large text (`theme::display`); Android and iOS
map it to `displayLarge`. Compose derives line height as 1.35 × size rather
than naming it ten more times, except Hero at 1.1, where the text leading
pushes a two-line name apart.
Icons on the desktop come from the Phosphor icon font (`egui-phosphor`,
regular weight), installed right behind Inter so an icon can sit inside an
ordinary label. Do not use Unicode symbols such as ⏭ or 🔊 as icons: they come
out of whichever fallback font has them, at that font's size and baseline.
Both clients point their framework's *default* styles at the ramp — egui's five
`TextStyle`s, Compose's fifteen — so a stock widget nobody restyled still lands
on it. Material 1.4 additionally carries an `Emphasized` copy of all fifteen
styles for its expressive components; those are `internal`, cannot be set from
this module, and keep Material's sizes. Nothing in the app draws with them.
## Shape
The suite's scale. **12** (`radius::MD`, Android `CORNER`) for cards, tiles
and rows. **6** (`BADGE`, `CORNER_TIGHT`) for a badge over artwork or a chip,
**8** (`SM`, `CORNER_SMALL`) for a small control inside something else, **16**
(`LG`, `CORNER_SHEET`) for what floats over the page — dialogs, toasts, sheets
— and **24** (`FLOAT`, `CORNER_FLOAT`) for the desktop's top bar. Buttons, tabs
and the search box are **pills** (`radius::PILL`, Android `Pill`, iOS
`Capsule`). The desktop also has **3** (`BAR`) for progress bars and edge
strips. The library's banner is square: it runs edge to edge.
## The mark inside the app
The top bar on the desktop, the Library's bar on Android, About on both, and
every empty page show the app's mark from `images/logo.svg`: the desktop
through `assets/icon-256.png`, Android through the generated
`drawable/ic_stream_mark.xml`. On an empty page it is faint, at about 40%.
## Focus
A control that has the keyboard's or the remote's focus wears a solid ring of
the accent, standing off the control (`theme::focus_ring` on the desktop,
`focusHighlight` on the phone, `focusBorder` on the TV). It is drawn outside
the control, so it never covers what it marks. One ring on every client: no
gradient border and no second copper edge.
## Scrims
A scrim — a fade laid over artwork so text on it reads — is the one place a
gradient is drawn on purpose, and every client draws it from one curve:
`pstr_core::appearance::scrim`, `1 - smoothstep`, flat at both ends so neither
end shows as a line. The desktop samples it per texel; Android
(`ui/theme/Scrim.kt`) and iOS (`UI/Theme/Scrim.swift`) copy
`SCRIM_STOPS`, which a test pins to the curve. Each scrim has one job — dark
under the status bar, the picture's colour under the text, the page colour
where the art hands over to the page — and they are layered, never merged into
one many-stop ramp. Scrims do not follow the `gradients` switch: they are
legibility, not decoration.
## A picture's colour
The veils over a title's backdrop — the library's banner, the top of a title's
page — are the page colour tinted by the picture under them, so each title
carries its own light. All three clients get the same colour from the same
code: `pstr_core::appearance::mood` averages the picture, squeezed to a few
hundred pixels, counting a saturated pixel up to five times a grey one
(`MOOD_CHROMA_WEIGHT`), and `mood_veil` turns that into the veil. On a dark
palette the mood is darkened until its brightest channel is 60 (`MOOD_DEPTH`)
and the page moves 55% of the way to it (`MOOD_DARK`); a light palette moves
12% (`MOOD_LIGHT`). The phones reach both through the bridge, as
`pictureMood` and `moodVeil`. The fade at the bottom stays the page colour,
because that is what it ends in.
## Spacing
The desktop spaces things from one scale, `theme::space`: 2, 4, 6, 8, 12, 16,
24 (`XXS` to `XXL`). Use a step of the scale for a gap, not a literal. Sizes of
things — a still, a button, a column — are not spacing and stay where they are
defined.
Two traps, both Android's:
- Material's default shape ramp is 4 / 8 / 12 / 16 / 28, so an unstyled screen
puts a 28dp sheet beside a 12dp card beside a fully-round button.
- Material's *buttons* read their own shape token (`CornerFull`), not
`MaterialTheme.shapes`. Handing them a shape is what
`AccentButton` / `TonalButton` / `EdgedButton` / `QuietButton`
(`ui/theme/Accent.kt`) are for. Use those, not Material's, at a new call site.
## The accent, and what `gradients` means
The accent is the **only strong colour in the window**. Something wearing it is
something to interact with; nothing wears it for decoration. Neither client
draws an elevation tint (`surfaceTint` is transparent on Android) — a surface
that is faintly accent-coloured because it happens to be raised breaks that rule.
With `gradients` on (off by default), the accent is a **tonal** ramp, top to
bottom, from the accent into a shade of itself (`TONAL_SHADE`), never into a
second hue — the one exception is the Pink → Sky accent, which is a pair by
choice. It is drawn on:
- the primary button
- the seek bar's spent side
- the progress bar under a tile and under an episode row
- the selected navigation pill *(desktop only — see below)*
Neither client branches on the stored `gradients` flag to decide this.
`Palette::resolve` sets `accent_alt` equal to `accent` when the flag is off, so a
two-stop brush collapses to a flat fill by itself. That is deliberate: a flag
read in two places is a flag that will eventually mean two things, which is
exactly what [B52](BUGS.md#b52--paint-the-accent-as-a-gradient-did-nothing-on-android)
was.
Known divergences, both Android's, both because the component takes a `Color`
and offers no slot to draw into:
- The navigation pill is solid `primary` rather than a ramp.
- A download in flight is solid `tertiary` by choice, not by limitation: it is
drawn directly under the watch-progress bar of the same row, and two ramps in
the same colour two pixels apart say nothing.
## Depth and motion
The desktop casts shadows from `theme::tile_shadow` / `theme::bar_shadow`, which
**halve on a light flavour** — the same black that separates a card from a dark
page is a smudge on a near-white one. Android gets Material's elevation, which
already adapts. Neither uses a tint to say "raised".
Transitions on the desktop go through `Context::animate_*`: wall-clock driven,
frame-rate independent, no state held by the caller. Durations come from
`theme::motion`: `PRESS` 0.05 s, `HOVER` 0.12 s, `STATE` 0.15 s (a switch, the
tab pill's travel, a page change), `FADE` 0.18 s (player chrome, toasts) and
`ARRIVE` 0.24 s (artwork over its placeholder). A hand-driven transition eases
with `motion::ease_out`. Compose's defaults are close enough that nothing here
overrides them.
## Desktop widgets
`pstr-app/src/ui/widgets.rs` holds the hand-painted controls. Use them instead
of egui's own in new code:
- `toggle`: an on/off switch. It replaces `ui.checkbox`, whose unchecked box
is filled with the card colour and so disappears on a card.
- `settings_group` / `settings_row`: one card per subject, with the name and
description on the left and the control on the right (the libadwaita
preferences pattern `proton-drive-linux` uses).
- `segmented`: pills on a shared track, for picking one of a few values
(library filter, season).
- `chip`: a small rounded fact, such as a genre.
- `watched_mark`, `download_button`: the round icon buttons on an episode row.
Messages go through `ui::toast::Toasts` (via `App::note`), not a status line.
Destructive actions ask through `ui::confirm`.
## Adding a token
Name it in the owning client first, restate it on the other side, and extend the
test that pins the copy. A token that lives in only one place is not a token —
it is a literal with a comment.