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 + Clone> {
10 state_type: PhantomData<S>,
11 scroll_state: ScrollState,
12}
13
14impl<S: 'static + Send + Sync + Clone> ProjectPanel<S> {
15 pub fn new(scroll_state: ScrollState) -> Self {
16 Self {
17 state_type: PhantomData,
18 scroll_state,
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 .flex()
28 .flex_col()
29 .w_full()
30 .h_full()
31 .bg(color.surface)
32 .child(
33 div()
34 .w_full()
35 .flex()
36 .flex_col()
37 .overflow_y_scroll(ScrollState::default())
38 .child(
39 List::new(static_project_panel_single_items())
40 .header(ListHeader::new("FILES").set_toggle(ToggleState::Toggled))
41 .empty_message("No files in directory")
42 .set_toggle(ToggleState::Toggled),
43 )
44 .child(
45 List::new(static_project_panel_project_items())
46 .header(ListHeader::new("PROJECT").set_toggle(ToggleState::Toggled))
47 .empty_message("No folders in directory")
48 .set_toggle(ToggleState::Toggled),
49 ),
50 )
51 .child(
52 Input::new("Find something...")
53 .value("buffe".to_string())
54 .state(InteractionState::Focused),
55 )
56 }
57}
58
59#[cfg(feature = "stories")]
60pub use stories::*;
61
62#[cfg(feature = "stories")]
63mod stories {
64 use crate::{Panel, Story};
65
66 use super::*;
67
68 #[derive(Element)]
69 pub struct ProjectPanelStory<S: 'static + Send + Sync + Clone> {
70 state_type: PhantomData<S>,
71 }
72
73 impl<S: 'static + Send + Sync + Clone> ProjectPanelStory<S> {
74 pub fn new() -> Self {
75 Self {
76 state_type: PhantomData,
77 }
78 }
79
80 fn render(
81 &mut self,
82 _view: &mut S,
83 cx: &mut ViewContext<S>,
84 ) -> impl Element<ViewState = S> {
85 Story::container(cx)
86 .child(Story::title_for::<_, ProjectPanel<S>>(cx))
87 .child(Story::label(cx, "Default"))
88 .child(
89 Panel::new(cx)
90 .child(ProjectPanel::new(ScrollState::default())),
91 )
92 }
93 }
94}