1use std::marker::PhantomData;
2
3use crate::icon_button;
4use crate::theme::theme;
5use gpui2::elements::div::ScrollState;
6use gpui2::style::StyleHelpers;
7use gpui2::{elements::div, IntoElement};
8use gpui2::{Element, ParentElement, ViewContext};
9
10#[derive(Element)]
11pub struct ChatPanel<V: 'static> {
12 view_type: PhantomData<V>,
13 scroll_state: ScrollState,
14}
15
16pub fn chat_panel<V: 'static>(scroll_state: ScrollState) -> ChatPanel<V> {
17 ChatPanel {
18 view_type: PhantomData,
19 scroll_state,
20 }
21}
22
23impl<V: 'static> ChatPanel<V> {
24 fn render(&mut self, _: &mut V, cx: &mut ViewContext<V>) -> impl IntoElement<V> {
25 let theme = theme(cx);
26
27 div()
28 .h_full()
29 .flex()
30 // Header
31 .child(
32 div()
33 .px_2()
34 .flex()
35 .gap_2()
36 // Nav Buttons
37 .child("#gpui2"),
38 )
39 // Chat Body
40 .child(
41 div()
42 .w_full()
43 .flex()
44 .flex_col()
45 .overflow_y_scroll(self.scroll_state.clone())
46 .child("body"),
47 )
48 // Composer
49 .child(
50 div()
51 .px_2()
52 .flex()
53 .gap_2()
54 // Nav Buttons
55 .child(
56 div()
57 .flex()
58 .items_center()
59 .gap_px()
60 .child(icon_button("icons/plus.svg"))
61 .child(icon_button("icons/split.svg")),
62 ),
63 )
64 }
65}