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