use std::marker::PhantomData; use gpui2::{rems, AbsoluteLength}; use crate::prelude::*; use crate::{Icon, IconButton, Label, Panel, PanelSide}; #[derive(Element)] pub struct AssistantPanel { id: ElementId, state_type: PhantomData, current_side: PanelSide, } impl AssistantPanel { pub fn new(id: impl Into) -> Self { Self { id: id.into(), state_type: PhantomData, current_side: PanelSide::default(), } } pub fn side(mut self, side: PanelSide) -> Self { self.current_side = side; self } fn render(&mut self, view: &mut S, cx: &mut ViewContext) -> impl Element { let color = ThemeColor::new(cx); Panel::new(self.id.clone(), cx) .children(vec![div() .flex() .flex_col() .h_full() .px_2() .gap_2() // Header .child( div() .flex() .justify_between() .gap_2() .child( div() .flex() .child(IconButton::new(Icon::Menu)) .child(Label::new("New Conversation")), ) .child( div() .flex() .items_center() .gap_px() .child(IconButton::new(Icon::SplitMessage)) .child(IconButton::new(Icon::Quote)) .child(IconButton::new(Icon::MagicWand)) .child(IconButton::new(Icon::Plus)) .child(IconButton::new(Icon::Maximize)), ), ) // Chat Body .child( div() .id("chat-body") .w_full() .flex() .flex_col() .gap_3() .overflow_y_scroll() .child(Label::new("Is this thing on?")), ) .into_any()]) .side(self.current_side) .width(AbsoluteLength::Rems(rems(32.))) } } #[cfg(feature = "stories")] pub use stories::*; #[cfg(feature = "stories")] mod stories { use crate::Story; use super::*; #[derive(Element)] pub struct AssistantPanelStory { state_type: PhantomData, } impl AssistantPanelStory { pub fn new() -> Self { Self { state_type: PhantomData, } } fn render( &mut self, _view: &mut S, cx: &mut ViewContext, ) -> impl Element { Story::container(cx) .child(Story::title_for::<_, AssistantPanel>(cx)) .child(Story::label(cx, "Default")) .child(AssistantPanel::new("assistant-panel")) } } }