1use crate::prelude::*;
2use crate::{Icon, IconButton, Label, Panel, PanelSide};
3use gpui::{prelude::*, rems, AbsoluteLength, RenderOnce};
4
5#[derive(RenderOnce)]
6pub struct AssistantPanel {
7 id: ElementId,
8 current_side: PanelSide,
9}
10
11impl<V: 'static> Component<V> for AssistantPanel {
12 type Rendered = Panel<V>;
13
14 fn render(self, view: &mut V, cx: &mut ViewContext<V>) -> Self::Rendered {
15 Panel::new(self.id.clone(), cx)
16 .children(vec![div()
17 .flex()
18 .flex_col()
19 .h_full()
20 .px_2()
21 .gap_2()
22 // Header
23 .child(
24 div()
25 .flex()
26 .justify_between()
27 .gap_2()
28 .child(
29 div()
30 .flex()
31 .child(IconButton::new("menu", Icon::Menu))
32 .child(Label::new("New Conversation")),
33 )
34 .child(
35 div()
36 .flex()
37 .items_center()
38 .gap_px()
39 .child(IconButton::new("split_message", Icon::SplitMessage))
40 .child(IconButton::new("quote", Icon::Quote))
41 .child(IconButton::new("magic_wand", Icon::MagicWand))
42 .child(IconButton::new("plus", Icon::Plus))
43 .child(IconButton::new("maximize", Icon::Maximize)),
44 ),
45 )
46 // Chat Body
47 .child(
48 div()
49 .id("chat-body")
50 .w_full()
51 .flex()
52 .flex_col()
53 .gap_3()
54 .overflow_y_scroll()
55 .child(Label::new("Is this thing on?")),
56 )
57 .into_any()])
58 .side(self.current_side)
59 .width(AbsoluteLength::Rems(rems(32.)))
60 }
61}
62
63impl AssistantPanel {
64 pub fn new(id: impl Into<ElementId>) -> Self {
65 Self {
66 id: id.into(),
67 current_side: PanelSide::default(),
68 }
69 }
70
71 pub fn side(mut self, side: PanelSide) -> Self {
72 self.current_side = side;
73 self
74 }
75}
76
77#[cfg(feature = "stories")]
78pub use stories::*;
79
80#[cfg(feature = "stories")]
81mod stories {
82 use super::*;
83 use crate::Story;
84 use gpui::{Div, Render};
85 pub struct AssistantPanelStory;
86
87 impl Render<Self> for AssistantPanelStory {
88 type Element = Div<Self>;
89
90 fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
91 Story::container(cx)
92 .child(Story::title_for::<_, AssistantPanel>(cx))
93 .child(Story::label(cx, "Default"))
94 .child(AssistantPanel::new("assistant-panel"))
95 }
96 }
97}