Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Merge branch 'zed2-render' into zed2

Max Brunsfeld58446c2715c1
diff --cc crates/storybook2/src/stories/colors.rs
index d0f938e57d4,00000000000..afc29660ff5
mode 100644,000000..100644
--- a/crates/storybook2/src/stories/colors.rs
+++ b/crates/storybook2/src/stories/colors.rs
@@@ -1,38 -1,0 +1,38 @@@
- use gpui2::px;
- use ui::prelude::*;
-
+use crate::story::Story;
++use gpui2::{px, Div, Render};
++use ui::prelude::*;
+
- #[derive(Component)]
+pub struct ColorsStory;
+
- impl ColorsStory {
- fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
++impl Render for ColorsStory {
++ type Element = Div<Self>;
++
++ fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
+ let color_scales = theme2::default_color_scales();
+
+ Story::container(cx)
+ .child(Story::title(cx, "Colors"))
+ .child(
+ div()
+ .id("colors")
+ .flex()
+ .flex_col()
+ .gap_1()
+ .overflow_y_scroll()
+ .text_color(gpui2::white())
+ .children(color_scales.into_iter().map(|(name, scale)| {
+ div()
+ .flex()
+ .child(
+ div()
+ .w(px(75.))
+ .line_height(px(24.))
+ .child(name.to_string()),
+ )
+ .child(div().flex().gap_1().children(
+ (1..=12).map(|step| div().flex().size_6().bg(scale.step(cx, step))),
+ ))
+ })),
+ )
+ }
+}
diff --cc crates/storybook2/src/story_selector.rs
index 737f28bda29,997e45ead72..30d31f8cf3b
--- a/crates/storybook2/src/story_selector.rs
+++ b/crates/storybook2/src/story_selector.rs
@@@ -28,19 -27,16 +28,17 @@@ pub enum ElementStory
impl ElementStory {
pub fn story(&self, cx: &mut WindowContext) -> AnyView {
match self {
- Self::Avatar => { cx.build_view(|cx| (), |_, _| ui::AvatarStory.render()) }.into_any(),
- Self::Button => { cx.build_view(|cx| (), |_, _| ui::ButtonStory.render()) }.into_any(),
- Self::Colors => { cx.build_view(|cx| (), |_, _| ColorsStory.render()) }.into_any(),
- Self::Details => {
- { cx.build_view(|cx| (), |_, _| ui::DetailsStory.render()) }.into_any()
- }
++ Self::Colors => cx.build_view(|_| ColorsStory).into_any(),
+ Self::Avatar => cx.build_view(|_| AvatarStory).into_any(),
+ Self::Button => cx.build_view(|_| ButtonStory).into_any(),
+ Self::Details => cx.build_view(|_| DetailsStory).into_any(),
Self::Focus => FocusStory::view(cx).into_any(),
- Self::Icon => { cx.build_view(|cx| (), |_, _| ui::IconStory.render()) }.into_any(),
- Self::Input => { cx.build_view(|cx| (), |_, _| ui::InputStory.render()) }.into_any(),
- Self::Label => { cx.build_view(|cx| (), |_, _| ui::LabelStory.render()) }.into_any(),
+ Self::Icon => cx.build_view(|_| IconStory).into_any(),
+ Self::Input => cx.build_view(|_| InputStory).into_any(),
+ Self::Label => cx.build_view(|_| LabelStory).into_any(),
Self::Scroll => ScrollStory::view(cx).into_any(),
Self::Text => TextStory::view(cx).into_any(),
- Self::ZIndex => { cx.build_view(|cx| (), |_, _| ZIndexStory.render()) }.into_any(),
+ Self::ZIndex => cx.build_view(|_| ZIndexStory).into_any(),
}
}
}