Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Fix stories
Mikaylaa844bf7d41f5
diff --git a/crates/ui2/src/components/avatar.rs b/crates/ui2/src/components/avatar.rsindex 2c2679c39a3..ab79352f86e 100644--- a/crates/ui2/src/components/avatar.rs+++ b/crates/ui2/src/components/avatar.rs@@ -54,7 +54,7 @@ mod stories {impl Render for AvatarStory {type Element = Div;- fn render(&mut self, cx: &mut WindowContext) -> Self::Element {+ fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {Story::container(cx).child(Story::title_for::<Avatar>(cx)).child(Story::label(cx, "Default"))diff --git a/crates/ui2/src/components/button.rs b/crates/ui2/src/components/button.rsindex c70c6981fa0..3d92cebec55 100644--- a/crates/ui2/src/components/button.rs+++ b/crates/ui2/src/components/button.rs@@ -251,7 +251,7 @@ mod stories {let states = InteractionState::iter();Story::container(cx)- .child(Story::title_for::<_, Button>(cx))+ .child(Story::title_for::<Button>(cx)).child(div().flex()@@ -394,7 +394,7 @@ mod stories {.child(Button::new("Label").variant(ButtonVariant::Ghost)- .on_click(cx.callback(|_view, _, cx| println!("Button clicked."))),+ .on_click(|_, cx| println!("Button clicked.")),)}}diff --git a/crates/ui2/src/components/checkbox.rs b/crates/ui2/src/components/checkbox.rsindex 276ee3a795d..f8f54df69f9 100644--- a/crates/ui2/src/components/checkbox.rs+++ b/crates/ui2/src/components/checkbox.rs@@ -291,7 +291,7 @@ pub use stories::*;mod stories {use super::*;use crate::{h_stack, Story};- use gpui::{Div, Render};+ use gpui::{Div, Render, ViewContext};pub struct CheckboxStory;@@ -300,7 +300,7 @@ mod stories {fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {Story::container(cx)- .child(Story::title_for::<_, Checkbox<Self>>(cx))+ .child(Story::title_for::<Checkbox>(cx)).child(Story::label(cx, "Default")).child(h_stack()diff --git a/crates/ui2/src/components/context_menu.rs b/crates/ui2/src/components/context_menu.rsindex f0424f0cf71..a6750be6074 100644--- a/crates/ui2/src/components/context_menu.rs+++ b/crates/ui2/src/components/context_menu.rs@@ -309,10 +309,7 @@ mod stories {actions!(PrintCurrentDate, PrintBestFood);- fn build_menu<V: Render>(- cx: &mut WindowContext,- header: impl Into<SharedString>,- ) -> View<ContextMenu> {+ fn build_menu(cx: &mut WindowContext, header: impl Into<SharedString>) -> View<ContextMenu> {ContextMenu::build(cx, |menu, _| {menu.header(header).separator()@@ -337,13 +334,13 @@ mod stories {fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {Story::container(cx)- .on_action(|_, _: &PrintCurrentDate, _| {+ .on_action(|_: &PrintCurrentDate, _| {println!("printing unix time!");if let Ok(unix_time) = std::time::UNIX_EPOCH.elapsed() {println!("Current Unix time is {:?}", unix_time.as_secs());}})- .on_action(|_, _: &PrintBestFood, _| {+ .on_action(|_: &PrintBestFood, _| {println!("burrito");}).flex()@@ -363,7 +360,7 @@ mod stories {"RIGHT CLICK ME"})})- .menu(move |_, cx| build_menu(cx, "top left")),+ .menu(move |cx| build_menu(cx, "top left")),).child(menu_handle("test1")@@ -376,7 +373,7 @@ mod stories {}).anchor(AnchorCorner::BottomLeft).attach(AnchorCorner::TopLeft)- .menu(move |_, cx| build_menu(cx, "bottom left")),+ .menu(move |cx| build_menu(cx, "bottom left")),),).child(@@ -394,7 +391,7 @@ mod stories {})}).anchor(AnchorCorner::TopRight)- .menu(move |_, cx| build_menu(cx, "top right")),+ .menu(move |cx| build_menu(cx, "top right")),).child(menu_handle("test4")@@ -407,7 +404,7 @@ mod stories {}).anchor(AnchorCorner::BottomRight).attach(AnchorCorner::TopRight)- .menu(move |_, cx| build_menu(cx, "bottom right")),+ .menu(move |cx| build_menu(cx, "bottom right")),),)}diff --git a/crates/ui2/src/components/details.rs b/crates/ui2/src/components/details.rsindex 66aa586a778..fbdf34389de 100644--- a/crates/ui2/src/components/details.rs+++ b/crates/ui2/src/components/details.rs@@ -61,7 +61,7 @@ mod stories {fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {Story::container(cx)- .child(Story::title_for::<_, Details<Self>>(cx))+ .child(Story::title_for::<Details>(cx)).child(Story::label(cx, "Default")).child(Details::new("The quick brown fox jumps over the lazy dog")).child(Story::label(cx, "With meta"))diff --git a/crates/ui2/src/components/facepile.rs b/crates/ui2/src/components/facepile.rsindex 92854e01ce9..55619440496 100644--- a/crates/ui2/src/components/facepile.rs+++ b/crates/ui2/src/components/facepile.rs@@ -31,34 +31,3 @@ impl Facepile {}use gpui::{Div, RenderOnce};-#[cfg(feature = "stories")]-pub use stories::*;--#[cfg(feature = "stories")]-mod stories {- use super::*;- use crate::{static_players, Story};- use gpui::{Div, Render};-- pub struct FacepileStory;-- impl Render for FacepileStory {- type Element = Div;-- fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {- let players = static_players();-- Story::container(cx)- .child(Story::title_for::<_, Facepile>(cx))- .child(Story::label(cx, "Default"))- .child(- div()- .flex()- .gap_3()- .child(Facepile::new(players.clone().into_iter().take(1)))- .child(Facepile::new(players.clone().into_iter().take(2)))- .child(Facepile::new(players.clone().into_iter().take(3))),- )- }- }-}diff --git a/crates/ui2/src/components/icon.rs b/crates/ui2/src/components/icon.rsindex b40f5436b37..7e1e87d65d6 100644--- a/crates/ui2/src/components/icon.rs+++ b/crates/ui2/src/components/icon.rs@@ -215,7 +215,7 @@ mod stories {let icons = Icon::iter();Story::container(cx)- .child(Story::title_for::<_, IconElement>(cx))+ .child(Story::title_for::<IconElement>(cx)).child(Story::label(cx, "All Icons")).child(div().flex().gap_3().children(icons.map(IconElement::new)))}diff --git a/crates/ui2/src/components/input.rs b/crates/ui2/src/components/input.rsindex 3a72b9e3cc2..ceaacde18f8 100644--- a/crates/ui2/src/components/input.rs+++ b/crates/ui2/src/components/input.rs@@ -123,7 +123,7 @@ mod stories {fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {Story::container(cx)- .child(Story::title_for::<_, Input>(cx))+ .child(Story::title_for::<Input>(cx)).child(Story::label(cx, "Default")).child(div().flex().child(Input::new("Search")))}diff --git a/crates/ui2/src/components/keybinding.rs b/crates/ui2/src/components/keybinding.rsindex ffd7094c3ca..e5faaac6404 100644--- a/crates/ui2/src/components/keybinding.rs+++ b/crates/ui2/src/components/keybinding.rs@@ -96,7 +96,7 @@ mod stories {["ctrl", "alt", "cmd", "shift"].into_iter().permutations(2);Story::container(cx)- .child(Story::title_for::<_, KeyBinding>(cx))+ .child(Story::title_for::<KeyBinding>(cx)).child(Story::label(cx, "Single Key")).child(KeyBinding::new(binding("Z"))).child(Story::label(cx, "Single Key with Modifier"))diff --git a/crates/ui2/src/components/label.rs b/crates/ui2/src/components/label.rsindex 6f343191e5b..65e25715ee5 100644--- a/crates/ui2/src/components/label.rs+++ b/crates/ui2/src/components/label.rs@@ -247,7 +247,7 @@ mod stories {fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {Story::container(cx)- .child(Story::title_for::<_, Label>(cx))+ .child(Story::title_for::<Label>(cx)).child(Story::label(cx, "Default")).child(Label::new("Hello, world!")).child(Story::label(cx, "Highlighted"))diff --git a/crates/ui2/src/components/palette.rs b/crates/ui2/src/components/palette.rsindex 504c4926565..c154215dfe1 100644--- a/crates/ui2/src/components/palette.rs+++ b/crates/ui2/src/components/palette.rs@@ -178,7 +178,7 @@ mod stories {fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {{Story::container(cx)- .child(Story::title_for::<_, Palette>(cx))+ .child(Story::title_for::<Palette>(cx)).child(Story::label(cx, "Default")).child(Palette::new("palette-1")).child(Story::label(cx, "With Items"))diff --git a/crates/ui2/src/components/panel.rs b/crates/ui2/src/components/panel.rsindex 4918d0df95f..12a40c78d0f 100644--- a/crates/ui2/src/components/panel.rs+++ b/crates/ui2/src/components/panel.rs@@ -137,7 +137,7 @@ mod stories {fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {Story::container(cx)- .child(Story::title_for::<Panel<Self>>(cx))+ .child(Story::title_for::<Panel>(cx)).child(Story::label(cx, "Default")).child(Panel::new("panel", cx).child(diff --git a/crates/ui2/src/components/toast.rs b/crates/ui2/src/components/toast.rsindex 1af64eea6de..cdf29e8c1be 100644--- a/crates/ui2/src/components/toast.rs+++ b/crates/ui2/src/components/toast.rs@@ -109,7 +109,7 @@ mod stories {fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {Story::container(cx)- .child(Story::title_for::<Toast<Self>>(cx))+ .child(Story::title_for::<Toast>(cx)).child(Story::label(cx, "Default")).child(Toast::new(ToastOrigin::Bottom).child(Label::new("label")))}diff --git a/crates/ui2/src/story.rs b/crates/ui2/src/story.rsindex a8f6a12402e..fc8c42eff74 100644--- a/crates/ui2/src/story.rs+++ b/crates/ui2/src/story.rs@@ -15,10 +15,7 @@ impl Story {.bg(cx.theme().colors().background)}- pub fn title<V: 'static>(- cx: &mut WindowContext,- title: impl Into<SharedString>,- ) -> impl Element {+ pub fn title(cx: &mut WindowContext, title: impl Into<SharedString>) -> impl Element {div().text_xl().text_color(cx.theme().colors().text)@@ -29,10 +26,7 @@ impl Story {Self::title(cx, std::any::type_name::<T>())}- pub fn label<V: 'static>(- cx: &mut WindowContext,- label: impl Into<SharedString>,- ) -> impl Element {+ pub fn label(cx: &mut WindowContext, label: impl Into<SharedString>) -> impl Element {div().mt_4().mb_2()