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