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