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