From 62dff57b854cb55bfaf0b7da327311722f6d7087 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Thu, 8 Oct 2026 20:59:04 -0400 Subject: [PATCH] Banner text wraps; PropertyGrid label column 104 --- src/buttons/button.rs | 15 ++++++++++++--- src/data_display/records.rs | 2 +- src/feedback/messages.rs | 34 +++++++++++++++++++++++----------- src/forms/switch.rs | 10 +++++++++- src/git/changes.rs | 3 ++- 5 files changed, 47 insertions(+), 17 deletions(-) diff --git a/src/buttons/button.rs b/src/buttons/button.rs index 3de04cf..d895dfd 100644 --- a/src/buttons/button.rs +++ b/src/buttons/button.rs @@ -9,7 +9,10 @@ use crate::{ motion::Spinner, primitives::{FocusRing, Icon, IconName}, theme::{ActiveTheme, ControlSize, IconSize, Mix, Palette, Platform, Radius, TextSize}, - typography::keys::{keystroke, keystroke_labels}, + typography::{ + Ellipsis, + keys::{keystroke, keystroke_labels}, + }, }; pub(crate) type ClickHandler = Box; @@ -237,10 +240,13 @@ impl RenderOnce for Button { let name = self.label.clone(); let parts = div() .flex() + .min_w_0() .items_center() .gap_1p5() .when_some(self.icon, |el, name| el.child(icon(name))) - .when(!self.label.is_empty(), |el| el.child(self.label)) + .when(!self.label.is_empty(), |el| { + el.child(div().min_w_0().child(Ellipsis::new(self.label))) + }) .when_some(self.trailing_icon, |el, name| el.child(icon(name))) .when_some(hint, |el, hint| { el.child( @@ -257,7 +263,10 @@ impl RenderOnce for Button { .role(Role::Button) .when(!name.is_empty(), |el| el.aria_label(name)) .flex() - .flex_none() + // Never grows; shrinks only when a row cannot wrap. + .flex_grow_0() + .flex_shrink_1() + .min_w_0() .items_center() .justify_center() .gap_1p5() diff --git a/src/data_display/records.rs b/src/data_display/records.rs index d88069c..fc48ee0 100644 --- a/src/data_display/records.rs +++ b/src/data_display/records.rs @@ -229,7 +229,7 @@ impl RenderOnce for PropertyGrid { .child( div() .flex_none() - .w(theme.label_width() * 0.75) + .w(theme.label_width() * 0.65) .text_color(colors.fg_muted) .child(name), ) diff --git a/src/feedback/messages.rs b/src/feedback/messages.rs index cb655ac..2278117 100644 --- a/src/feedback/messages.rs +++ b/src/feedback/messages.rs @@ -182,18 +182,30 @@ impl RenderOnce for Banner { .text_size(theme.text_size(TextSize::Base)) .text_color(colors.fg) .child( - Icon::new(self.severity.icon()) - .size(IconSize::Sm) - .color(self.severity.color(colors)), + div().flex_none().child( + Icon::new(self.severity.icon()) + .size(IconSize::Sm) + .color(self.severity.color(colors)), + ), + ) + // Narrow, the message wraps and the action goes below it. + .child( + div() + .flex() + .flex_wrap() + .flex_shrink_1() + .min_w_0() + .items_center() + .gap_x_2() + .child(div().min_w_0().child(self.message)) + .when_some(self.action, |text, (label, run)| { + text.child( + Button::new(link, label) + .variant(ButtonVariant::Link) + .on_click(move |_, window, cx| run(window, cx)), + ) + }), ) - .child(self.message) - .when_some(self.action, |banner, (label, run)| { - banner.child( - Button::new(link, label) - .variant(ButtonVariant::Link) - .on_click(move |_, window, cx| run(window, cx)), - ) - }) .when_some(self.on_dismiss, |banner, run| { banner.child( div() diff --git a/src/forms/switch.rs b/src/forms/switch.rs index 113933b..2b412fa 100644 --- a/src/forms/switch.rs +++ b/src/forms/switch.rs @@ -19,6 +19,7 @@ pub struct Switch { id: ElementId, on: bool, label: Option, + name: Option, disabled: bool, on_change: Option, } @@ -29,6 +30,7 @@ impl Switch { id: id.into(), on, label: None, + name: None, disabled: false, on_change: None, } @@ -39,6 +41,12 @@ impl Switch { self } + /// Names it for assistive technology, drawing nothing. + pub fn name(mut self, name: impl Into) -> Self { + self.name = Some(name.into()); + self + } + pub fn disabled(mut self, disabled: bool) -> Self { self.disabled = disabled; self @@ -121,7 +129,7 @@ impl RenderOnce for Switch { .id(self.id) .role(Role::Switch) .aria_toggled(self.on.into()) - .when_some(self.label.clone(), |row, label| row.aria_label(label)) + .when_some(self.label.clone().or(self.name), |row, label| row.aria_label(label)) .when(self.disabled, |row| { row.aria_description(i18n::text(cx, "state.unavailable", &[])) }) diff --git a/src/git/changes.rs b/src/git/changes.rs index 7f99c1a..d96c82d 100644 --- a/src/git/changes.rs +++ b/src/git/changes.rs @@ -433,9 +433,10 @@ impl RenderOnce for CommitInput { .child( div() .flex() + .flex_wrap() .items_center() .gap_2() - .child(div().flex_1().child(amend)) + .child(div().flex_1().min_w_0().child(amend)) .child( Button::new((self.id.clone(), "commit"), label) .variant(ButtonVariant::Primary)