use std::marker::PhantomData; use gpui3::rems; use crate::{h_stack, prelude::*, Icon}; #[derive(Element)] pub struct NotificationToast { state_type: PhantomData, label: SharedString, icon: Option, } impl NotificationToast { pub fn new(label: SharedString) -> Self { Self { state_type: PhantomData, label, icon: None, } } pub fn icon(mut self, icon: I) -> Self where I: Into>, { self.icon = icon.into(); self } fn render(&mut self, _view: &mut S, cx: &mut ViewContext) -> impl Element { let color = ThemeColor::new(cx); h_stack() .z_index(5) .absolute() .top_1() .right_1() .w(rems(9999.)) .max_w_56() .py_1() .px_1p5() .rounded_lg() .shadow_md() .bg(color.elevated_surface) .child(div().size_full().child(self.label.clone())) } }