Checkpoint – Notifications Panel

This commit is contained in:
Nate Butler 2023-10-19 20:04:21 -04:00
parent e3d948f60b
commit 32028fbbb1
10 changed files with 318 additions and 107 deletions

View file

@ -0,0 +1,48 @@
use std::marker::PhantomData;
use gpui3::rems;
use crate::{h_stack, prelude::*, Icon};
#[derive(Element)]
pub struct NotificationToast<S: 'static + Send + Sync + Clone> {
state_type: PhantomData<S>,
label: SharedString,
icon: Option<Icon>,
}
impl<S: 'static + Send + Sync + Clone> NotificationToast<S> {
pub fn new(label: SharedString) -> Self {
Self {
state_type: PhantomData,
label,
icon: None,
}
}
pub fn icon<I>(mut self, icon: I) -> Self
where
I: Into<Option<Icon>>,
{
self.icon = icon.into();
self
}
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
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()))
}
}