Task 16: Theme tokens, fonts, icons (#16) #34

Manually merged
charles merged 0 commits from task/16-ui-theme-fonts-icons into foundation 2026-11-11 18:28:12 +00:00
Owner

What this adds

cargo xtask gen-theme --fork <path> [--out <file>] (xtask/src/gen_theme.rs) reads the Electron app's CSS and writes crates/fluxer-ui/src/theme/tokens.rs:

  • color-system.css, :root, .theme-dark block: every variable that resolves to a colour becomes a field of Colors (172 of them; the 11 non-colours such as shadows and border shorthands are listed in the generated header). Handles hsl/hsla/rgb/rgba/hex/transparent, calc(N% * var(--saturation-factor)) with the factor from globals.css, var(--x, fallback) (so --instance-* overrides resolve to the defaults), and color-mix() in srgb and oklab per CSS Color 5 (percentage normalisation, premultiplied alpha).
  • globals.css top-level :root: --radius-*, --spacing-*, layout sizes. message-layout.css: avatar, gutter, line height. rem to px at 16.
  • Interface as in the plan: Tokens { colors, radii, spacing, layout }, pub const DARK, Layout { guild_list_width: 72.0, sidebar_width: 320.0, header_height: 56.0, member_list_width: 264.0, message_avatar: 40.0, message_gutter: 12.0, message_line_height: 22.0, guild_icon: 44.0, guild_item_box: 48.0 }.

fluxer_ui::theme

  • palette::Theme (Theme::DARK): implements iced::theme::Base and the catalogs for text, container, button, text_input, text_editor, scrollable, svg, rule, progress_bar, checkbox, toggler, radio, slider, pick_list and menu, all with iced's own StyleFn class types so .style(|theme, status| ...) works as usual. Named styles in submodules (palette::button::{primary, secondary, danger, ghost}, palette::container::{primary, secondary, secondary_alt, tertiary, header}, palette::text::{secondary, muted, link, danger}, palette::svg::{icon, icon_muted}). The primary button follows Button.module.css (brand fill, hover brand_secondary, pressed brand_primary_pressed, 0.5 opacity disabled, radius 8).
  • fonts::load() -> Vec<Cow<'static, [u8]>>, FONT_SANS, FONT_MONO (+ medium/semibold/bold/italic constants).
  • icons::svg(IconName) -> svg::Handle, 40 icons, handles cached.

How it was tested

  • xtask/tests/gen_theme.rs runs the real binary against a stand-in fork that uses the fork's exact syntax: gen_theme_resolves_background_primary_to_hsl_258_10_5, brand_primary_uses_fallback_hsl_242_70_55, var chains, alpha, color-mix (srgb, oklab, transparent), dark block only, non-colours skipped, lengths, missing fork error. Unit tests in gen_theme.rs cover the CSS reader, colour-mix rules, Oklab round trip, var cycles.
  • crates/fluxer-ui/tests/theme.rs checks the committed DARK against the CSS values (layout_constants_match_spec, colours vs an independent hsl conversion), fonts_load_and_include_fluxer_sans (sfnt magic, "Fluxer Sans"/"Fluxer Mono" name records present, no "IBM Plex" name), every icon is an embedded SVG, and the theme and default widget styles come from tokens.
  • Tests were written first and seen failing (7 xtask tests failed, the ui test did not compile), then passing. cargo xtask ci is green locally. tokens.rs was generated from the fork checkout and is byte-stable under cargo fmt.

Deviations from the plan, for the reviewer

  1. Fonts are TTF, and a subset. The fork ships WOFF2, which iced's text stack cannot load. The files were converted with woff2_decompress (container change only) and only the weights the web app uses are bundled: Sans 400/500/600/700, Mono 400/700, each with italic (12 files, 2.3 MB instead of 32). LICENSE-IBM-PLEX.txt and NOTICE.md are copied unchanged; assets/fonts/README.md records the conversion.
  2. Icons come from the fork's node_modules. The web app has no SVG files for icons; it uses @phosphor-icons/react 2.1.10 (MIT). The SVGs wrap that package's path data, in the weight the web app uses (fill is its default). Licence copied to assets/icons/LICENSE-PHOSPHOR.txt. The spec says "rendered with resvg": iced's svg feature does that.
  3. Files outside the task's list (needed to compile and keep CI green):
    • Cargo.toml: adds iced = 0.14 to workspace dependencies, default features minus linux-theme-detection (pulls zbus 5, three unmaintained-crate advisories), plus svg and advanced. Task 17 may need to add tokio.
    • deny.toml: allows BSL-1.0 (clipboard-win, error-code) and CC0-1.0 (hexf-parse); ignores RUSTSEC-2024-0436 (paste), RUSTSEC-2026-0206 (rustybuzz), RUSTSEC-2026-0192 (ttf-parser): unmaintained notices, all transitive through iced 0.14 with no upgrade available. This is a policy call worth a second look.
    • xtask/src/main.rs: GenTheme gains --fork/--out, so Cmd is no longer Copy. xtask/tests/ci_smoke.rs: gen-theme removed from the "exits 2, not implemented" list.
    • READMEs of fluxer-ui and xtask.
  4. No Default for Theme: it would make Theme::default() ambiguous with iced::theme::Base::default wherever that trait is imported. Use Theme::DARK.
  5. Spec §5.3 says "Inter bundled" and "font sizes" in tokens; the plan (Fluxer Sans, four token groups) wins. Font-size tokens are not generated.
  6. Colours come only from color-system.css as the plan says. globals.css :root also sets --scrollbar-thumb-bg-hover and --scrollbar-track-bg to color-mix values; which wins in the browser depends on stylesheet order, so the scrollbar colours may need a look when Task 24 compares screenshots.
  7. No side-by-side screenshots: this task renders nothing yet (first screens are Task 17).

Not verified here: the Windows runner, and actual rendering of the fonts and icons in a window (only their data is tested).

Also opened #33 for a shared-target-dir problem found on the way (not fixed here).

Closes #16

🤖 Generated with Claude Code

## What this adds **`cargo xtask gen-theme --fork <path> [--out <file>]`** (`xtask/src/gen_theme.rs`) reads the Electron app's CSS and writes `crates/fluxer-ui/src/theme/tokens.rs`: - `color-system.css`, `:root, .theme-dark` block: every variable that resolves to a colour becomes a field of `Colors` (172 of them; the 11 non-colours such as shadows and border shorthands are listed in the generated header). Handles `hsl`/`hsla`/`rgb`/`rgba`/hex/`transparent`, `calc(N% * var(--saturation-factor))` with the factor from `globals.css`, `var(--x, fallback)` (so `--instance-*` overrides resolve to the defaults), and `color-mix()` in `srgb` and `oklab` per CSS Color 5 (percentage normalisation, premultiplied alpha). - `globals.css` top-level `:root`: `--radius-*`, `--spacing-*`, layout sizes. `message-layout.css`: avatar, gutter, line height. rem to px at 16. - Interface as in the plan: `Tokens { colors, radii, spacing, layout }`, `pub const DARK`, `Layout { guild_list_width: 72.0, sidebar_width: 320.0, header_height: 56.0, member_list_width: 264.0, message_avatar: 40.0, message_gutter: 12.0, message_line_height: 22.0, guild_icon: 44.0, guild_item_box: 48.0 }`. **`fluxer_ui::theme`** - `palette::Theme` (`Theme::DARK`): implements `iced::theme::Base` and the catalogs for text, container, button, text_input, text_editor, scrollable, svg, rule, progress_bar, checkbox, toggler, radio, slider, pick_list and menu, all with iced's own `StyleFn` class types so `.style(|theme, status| ...)` works as usual. Named styles in submodules (`palette::button::{primary, secondary, danger, ghost}`, `palette::container::{primary, secondary, secondary_alt, tertiary, header}`, `palette::text::{secondary, muted, link, danger}`, `palette::svg::{icon, icon_muted}`). The primary button follows `Button.module.css` (brand fill, hover `brand_secondary`, pressed `brand_primary_pressed`, 0.5 opacity disabled, radius 8). - `fonts::load() -> Vec<Cow<'static, [u8]>>`, `FONT_SANS`, `FONT_MONO` (+ medium/semibold/bold/italic constants). - `icons::svg(IconName) -> svg::Handle`, 40 icons, handles cached. ## How it was tested - `xtask/tests/gen_theme.rs` runs the real binary against a stand-in fork that uses the fork's exact syntax: `gen_theme_resolves_background_primary_to_hsl_258_10_5`, `brand_primary_uses_fallback_hsl_242_70_55`, var chains, alpha, `color-mix` (srgb, oklab, `transparent`), dark block only, non-colours skipped, lengths, missing fork error. Unit tests in `gen_theme.rs` cover the CSS reader, colour-mix rules, Oklab round trip, var cycles. - `crates/fluxer-ui/tests/theme.rs` checks the committed `DARK` against the CSS values (`layout_constants_match_spec`, colours vs an independent hsl conversion), `fonts_load_and_include_fluxer_sans` (sfnt magic, "Fluxer Sans"/"Fluxer Mono" name records present, no "IBM Plex" name), every icon is an embedded SVG, and the theme and default widget styles come from tokens. - Tests were written first and seen failing (7 xtask tests failed, the ui test did not compile), then passing. `cargo xtask ci` is green locally. `tokens.rs` was generated from the fork checkout and is byte-stable under `cargo fmt`. ## Deviations from the plan, for the reviewer 1. **Fonts are TTF, and a subset.** The fork ships WOFF2, which iced's text stack cannot load. The files were converted with `woff2_decompress` (container change only) and only the weights the web app uses are bundled: Sans 400/500/600/700, Mono 400/700, each with italic (12 files, 2.3 MB instead of 32). `LICENSE-IBM-PLEX.txt` and `NOTICE.md` are copied unchanged; `assets/fonts/README.md` records the conversion. 2. **Icons come from the fork's `node_modules`.** The web app has no SVG files for icons; it uses `@phosphor-icons/react` 2.1.10 (MIT). The SVGs wrap that package's path data, in the weight the web app uses (`fill` is its default). Licence copied to `assets/icons/LICENSE-PHOSPHOR.txt`. The spec says "rendered with resvg": iced's `svg` feature does that. 3. **Files outside the task's list** (needed to compile and keep CI green): - `Cargo.toml`: adds `iced = 0.14` to workspace dependencies, default features minus `linux-theme-detection` (pulls zbus 5, three unmaintained-crate advisories), plus `svg` and `advanced`. Task 17 may need to add `tokio`. - `deny.toml`: allows `BSL-1.0` (clipboard-win, error-code) and `CC0-1.0` (hexf-parse); ignores RUSTSEC-2024-0436 (paste), RUSTSEC-2026-0206 (rustybuzz), RUSTSEC-2026-0192 (ttf-parser): unmaintained notices, all transitive through iced 0.14 with no upgrade available. **This is a policy call worth a second look.** - `xtask/src/main.rs`: `GenTheme` gains `--fork`/`--out`, so `Cmd` is no longer `Copy`. `xtask/tests/ci_smoke.rs`: `gen-theme` removed from the "exits 2, not implemented" list. - READMEs of `fluxer-ui` and `xtask`. 4. **No `Default` for `Theme`**: it would make `Theme::default()` ambiguous with `iced::theme::Base::default` wherever that trait is imported. Use `Theme::DARK`. 5. **Spec §5.3 says "Inter bundled" and "font sizes" in tokens**; the plan (Fluxer Sans, four token groups) wins. Font-size tokens are not generated. 6. Colours come only from `color-system.css` as the plan says. `globals.css` `:root` also sets `--scrollbar-thumb-bg-hover` and `--scrollbar-track-bg` to `color-mix` values; which wins in the browser depends on stylesheet order, so the scrollbar colours may need a look when Task 24 compares screenshots. 7. No side-by-side screenshots: this task renders nothing yet (first screens are Task 17). Not verified here: the Windows runner, and actual rendering of the fonts and icons in a window (only their data is tested). Also opened #33 for a shared-target-dir problem found on the way (not fixed here). Closes #16 🤖 Generated with [Claude Code](https://claude.com/claude-code)
feat(ui): generated theme tokens, fonts and icons
Some checks failed
ci / Linux (x86_64) (push) Successful in 1m28s
ci / Windows (x64) (push) Failing after 2m44s
ci / Windows (x64) (pull_request) Failing after 18s
ci / Linux (x86_64) (pull_request) Successful in 1m29s
320a63b238
- xtask gen-theme --fork <path>: parses the Electron app's colour system,
  globals and message-layout CSS into crates/fluxer-ui/src/theme/tokens.rs
  (hsl/hsla/rgb/hex, saturation-factor calc, var() fallbacks, color-mix in
  srgb and oklab; rem to px).
- fluxer-ui::theme: tokens (DARK), palette::Theme with iced's Base and
  widget catalogs, fonts (Fluxer Sans/Mono as TTF) and icons (Phosphor SVGs).
- Adds iced 0.14 to the workspace; deny.toml allows BSL-1.0 and CC0-1.0 and
  ignores three unmaintained-crate advisories that iced pulls in.

Refs #16

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Author
Owner

Independent review of Task 16 (commit 320a63b)

Verdict: APPROVE — no blocking findings; local cargo xtask ci is green in a fresh review worktree (all sources touched first because of #33). Remote runners and on-screen rendering were not checked.

What was verified

  • Plan tests: gen_theme_resolves_background_primary_to_hsl_258_10_5, brand_primary_uses_fallback_hsl_242_70_55, layout_constants_match_spec (72/320/56/264/40/12/22, plus 44/48) and fonts_load_and_include_fluxer_sans all exist and assert the plan's values. The first two exist both against the generator binary (xtask/tests/gen_theme.rs) and against the committed DARK (crates/fluxer-ui/tests/theme.rs).
  • Generated file is not stale: cargo xtask gen-theme --fork ~/src/fluxer-soundboard --out <tmp> produces output byte-identical to the committed tokens.rs.
  • Interfaces: Tokens { colors, radii, spacing, layout }, pub const DARK: Tokens, Layout with the nine fields and values of the plan, fonts::load() -> Vec<Cow<'static, [u8]>>, FONT_SANS = Font::with_name("Fluxer Sans"), FONT_MONO, icons::svg(IconName) -> svg::Handle, palette::Theme implementing Base and the widget catalogs. status_danger (consumed by Task 18) is present.
  • Invariants: fluxer-core has no iced dependency and the core-isolation step passes; fluxer-ui does no I/O (assets are include_bytes!); no secrets or tokens in the diff; font licence and NOTICE are identical to the fork's copies; commit message carries Refs #16 and the co-author line.
  • Review Focus: none of the five items belongs to this task.
  • deny.toml: the three advisory ignores and the two new licences are all actually encountered (cargo deny reports no unused ignore or allowance for them); the only unmatched allowance is MPL-2.0, which predates this PR.

Findings

  1. minor — docs/.../foundation-design.md §5.3 asks for font-size tokens and Inter; the plan asks for Fluxer Sans and four token groups, and the plan was followed. globals.css does define --font-size-*, so later UI tasks will have to hand-pick sizes until a token group exists. Needs a follow-up issue (and a spec correction for Inter) before merge.
  2. minor — deny.toml now ignores three unmaintained-crate advisories (paste, rustybuzz, ttf-parser) transitive through iced 0.14. Reasonable, but it is a standing exception Charles should know about; revisit on the next iced upgrade.
  3. minor — palette.rs button::primary derives border colours by mixing brand tokens with Color::WHITE at 18% / 16%. I did not trace these percentages to the web app's button CSS; if they are not from there they are hand-picked values and should be checked in the Task 24 screenshot comparison.
  4. minor — icons::svg indexes the handle cache by name as usize, relying on ALL being in declaration order. The macro guarantees that today and server data cannot reach it; noted only because a hand-edit of ALL would turn it into a wrong-icon or out-of-bounds bug.
  5. minor — Icons are Phosphor path data from the fork's node_modules, not SVG files copied from the web app (there are none), and fonts are TTF converted from the fork's WOFF2. Both deviations are justified and licences are included; rendering is untested until Task 24.
## Independent review of Task 16 (commit 320a63b) **Verdict: APPROVE** — no blocking findings; local `cargo xtask ci` is green in a fresh review worktree (all sources touched first because of #33). Remote runners and on-screen rendering were not checked. ### What was verified - **Plan tests**: `gen_theme_resolves_background_primary_to_hsl_258_10_5`, `brand_primary_uses_fallback_hsl_242_70_55`, `layout_constants_match_spec` (72/320/56/264/40/12/22, plus 44/48) and `fonts_load_and_include_fluxer_sans` all exist and assert the plan's values. The first two exist both against the generator binary (`xtask/tests/gen_theme.rs`) and against the committed `DARK` (`crates/fluxer-ui/tests/theme.rs`). - **Generated file is not stale**: `cargo xtask gen-theme --fork ~/src/fluxer-soundboard --out <tmp>` produces output byte-identical to the committed `tokens.rs`. - **Interfaces**: `Tokens { colors, radii, spacing, layout }`, `pub const DARK: Tokens`, `Layout` with the nine fields and values of the plan, `fonts::load() -> Vec<Cow<'static, [u8]>>`, `FONT_SANS = Font::with_name("Fluxer Sans")`, `FONT_MONO`, `icons::svg(IconName) -> svg::Handle`, `palette::Theme` implementing `Base` and the widget catalogs. `status_danger` (consumed by Task 18) is present. - **Invariants**: `fluxer-core` has no iced dependency and the core-isolation step passes; `fluxer-ui` does no I/O (assets are `include_bytes!`); no secrets or tokens in the diff; font licence and NOTICE are identical to the fork's copies; commit message carries `Refs #16` and the co-author line. - **Review Focus**: none of the five items belongs to this task. - **deny.toml**: the three advisory ignores and the two new licences are all actually encountered (cargo deny reports no unused ignore or allowance for them); the only unmatched allowance is `MPL-2.0`, which predates this PR. ### Findings 1. **minor** — `docs/.../foundation-design.md` §5.3 asks for font-size tokens and Inter; the plan asks for Fluxer Sans and four token groups, and the plan was followed. `globals.css` does define `--font-size-*`, so later UI tasks will have to hand-pick sizes until a token group exists. Needs a `follow-up` issue (and a spec correction for Inter) before merge. 2. **minor** — `deny.toml` now ignores three unmaintained-crate advisories (paste, rustybuzz, ttf-parser) transitive through iced 0.14. Reasonable, but it is a standing exception Charles should know about; revisit on the next iced upgrade. 3. **minor** — `palette.rs` `button::primary` derives border colours by mixing brand tokens with `Color::WHITE` at 18% / 16%. I did not trace these percentages to the web app's button CSS; if they are not from there they are hand-picked values and should be checked in the Task 24 screenshot comparison. 4. **minor** — `icons::svg` indexes the handle cache by `name as usize`, relying on `ALL` being in declaration order. The macro guarantees that today and server data cannot reach it; noted only because a hand-edit of `ALL` would turn it into a wrong-icon or out-of-bounds bug. 5. **minor** — Icons are Phosphor path data from the fork's `node_modules`, not SVG files copied from the web app (there are none), and fonts are TTF converted from the fork's WOFF2. Both deviations are justified and licences are included; rendering is untested until Task 24.
charles force-pushed task/16-ui-theme-fonts-icons from 320a63b238
Some checks failed
ci / Linux (x86_64) (push) Successful in 1m28s
ci / Windows (x64) (push) Failing after 2m44s
ci / Windows (x64) (pull_request) Failing after 18s
ci / Linux (x86_64) (pull_request) Successful in 1m29s
to 64430a109d
All checks were successful
ci / Windows (x64) (push) Successful in 22s
ci / Windows (x64) (pull_request) Successful in 15s
ci / Linux (x86_64) (push) Successful in 1m22s
ci / Linux (x86_64) (pull_request) Successful in 1m23s
2026-11-11 08:49:37 +00:00
Compare
Merge origin/foundation into task/16-ui-theme-fonts-icons
All checks were successful
ci / Windows (x64) (push) Successful in 1m32s
ci / Windows (x64) (pull_request) Successful in 38s
ci / Linux (x86_64) (push) Successful in 1m28s
ci / Linux (x86_64) (pull_request) Successful in 1m34s
897ebaae93
Conflicts in xtask (both sides implemented dispatch stubs: gen-theme here,
vendor-spec/spec-check on foundation) and Cargo.lock resolved as the union.

Refs #16

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Merge origin/foundation into task/16-ui-theme-fonts-icons
All checks were successful
ci / Windows (x64) (push) Successful in 44s
ci / Linux (x86_64) (push) Successful in 1m41s
ci / Windows (x64) (pull_request) Successful in 52s
ci / Linux (x86_64) (pull_request) Successful in 1m31s
301b889ef7
Mechanical conflicts: both sides added workspace dependencies (iced, futures-util)
and Cargo.lock entries.

Refs #16

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
charles manually merged commit 24e7c9d137 into foundation 2026-11-11 18:28:12 +00:00
Sign in to join this conversation.
No description provided.