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, cx: &mut ViewContext<S>) -> impl Element<State = S> {
24 let theme = theme(cx);
25
26 div()
27 .flex()
28 .flex_col()
29 .w_full()
30 .h_full()
31 .px_2()
32 .fill(theme.middle.base.default.background)
33 .child(
34 div()
35 .w_56()
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(&mut self, cx: &mut ViewContext<S>) -> impl Element<State = S> {
82 Story::container(cx)
83 .child(Story::title_for::<_, ProjectPanel<S>>(cx))
84 .child(Story::label(cx, "Default"))
85 .child(Panel::new(
86 ScrollState::default(),
87 |_, _| vec![ProjectPanel::new(ScrollState::default()).into_any()],
88 Box::new(()),
89 ))
90 }
91 }
92}