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 <noreply@anthropic.com>
This commit is contained in:
Martin Ball
2026-11-19 14:15:30 +00:00
co-authored by Claude Opus 5.5
parent 566ba7bdbc
commit cb16b12a49
3 changed files with 17 additions and 6 deletions
+1 -1
View File
@@ -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)
@@ -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.",
+11 -3
View File
@@ -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::<ToggleButton<'static>>();
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}");
}