Task 16: Theme tokens, fonts, icons (#16) #34
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "task/16-ui-theme-fonts-icons"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What this adds
cargo xtask gen-theme --fork <path> [--out <file>](xtask/src/gen_theme.rs) reads the Electron app's CSS and writescrates/fluxer-ui/src/theme/tokens.rs:color-system.css,:root, .theme-darkblock: every variable that resolves to a colour becomes a field ofColors(172 of them; the 11 non-colours such as shadows and border shorthands are listed in the generated header). Handleshsl/hsla/rgb/rgba/hex/transparent,calc(N% * var(--saturation-factor))with the factor fromglobals.css,var(--x, fallback)(so--instance-*overrides resolve to the defaults), andcolor-mix()insrgbandoklabper CSS Color 5 (percentage normalisation, premultiplied alpha).globals.csstop-level:root:--radius-*,--spacing-*, layout sizes.message-layout.css: avatar, gutter, line height. rem to px at 16.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::themepalette::Theme(Theme::DARK): implementsiced::theme::Baseand 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 ownStyleFnclass 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 followsButton.module.css(brand fill, hoverbrand_secondary, pressedbrand_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.rsruns 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 ingen_theme.rscover the CSS reader, colour-mix rules, Oklab round trip, var cycles.crates/fluxer-ui/tests/theme.rschecks the committedDARKagainst 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.cargo xtask ciis green locally.tokens.rswas generated from the fork checkout and is byte-stable undercargo fmt.Deviations from the plan, for the reviewer
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.txtandNOTICE.mdare copied unchanged;assets/fonts/README.mdrecords the conversion.node_modules. The web app has no SVG files for icons; it uses@phosphor-icons/react2.1.10 (MIT). The SVGs wrap that package's path data, in the weight the web app uses (fillis its default). Licence copied toassets/icons/LICENSE-PHOSPHOR.txt. The spec says "rendered with resvg": iced'ssvgfeature does that.Cargo.toml: addsiced = 0.14to workspace dependencies, default features minuslinux-theme-detection(pulls zbus 5, three unmaintained-crate advisories), plussvgandadvanced. Task 17 may need to addtokio.deny.toml: allowsBSL-1.0(clipboard-win, error-code) andCC0-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:GenThemegains--fork/--out, soCmdis no longerCopy.xtask/tests/ci_smoke.rs:gen-themeremoved from the "exits 2, not implemented" list.fluxer-uiandxtask.DefaultforTheme: it would makeTheme::default()ambiguous withiced::theme::Base::defaultwherever that trait is imported. UseTheme::DARK.color-system.cssas the plan says.globals.css:rootalso sets--scrollbar-thumb-bg-hoverand--scrollbar-track-bgtocolor-mixvalues; which wins in the browser depends on stylesheet order, so the scrollbar colours may need a look when Task 24 compares screenshots.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
Independent review of Task 16 (commit
320a63b)Verdict: APPROVE — no blocking findings; local
cargo xtask ciis 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
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) andfonts_load_and_include_fluxer_sansall exist and assert the plan's values. The first two exist both against the generator binary (xtask/tests/gen_theme.rs) and against the committedDARK(crates/fluxer-ui/tests/theme.rs).cargo xtask gen-theme --fork ~/src/fluxer-soundboard --out <tmp>produces output byte-identical to the committedtokens.rs.Tokens { colors, radii, spacing, layout },pub const DARK: Tokens,Layoutwith 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::ThemeimplementingBaseand the widget catalogs.status_danger(consumed by Task 18) is present.fluxer-corehas no iced dependency and the core-isolation step passes;fluxer-uidoes no I/O (assets areinclude_bytes!); no secrets or tokens in the diff; font licence and NOTICE are identical to the fork's copies; commit message carriesRefs #16and the co-author line.MPL-2.0, which predates this PR.Findings
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.cssdoes define--font-size-*, so later UI tasks will have to hand-pick sizes until a token group exists. Needs afollow-upissue (and a spec correction for Inter) before merge.deny.tomlnow 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.palette.rsbutton::primaryderives border colours by mixing brand tokens withColor::WHITEat 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.icons::svgindexes the handle cache byname as usize, relying onALLbeing in declaration order. The macro guarantees that today and server data cannot reach it; noted only because a hand-edit ofALLwould turn it into a wrong-icon or out-of-bounds bug.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.320a63b23864430a109d