Banner text wraps; PropertyGrid label column 104
This commit is contained in:
5 files changed
+47
-17
No files matched your search
+12
-3
@@ -9,7 +9,10 @@ use crate::{
|
|||||||
motion::Spinner,
|
motion::Spinner,
|
||||||
primitives::{FocusRing, Icon, IconName},
|
primitives::{FocusRing, Icon, IconName},
|
||||||
theme::{ActiveTheme, ControlSize, IconSize, Mix, Palette, Platform, Radius, TextSize},
|
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>;
|
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 name = self.label.clone();
|
||||||
let parts = div()
|
let parts = div()
|
||||||
.flex()
|
.flex()
|
||||||
|
.min_w_0()
|
||||||
.items_center()
|
.items_center()
|
||||||
.gap_1p5()
|
.gap_1p5()
|
||||||
.when_some(self.icon, |el, name| el.child(icon(name)))
|
.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(self.trailing_icon, |el, name| el.child(icon(name)))
|
||||||
.when_some(hint, |el, hint| {
|
.when_some(hint, |el, hint| {
|
||||||
el.child(
|
el.child(
|
||||||
@@ -257,7 +263,10 @@ impl RenderOnce for Button {
|
|||||||
.role(Role::Button)
|
.role(Role::Button)
|
||||||
.when(!name.is_empty(), |el| el.aria_label(name))
|
.when(!name.is_empty(), |el| el.aria_label(name))
|
||||||
.flex()
|
.flex()
|
||||||
.flex_none()
|
// Never grows; shrinks only when a row cannot wrap.
|
||||||
|
.flex_grow_0()
|
||||||
|
.flex_shrink_1()
|
||||||
|
.min_w_0()
|
||||||
.items_center()
|
.items_center()
|
||||||
.justify_center()
|
.justify_center()
|
||||||
.gap_1p5()
|
.gap_1p5()
|
||||||
|
|||||||
@@ -229,7 +229,7 @@ impl RenderOnce for PropertyGrid {
|
|||||||
.child(
|
.child(
|
||||||
div()
|
div()
|
||||||
.flex_none()
|
.flex_none()
|
||||||
.w(theme.label_width() * 0.75)
|
.w(theme.label_width() * 0.65)
|
||||||
.text_color(colors.fg_muted)
|
.text_color(colors.fg_muted)
|
||||||
.child(name),
|
.child(name),
|
||||||
)
|
)
|
||||||
|
|||||||
+23
-11
@@ -182,18 +182,30 @@ impl RenderOnce for Banner {
|
|||||||
.text_size(theme.text_size(TextSize::Base))
|
.text_size(theme.text_size(TextSize::Base))
|
||||||
.text_color(colors.fg)
|
.text_color(colors.fg)
|
||||||
.child(
|
.child(
|
||||||
Icon::new(self.severity.icon())
|
div().flex_none().child(
|
||||||
.size(IconSize::Sm)
|
Icon::new(self.severity.icon())
|
||||||
.color(self.severity.color(colors)),
|
.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| {
|
.when_some(self.on_dismiss, |banner, run| {
|
||||||
banner.child(
|
banner.child(
|
||||||
div()
|
div()
|
||||||
|
|||||||
+9
-1
@@ -19,6 +19,7 @@ pub struct Switch {
|
|||||||
id: ElementId,
|
id: ElementId,
|
||||||
on: bool,
|
on: bool,
|
||||||
label: Option<SharedString>,
|
label: Option<SharedString>,
|
||||||
|
name: Option<SharedString>,
|
||||||
disabled: bool,
|
disabled: bool,
|
||||||
on_change: Option<OnFlag>,
|
on_change: Option<OnFlag>,
|
||||||
}
|
}
|
||||||
@@ -29,6 +30,7 @@ impl Switch {
|
|||||||
id: id.into(),
|
id: id.into(),
|
||||||
on,
|
on,
|
||||||
label: None,
|
label: None,
|
||||||
|
name: None,
|
||||||
disabled: false,
|
disabled: false,
|
||||||
on_change: None,
|
on_change: None,
|
||||||
}
|
}
|
||||||
@@ -39,6 +41,12 @@ impl Switch {
|
|||||||
self
|
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 {
|
pub fn disabled(mut self, disabled: bool) -> Self {
|
||||||
self.disabled = disabled;
|
self.disabled = disabled;
|
||||||
self
|
self
|
||||||
@@ -121,7 +129,7 @@ impl RenderOnce for Switch {
|
|||||||
.id(self.id)
|
.id(self.id)
|
||||||
.role(Role::Switch)
|
.role(Role::Switch)
|
||||||
.aria_toggled(self.on.into())
|
.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| {
|
.when(self.disabled, |row| {
|
||||||
row.aria_description(i18n::text(cx, "state.unavailable", &[]))
|
row.aria_description(i18n::text(cx, "state.unavailable", &[]))
|
||||||
})
|
})
|
||||||
|
|||||||
+2
-1
@@ -433,9 +433,10 @@ impl RenderOnce for CommitInput {
|
|||||||
.child(
|
.child(
|
||||||
div()
|
div()
|
||||||
.flex()
|
.flex()
|
||||||
|
.flex_wrap()
|
||||||
.items_center()
|
.items_center()
|
||||||
.gap_2()
|
.gap_2()
|
||||||
.child(div().flex_1().child(amend))
|
.child(div().flex_1().min_w_0().child(amend))
|
||||||
.child(
|
.child(
|
||||||
Button::new((self.id.clone(), "commit"), label)
|
Button::new((self.id.clone(), "commit"), label)
|
||||||
.variant(ButtonVariant::Primary)
|
.variant(ButtonVariant::Primary)
|
||||||
|
|||||||
Reference in new issue
Block a user