1use crate::prelude::*;
2use crate::{
3 static_collab_panel_channels, static_collab_panel_current_call, v_stack, Icon, List,
4 ListHeader, ToggleState,
5};
6
7#[derive(Component)]
8pub struct CollabPanel {
9 id: ElementId,
10}
11
12impl CollabPanel {
13 pub fn new(id: impl Into<ElementId>) -> Self {
14 Self { id: id.into() }
15 }
16
17 fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
18 let theme = theme(cx);
19
20 v_stack()
21 .id(self.id.clone())
22 .h_full()
23 .bg(theme.surface)
24 .child(
25 v_stack()
26 .id("crdb")
27 .w_full()
28 .overflow_y_scroll()
29 .child(
30 div().pb_1().border_color(theme.border).border_b().child(
31 List::new(static_collab_panel_current_call())
32 .header(
33 ListHeader::new("CRDB")
34 .left_icon(Icon::Hash.into())
35 .toggle(ToggleState::Toggled),
36 )
37 .toggle(ToggleState::Toggled),
38 ),
39 )
40 .child(
41 v_stack().id("channels").py_1().child(
42 List::new(static_collab_panel_channels())
43 .header(ListHeader::new("CHANNELS").toggle(ToggleState::Toggled))
44 .empty_message("No channels yet. Add a channel to get started.")
45 .toggle(ToggleState::Toggled),
46 ),
47 )
48 .child(
49 v_stack().id("contacts-online").py_1().child(
50 List::new(static_collab_panel_current_call())
51 .header(
52 ListHeader::new("CONTACTS – ONLINE")
53 .toggle(ToggleState::Toggled),
54 )
55 .toggle(ToggleState::Toggled),
56 ),
57 )
58 .child(
59 v_stack().id("contacts-offline").py_1().child(
60 List::new(static_collab_panel_current_call())
61 .header(
62 ListHeader::new("CONTACTS – OFFLINE")
63 .toggle(ToggleState::NotToggled),
64 )
65 .toggle(ToggleState::NotToggled),
66 ),
67 ),
68 )
69 .child(
70 div()
71 .h_7()
72 .px_2()
73 .border_t()
74 .border_color(theme.border)
75 .flex()
76 .items_center()
77 .child(
78 div()
79 .text_sm()
80 .text_color(theme.text_placeholder)
81 .child("Find..."),
82 ),
83 )
84 }
85}
86
87#[cfg(feature = "stories")]
88pub use stories::*;
89
90#[cfg(feature = "stories")]
91mod stories {
92 use crate::Story;
93
94 use super::*;
95
96 #[derive(Component)]
97 pub struct CollabPanelStory;
98
99 impl CollabPanelStory {
100 fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
101 Story::container(cx)
102 .child(Story::title_for::<_, CollabPanel>(cx))
103 .child(Story::label(cx, "Default"))
104 .child(CollabPanel::new("collab-panel"))
105 }
106 }
107}