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