utils: add shared StyledExt styling helper

This commit is contained in:
2026-11-16 14:02:33 +07:00
parent d7e4047070
commit 745a01d7af
29 changed files with 332 additions and 68 deletions
+6 -2
View File
@@ -7,14 +7,15 @@ use gpui::prelude::FluentBuilder;
use gpui::{
Animation, AnimationExt as _, App, Context, ElementId, Entity, InteractiveElement as _,
IntoElement, ParentElement as _, RenderOnce, Role, SharedString,
StatefulInteractiveElement as _, Styled as _, Task, Window, deferred, div, ease_out_quint, px,
StatefulInteractiveElement as _, StyleRefinement, Styled as _, Task, Window, deferred, div,
ease_out_quint, px,
};
use gpui_native_icons::{Icon, IconRole};
use gpui_native_theme::{ActiveTheme as _, TOAST_MAX_WIDTH};
use gpui_native_utils::ResultLogErr as _;
use crate::button::{Button, ButtonVariant};
use crate::common::{DismissHandler, Sizable as _, TOAST_LAYER};
use crate::common::{DismissHandler, Sizable as _, StyledExt as _, TOAST_LAYER};
/// The action handler of a [`Toast`].
pub type ActionHandler = Rc<dyn Fn(&mut App)>;
@@ -49,6 +50,7 @@ pub struct Toast {
action: Option<ToastAction>,
duration: Option<Duration>,
on_dismiss: Option<DismissHandler>,
style: StyleRefinement,
}
impl Toast {
@@ -66,6 +68,7 @@ impl Toast {
action: None,
duration: Some(Self::DURATION),
on_dismiss: None,
style: StyleRefinement::default(),
}
}
@@ -300,6 +303,7 @@ impl ToastEntry {
.border_color(border)
.rounded(radius)
.shadow(shadows.clone())
.refine_style(&toast.style)
.when_some(toast.icon.clone(), |pill, icon| {
pill.child(
div()