1
2use crate::{prelude::*, static_new_notification_items, static_read_notification_items};
3use crate::{List, ListHeader};
4
5#[derive(Component)]
6pub struct NotificationsPanel {
7 id: ElementId,
8}
9
10impl NotificationsPanel {
11 pub fn new(id: impl Into<ElementId>) -> Self {
12 Self {
13 id: id.into(),
14 }
15 }
16
17 fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
18 let theme = theme(cx);
19
20 div()
21 .id(self.id.clone())
22 .flex()
23 .flex_col()
24 .w_full()
25 .h_full()
26 .bg(theme.surface)
27 .child(
28 div()
29 .id("header")
30 .w_full()
31 .flex()
32 .flex_col()
33 .overflow_y_scroll()
34 .child(
35 List::new(static_new_notification_items())
36 .header(ListHeader::new("NEW").toggle(ToggleState::Toggled))
37 .toggle(ToggleState::Toggled),
38 )
39 .child(
40 List::new(static_read_notification_items())
41 .header(ListHeader::new("EARLIER").toggle(ToggleState::Toggled))
42 .empty_message("No new notifications")
43 .toggle(ToggleState::Toggled),
44 ),
45 )
46 }
47}
48
49#[cfg(feature = "stories")]
50pub use stories::*;
51
52#[cfg(feature = "stories")]
53mod stories {
54 use crate::{Panel, Story};
55
56 use super::*;
57
58 #[derive(Component)]
59 pub struct NotificationsPanelStory;
60
61 impl NotificationsPanelStory {
62 pub fn new() -> Self {
63 Self
64 }
65
66 fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
67 Story::container(cx)
68 .child(Story::title_for::<_, NotificationsPanel>(cx))
69 .child(Story::label(cx, "Default"))
70 .child(
71 Panel::new("panel", cx).child(NotificationsPanel::new("notifications_panel")),
72 )
73 }
74 }
75}