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
3939
4040 use std::collections::HashSet;
4141
42−// #[derive(Element)]
43−pub struct Panel {
42+#[derive(Element)]
43+pub struct Panel<S: 'static + Send + Sync> {
44+ state_type: PhantomData<S>,
4445 scroll_state: ScrollState,
4546 current_side: PanelSide,
4647 /// Defaults to PanelAllowedSides::LeftAndRight
@@ -51,7 +52,7 @@ pub struct Panel { · 4 unmodified lines
5152 // payload: HackyChildrenPayload,
5253 }
5354
54−impl Panel {
55+impl<S: 'static + Send + Sync> Panel<S> {
5556 pub fn new(
5657 scroll_state: ScrollState,
5758 // children: HackyChildren<S>,
@@ -60,6 +61,7 @@ impl Panel { · 2 unmodified lines
6061 let token = token();
6162
6263 Self {
64+ state_type: PhantomData,
6365 scroll_state,
6466 current_side: PanelSide::default(),
6567 allowed_sides: PanelAllowedSides::default(),
@@ -99,7 +101,7 @@ impl Panel { · 33 unmodified lines
99101 self
100102 }
101103
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> {
103105 let token = token();
104106 let theme = rose_pine_dawn();
105107
@@ -112,7 +114,7 @@ impl Panel { · 6 unmodified lines
112114 .flex_initial()
113115 .h_full()
114116 // .w(current_width)
115− .w_4()
117+ .w_64()
116118 .fill(theme.middle.base.default.background)
117119 .border_r()
118120 .border_color(theme.middle.base.default.border);
@@ -122,7 +124,7 @@ impl Panel { · 3 unmodified lines
122124 .flex_initial()
123125 .h_full()
124126 // .w(current_width)
125− .w_4()
127+ .w_64()
126128 .fill(theme.middle.base.default.background)
127129 .border_l()
128130 .border_color(theme.middle.base.default.border);
@@ -132,7 +134,7 @@ impl Panel { · 3 unmodified lines
132134 .flex_initial()
133135 .w_full()
134136 // .h(current_width)
135− .h_4()
137+ .h_64()
136138 .fill(theme.middle.base.default.background)
137139 .border_t()
138140 .border_color(theme.middle.base.default.border);
crates/storybook2/src/workspace.rs+45−43
@@ -30,57 +30,59 @@ impl Workspace { · 29 unmodified lines
3030 fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element<State = Self> {
3131 let theme = rose_pine_dawn();
3232
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−
5933 themed(rose_pine_dawn(), cx, |cx| {
6034 div()
6135 .size_full()
62− .flex()
63− .flex_col()
64− .font("Courier")
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))
36+ .v_stack()
37+ .fill(theme.lowest.base.default.background)
38+ .child(Panel::new(ScrollState::default()))
7139 .child(
7240 div()
73− .flex_1()
74− .w_full()
41+ .size_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()
7556 .flex()
76− .flex_row()
77− .overflow_hidden()
78− .child(self.left_panel.clone())
79− .child(div().h_full().flex_1())
80− .child(self.right_panel.clone()),
57+ .fill(theme.middle.negative.default.background),
8158 )
82− .child(statusbar::statusbar(cx))
8359 })
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+ // })
8486 }
8587 }
8688

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