Banner text wraps; PropertyGrid label column 104

This commit is contained in:
ZacharyZhang-NY committed 2026-10-08 20:59:04 -04:00
1 parent 6d95b24889
commit 62dff57b85
5 files changed
+47 -17

No files matched your search

+12 -3
View File
@@ -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<dyn Fn(&ClickEvent, &mut Window, &mut App) + 'static>;
@@ -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()
+1 -1
View File
@@ -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),
)
+23 -11
View File
@@ -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()
+9 -1
View File
@@ -19,6 +19,7 @@ pub struct Switch {
id: ElementId,
on: bool,
label: Option<SharedString>,
name: Option<SharedString>,
disabled: bool,
on_change: Option<OnFlag>,
}
@@ -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<SharedString>) -> 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", &[]))
})
+2 -1
View File
@@ -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)