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