From 7714f322340e2ebafffd535df382fd4b258ceb72 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sat, 28 Nov 2026 07:15:06 +0000 Subject: [PATCH] ui: production's type scale and surface rounding through the app's sizes.json; the title bar shows the title and production's item order DeckCraft's sizes.json sets body, strong body and control labels to 13 px, captions to 11 px and headings to 18 px, as production's theme did, and popups and the ribbon card to production's 8 px rounding. The title bar under the OS frame still centres the document title, and its end reads theme, comments, Present, search. Co-Authored-By: Claude Opus 5.5 --- apps/deckcraft-web/src/presenter.rs | 4 ++-- crates/ui-egui/src/app.rs | 4 ++-- crates/ui-egui/src/ribbon/title_bar.rs | 9 +++++---- crates/ui-egui/src/sizes.json | 11 +++++++++++ crates/ui-egui/src/theme.rs | 22 ++++++++++++++++++++++ 5 files changed, 42 insertions(+), 8 deletions(-) create mode 100644 crates/ui-egui/src/sizes.json diff --git a/apps/deckcraft-web/src/presenter.rs b/apps/deckcraft-web/src/presenter.rs index 3817638d2..6b4c25034 100644 --- a/apps/deckcraft-web/src/presenter.rs +++ b/apps/deckcraft-web/src/presenter.rs @@ -5,7 +5,7 @@ use craft::ui::contract::{Politeness, Props as _, Show as _}; use craft::ui::fonts::{I18nScripts, UiFonts}; use craft::ui::notices::{Notice, NoticeLayout}; use craft::ui::primitives::{CachedTexture, Revision, TextureStore, TextureStoreOptions}; -use craft::ui::runtime::env::{RootEnv, WindowKey}; +use craft::ui::runtime::env::WindowKey; use craft::ui::runtime::frame::FrameInput; use craft::ui::shell::{AppShell, embed}; use craft::web_host::link::{LinkLimits, LinkState, WindowLink}; @@ -167,7 +167,7 @@ impl PopupApp { impl eframe::App for PopupApp { fn raw_input_hook(&mut self, ctx: &egui::Context, _input: &mut egui::RawInput) { - embed::before_input(ctx, |_| FrameInput::new(RootEnv::default())); + embed::before_input(ctx, |_| FrameInput::new(deckcraft_ui_egui::theme::root_env())); } fn logic(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) { diff --git a/crates/ui-egui/src/app.rs b/crates/ui-egui/src/app.rs index dbb5ade81..3e93a1a78 100644 --- a/crates/ui-egui/src/app.rs +++ b/crates/ui-egui/src/app.rs @@ -11,7 +11,7 @@ use super::{ }; use craft::ui::contract::{Bind, CommandSet as _, Tracked}; use craft::ui::runtime::commands::{CommandGate, CommandInput}; -use craft::ui::runtime::env::{RootEnv, Scale, WindowKey}; +use craft::ui::runtime::env::{Scale, WindowKey}; use craft::ui::runtime::frame::FrameInput; use craft::ui::runtime::windows::WindowHost; use craft::ui::shell::{AppShell, PageKind, Slot, SlotSize, embed}; @@ -152,7 +152,7 @@ impl SlideApp { injected_target: None, twist_frame: None, clock: Default::default(), - root: RootEnv::new(), + root: crate::theme::root_env(), #[cfg(not(target_arch = "wasm32"))] opening_jobs, dialogs: Default::default(), diff --git a/crates/ui-egui/src/ribbon/title_bar.rs b/crates/ui-egui/src/ribbon/title_bar.rs index 58e7c6209..ead6b7f5a 100644 --- a/crates/ui-egui/src/ribbon/title_bar.rs +++ b/crates/ui-egui/src/ribbon/title_bar.rs @@ -16,19 +16,20 @@ pub fn title_bar(app: &mut SlideApp, ui: &mut egui::Ui, _cx: &mut BodyCx<'_>) { let dirty = app.session.active().is_some_and(|doc| doc.is_dirty()); let title = if dirty { Title::unsaved(text) } else { Title::new(text) }; let dark = app.ui.brightness == crate::state::Brightness::Dark; - TitleBar::new().show_titled( + // The bar under the OS frame still carries the document's title, centred. + TitleBar::new().title_when_native().show_titled( ui, title, |ui, _| super::qat::bar(app, ui), |ui, _| { - IconButton::command(Icon::Search.id(), "app.palette").label("Search commands").show(ui); - Button::command(CommandRef::new("show.fromCurrent")).label("Present").variant(Variant::PRIMARY).show(ui); + IconButton::command(if dark { Icon::Sparkle } else { Icon::Palette }.id(), "view.dark").label("Light/Dark appearance").show(ui); ToggleButton::command(CommandRef::with_params("view.pane", json!({"pane": "comments", "toggle": true}))) .label("Comments") .icon(Icon::CommentsBubble.id()) .icon_only() .show(ui); - IconButton::command(if dark { Icon::Sparkle } else { Icon::Palette }.id(), "view.dark").label("Light/Dark appearance").show(ui); + Button::command(CommandRef::new("show.fromCurrent")).label("Present").variant(Variant::PRIMARY).show(ui); + IconButton::command(Icon::Search.id(), "app.palette").label("Search commands").show(ui); }, ); } diff --git a/crates/ui-egui/src/sizes.json b/crates/ui-egui/src/sizes.json new file mode 100644 index 000000000..8bd8d12d0 --- /dev/null +++ b/crates/ui-egui/src/sizes.json @@ -0,0 +1,11 @@ +{ + "all": { + "radius.surface": 8, + "typography.body.size": 13, + "typography.body_strong.size": 13, + "typography.caption.size": 11, + "typography.heading.line_height": 24, + "typography.heading.size": 18, + "typography.label.size": 13 + } +} diff --git a/crates/ui-egui/src/theme.rs b/crates/ui-egui/src/theme.rs index 3136cf2db..5589d4d0c 100644 --- a/crates/ui-egui/src/theme.rs +++ b/crates/ui-egui/src/theme.rs @@ -265,6 +265,21 @@ pub fn to_color32(c: deckcraft_color::Rgba) -> Color32 { Color32::from_rgba_unmultiplied(c.r, c.g, c.b, c.a) } +/// DeckCraft's overrides of the suite's size sets (`sizes.json`): its interface type scale and surface rounding. One +/// shared value, so every root that carries it keeps one identity for the token cache. +pub fn app_sizes() -> std::sync::Arc { + static SIZES: std::sync::LazyLock> = + std::sync::LazyLock::new(|| std::sync::Arc::new(craft::theme::AppSizes::parse_or_default(include_bytes!("sizes.json")))); + SIZES.clone() +} + +/// The app's root values before the frame's own: [`RootEnv`](craft::ui::runtime::env::RootEnv) with DeckCraft's sizes. +pub fn root_env() -> craft::ui::runtime::env::RootEnv { + let mut root = craft::ui::runtime::env::RootEnv::new(); + root.sizes = app_sizes(); + root +} + #[cfg(test)] mod tests { use super::*; @@ -482,4 +497,11 @@ mod tests { assert!(ink, "{c:?} ({:04X}) draws nothing at {size} px", c as u32); } } + + /// A path or value the size sets reject would make the app fall back to the suite's sizes with only a log line. + #[test] + fn the_apps_sizes_file_is_accepted() { + let sizes = craft::theme::AppSizes::parse(include_bytes!("sizes.json")).expect("sizes.json is valid"); + assert!(!sizes.is_empty()); + } }