History

Render `Panel`

Marshall Bowers committed 3 years ago

Commit aae4f001 parent 366a4912 files · +54 −50Browse files

Unified · Split

2 files
  1. crates/storybook2/src/ui/components/panel.rs +9 −7
  2. crates/storybook2/src/workspace.rs +45 −43
crates/storybook2/src/ui/components/panel.rs+9−7
@@ -39,8 +39,9 @@ pub enum PanelSide { · 38 unmodified lines
39 39
40use std::collections::HashSet;40use std::collections::HashSet;
41 41
42// #[derive(Element)]42#[derive(Element)]
43pub struct Panel {43pub struct Panel<S: 'static + Send + Sync> {
44 state_type: PhantomData<S>,
44 scroll_state: ScrollState,45 scroll_state: ScrollState,
45 current_side: PanelSide,46 current_side: PanelSide,
46 /// Defaults to PanelAllowedSides::LeftAndRight47 /// Defaults to PanelAllowedSides::LeftAndRight
@@ -51,7 +52,7 @@ pub struct Panel { · 4 unmodified lines
51 // payload: HackyChildrenPayload,52 // payload: HackyChildrenPayload,
52}53}
53 54
54impl Panel {55impl<S: 'static + Send + Sync> Panel<S> {
55 pub fn new(56 pub fn new(
56 scroll_state: ScrollState,57 scroll_state: ScrollState,
57 // children: HackyChildren<S>,58 // children: HackyChildren<S>,
@@ -60,6 +61,7 @@ impl Panel { · 2 unmodified lines
60 let token = token();61 let token = token();
61 62
62 Self {63 Self {
64 state_type: PhantomData,
63 scroll_state,65 scroll_state,
64 current_side: PanelSide::default(),66 current_side: PanelSide::default(),
65 allowed_sides: PanelAllowedSides::default(),67 allowed_sides: PanelAllowedSides::default(),
@@ -99,7 +101,7 @@ impl Panel { · 33 unmodified lines
99 self101 self
100 }102 }
101 103
102 fn render<S: 'static + Send + Sync>(&mut self, cx: &mut ViewContext<S>) -> impl Element<State = S> {104 fn render(&mut self, cx: &mut ViewContext<S>) -> impl Element<State = S> {
103 let token = token();105 let token = token();
104 let theme = rose_pine_dawn();106 let theme = rose_pine_dawn();
105 107
@@ -112,7 +114,7 @@ impl Panel { · 6 unmodified lines
112 .flex_initial()114 .flex_initial()
113 .h_full()115 .h_full()
114 // .w(current_width)116 // .w(current_width)
115 .w_4()117 .w_64()
116 .fill(theme.middle.base.default.background)118 .fill(theme.middle.base.default.background)
117 .border_r()119 .border_r()
118 .border_color(theme.middle.base.default.border);120 .border_color(theme.middle.base.default.border);
@@ -122,7 +124,7 @@ impl Panel { · 3 unmodified lines
122 .flex_initial()124 .flex_initial()
123 .h_full()125 .h_full()
124 // .w(current_width)126 // .w(current_width)
125 .w_4()127 .w_64()
126 .fill(theme.middle.base.default.background)128 .fill(theme.middle.base.default.background)
127 .border_l()129 .border_l()
128 .border_color(theme.middle.base.default.border);130 .border_color(theme.middle.base.default.border);
@@ -132,7 +134,7 @@ impl Panel { · 3 unmodified lines
132 .flex_initial()134 .flex_initial()
133 .w_full()135 .w_full()
134 // .h(current_width)136 // .h(current_width)
135 .h_4()137 .h_64()
136 .fill(theme.middle.base.default.background)138 .fill(theme.middle.base.default.background)
137 .border_t()139 .border_t()
138 .border_color(theme.middle.base.default.border);140 .border_color(theme.middle.base.default.border);
crates/storybook2/src/workspace.rs+45−43
@@ -30,57 +30,59 @@ impl Workspace { · 29 unmodified lines
30 fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element<State = Self> {30 fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element<State = Self> {
31 let theme = rose_pine_dawn();31 let theme = rose_pine_dawn();
32 32
33 // div()
34 // .size_full()
35 // .v_stack()
36 // .fill(theme.lowest.base.default.background)
37 // .child(Panel::new(ScrollState::default()))
38 // .child(
39 // div()
40 // .size_full()
41 // .h_stack()
42 // .gap_3()
43 // .children((0..4).map(|i| {
44 // div().size_full().flex().fill(gpui3::hsla(
45 // 0. + (i as f32 / 7.),
46 // 0. + (i as f32 / 5.),
47 // 0.5,
48 // 1.,
49 // ))
50 // })),
51 // )
52 // .child(
53 // div()
54 // .size_full()
55 // .flex()
56 // .fill(theme.middle.negative.default.background),
57 // )
58
59 themed(rose_pine_dawn(), cx, |cx| {33 themed(rose_pine_dawn(), cx, |cx| {
60 div()34 div()
61 .size_full()35 .size_full()
62 .flex()36 .v_stack()
63 .flex_col()37 .fill(theme.lowest.base.default.background)
64 .font("Courier")38 .child(Panel::new(ScrollState::default()))
65 .gap_0()
66 .justify_start()
67 .items_start()
68 .text_color(theme.lowest.base.default.foreground)
69 .fill(theme.middle.base.default.background)
70 .child(titlebar(cx))
71 .child(39 .child(
72 div()40 div()
73 .flex_1()41 .size_full()
74 .w_full()42 .h_stack()
43 .gap_3()
44 .children((0..4).map(|i| {
45 div().size_full().flex().fill(gpui3::hsla(
46 0. + (i as f32 / 7.),
47 0. + (i as f32 / 5.),
48 0.5,
49 1.,
50 ))
51 })),
52 )
53 .child(
54 div()
55 .size_full()
75 .flex()56 .flex()
76 .flex_row()57 .fill(theme.middle.negative.default.background),
77 .overflow_hidden()
78 .child(self.left_panel.clone())
79 .child(div().h_full().flex_1())
80 .child(self.right_panel.clone()),
81 )58 )
82 .child(statusbar::statusbar(cx))
83 })59 })
60
61 // themed(rose_pine_dawn(), cx, |cx| {
62 // div()
63 // .size_full()
64 // .flex()
65 // .flex_col()
66 // .font("Courier")
67 // .gap_0()
68 // .justify_start()
69 // .items_start()
70 // .text_color(theme.lowest.base.default.foreground)
71 // .fill(theme.middle.base.default.background)
72 // .child(titlebar(cx))
73 // .child(
74 // div()
75 // .flex_1()
76 // .w_full()
77 // .flex()
78 // .flex_row()
79 // .overflow_hidden()
80 // .child(self.left_panel.clone())
81 // .child(div().h_full().flex_1())
82 // .child(self.right_panel.clone()),
83 // )
84 // .child(statusbar::statusbar(cx))
85 // })
84 }86 }
85}87}
86 88

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t