1use gpui2::rems;
2
3use crate::{h_stack, prelude::*, Icon};
4
5#[derive(Component)]
6pub struct NotificationToast {
7 label: SharedString,
8 icon: Option<Icon>,
9}
10
11impl NotificationToast {
12 pub fn new(label: SharedString) -> Self {
13 Self { label, icon: None }
14 }
15
16 pub fn icon<I>(mut self, icon: I) -> Self
17 where
18 I: Into<Option<Icon>>,
19 {
20 self.icon = icon.into();
21 self
22 }
23
24 fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
25 let theme = theme(cx);
26
27 h_stack()
28 .z_index(5)
29 .absolute()
30 .top_1()
31 .right_1()
32 .w(rems(9999.))
33 .max_w_56()
34 .py_1()
35 .px_1p5()
36 .rounded_lg()
37 .shadow_md()
38 .bg(theme.elevated_surface)
39 .child(div().size_full().child(self.label.clone()))
40 }
41}