Checkpoint – Notifications Panel
This commit is contained in:
parent
e3d948f60b
commit
32028fbbb1
10 changed files with 318 additions and 107 deletions
48
crates/ui2/src/components/notification_toast.rs
Normal file
48
crates/ui2/src/components/notification_toast.rs
Normal 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()))
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue