1use crate::prelude::*;
2use crate::{
3 static_project_panel_project_items, static_project_panel_single_items, Input, List, ListHeader,
4};
5
6#[derive(Component)]
7pub struct ProjectPanel {
8 id: ElementId,
9}
10
11impl ProjectPanel {
12 pub fn new(id: impl Into<ElementId>) -> Self {
13 Self { id: id.into() }
14 }
15
16 fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
17 let theme = theme(cx);
18
19 div()
20 .id(self.id.clone())
21 .flex()
22 .flex_col()
23 .w_full()
24 .h_full()
25 .bg(theme.surface)
26 .child(
27 div()
28 .id("project-panel-contents")
29 .w_full()
30 .flex()
31 .flex_col()
32 .overflow_y_scroll()
33 .child(
34 List::new(static_project_panel_single_items())
35 .header(ListHeader::new("FILES").toggle(ToggleState::Toggled))
36 .empty_message("No files in directory")
37 .toggle(ToggleState::Toggled),
38 )
39 .child(
40 List::new(static_project_panel_project_items())
41 .header(ListHeader::new("PROJECT").toggle(ToggleState::Toggled))
42 .empty_message("No folders in directory")
43 .toggle(ToggleState::Toggled),
44 ),
45 )
46 .child(
47 Input::new("Find something...")
48 .value("buffe".to_string())
49 .state(InteractionState::Focused),
50 )
51 }
52}
53
54use gpui2::ElementId;
55#[cfg(feature = "stories")]
56pub use stories::*;
57
58#[cfg(feature = "stories")]
59mod stories {
60 use crate::{Panel, Story};
61
62 use super::*;
63
64 #[derive(Component)]
65 pub struct ProjectPanelStory;
66
67 impl ProjectPanelStory {
68 fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
69 Story::container(cx)
70 .child(Story::title_for::<_, ProjectPanel>(cx))
71 .child(Story::label(cx, "Default"))
72 .child(
73 Panel::new("project-panel-outer", cx)
74 .child(ProjectPanel::new("project-panel-inner")),
75 )
76 }
77 }
78}