From cb16b12a495c1145b516de018f2664b7ca9ac1e4 Mon Sep 17 00:00:00 2001 From: Martin Ball Date: Thu, 19 Nov 2026 14:15:30 +0000 Subject: [PATCH] look-ribbon-3: trials broken by round 2: a ribbon toggle is checked against the ribbon's flat button (round 2 made it flat; a ghost toggle outside a ribbon keeps its edge); the width-roles story holds a dialog's least width so its width does not follow where its paragraph breaks; the side-menu story uses the catalog's save icon Co-Authored-By: Claude Opus 5.5 --- crates/ui-widgets/src/buttons/stories.rs | 2 +- crates/ui-widgets/src/layout_components/stories.rs | 7 +++++-- crates/ui-widgets/tests/it/buttons.rs | 14 +++++++++++--- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/crates/ui-widgets/src/buttons/stories.rs b/crates/ui-widgets/src/buttons/stories.rs index 1688e9bfb..97b436849 100644 --- a/crates/ui-widgets/src/buttons/stories.rs +++ b/crates/ui-widgets/src/buttons/stories.rs @@ -224,7 +224,7 @@ fn button_in_side_menu(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { overrides.values.set(ControlPlace::SideMenu); }, |ui| { - for (name, icon) in [("Home", IconId::new("home")), ("Open", IconId::new("open")), ("Print", IconId::new("print"))] { + for (name, icon) in [("Home", IconId::new("home")), ("Open", IconId::new("open")), ("Save", IconId::new("save"))] { Button::new(name) .icon(icon) .variant(Variant::GHOST) diff --git a/crates/ui-widgets/src/layout_components/stories.rs b/crates/ui-widgets/src/layout_components/stories.rs index ac6d6ceee..c27e79b1a 100644 --- a/crates/ui-widgets/src/layout_components/stories.rs +++ b/crates/ui-widgets/src/layout_components/stories.rs @@ -48,7 +48,9 @@ fn stack_fill_height(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { } /// The two width roles of a content-sized stack: a side menu held at its least width with short items, and a column -/// of settings whose paragraph breaks at the column's line length instead of widening it. +/// of settings whose paragraph breaks at the column's line length instead of widening it. The column also holds a +/// dialog's least width, wider than its line length: where a paragraph's lines break moves with the text size, and the +/// least width keeps the story as wide in every density and text size, so it only grows as the text does. #[story(Stack<'static>, covers = [], title = "Width roles")] fn stack_width_roles(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { outlined(ui, |ui| { @@ -56,7 +58,8 @@ fn stack_width_roles(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { .gap(Gap::Section) .show(ui, |ui, _| { Stack::new().least_width(LeastWidth::SideMenu).gap(Gap::Tight).pad(Pad::Regular).show(ui, |ui, _| words(ui, 0..2)); - Stack::new().wrap_width(WrapWidth::Column).gap(Gap::Stack).pad(Pad::Regular).show(ui, |ui, _| { + let column = Stack::new().wrap_width(WrapWidth::Column).least_width(LeastWidth::Dialog); + column.gap(Gap::Stack).pad(Pad::Regular).show(ui, |ui, _| { let _ = Text::new( "Save a copy in another format. Printing goes through a PDF you can print from any viewer, and the pages \ picked here are the ones that print.", diff --git a/crates/ui-widgets/tests/it/buttons.rs b/crates/ui-widgets/tests/it/buttons.rs index af1461161..fa76f72fb 100644 --- a/crates/ui-widgets/tests/it/buttons.rs +++ b/crates/ui-widgets/tests/it/buttons.rs @@ -405,6 +405,7 @@ fn a_ribbons_buttons_are_flat_at_rest_unless_they_ask_for_a_variant() { }); assert!(ghost.is_some(), "a button has a surface"); assert_eq!(ribbon, ghost, "a ribbon button draws the ghost surface"); + let flat = ribbon.clone().expect("a ribbon button has a surface"); assert_ne!(standard, ghost, "outside a ribbon the default look stays"); assert_ne!(primary, ghost, "a variant asked for in a ribbon stays"); assert!(narrow < wide - 0.5, "a ribbon's flat button sits close: {narrow} against {wide}"); @@ -423,8 +424,9 @@ fn a_ribbons_buttons_are_flat_at_rest_unless_they_ask_for_a_variant() { assert_eq!(ribbon, ghost, "a ribbon split button draws the ghost surface"); assert!(narrow < wide - 0.5, "a ribbon's flat split button sits close: {narrow} against {wide}"); - // A labelled toggle is flat at rest too, with no outlined capsule: the ghost surface, which shows the on plate - // while on. + // A labelled toggle is flat at rest too, as the ribbon's push buttons are: no surface kind and no edge until the + // pointer is over it, and the on plate while on. A ghost toggle outside a ribbon keeps its raised, outlined edge, + // so the ribbon toggle is checked against the ribbon's flat push button, not against it. let toggle = std::any::type_name::>(); let (ribbon, narrow) = seen(toggle, "Track Changes", |ui| { in_ribbon(ui, |ui| { @@ -440,8 +442,14 @@ fn a_ribbons_buttons_are_flat_at_rest_unless_they_ask_for_a_variant() { let mut on = false; let _ = ToggleButton::new("Track Changes", Bind::bound(&mut on)).show(ui); }); - assert_eq!(ribbon, ghost, "a ribbon toggle draws the ghost surface"); + let ribbon = ribbon.expect("a ribbon toggle has a surface"); + assert_eq!(ribbon.kind, flat.kind, "a ribbon toggle draws no surface kind at rest, as a ribbon button"); + assert_eq!(ribbon.fill.off, flat.fill.off, "a ribbon toggle's fill while off is a ribbon button's"); + let edge = ribbon.border.as_ref().map(|border| border.off.rest); + assert!(edge.is_none() || edge == Some(ribbon.fill.off.rest), "a ribbon toggle shows no edge at rest: {edge:?}"); + assert!(ribbon.fill.on.is_some(), "a ribbon toggle shows the on plate while on"); assert_ne!(standard, ghost, "outside a ribbon a toggle keeps its outlined default"); + assert_ne!(Some(ribbon), standard, "a ribbon toggle is not the outlined default"); assert!(narrow < wide - 0.5, "a ribbon's flat toggle sits close: {narrow} against {wide}"); }