Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Fix IndentGuides story (#32781)
Alex Shi31b7786be7ed
diff --git a/crates/storybook/src/stories.rs b/crates/storybook/src/stories.rsindex b824235b00b..63992d259c7 100644--- a/crates/storybook/src/stories.rs+++ b/crates/storybook/src/stories.rs@@ -1,6 +1,7 @@mod auto_height_editor;mod cursor;mod focus;+mod indent_guides;mod kitchen_sink;mod overflow_scroll;mod picker;@@ -12,6 +13,7 @@ mod with_rem_size;pub use auto_height_editor::*;pub use cursor::*;pub use focus::*;+pub use indent_guides::*;pub use kitchen_sink::*;pub use overflow_scroll::*;pub use picker::*;diff --git a/crates/storybook/src/stories/indent_guides.rs b/crates/storybook/src/stories/indent_guides.rsindex 068890ae50c..e83c9ed3837 100644--- a/crates/storybook/src/stories/indent_guides.rs+++ b/crates/storybook/src/stories/indent_guides.rs@@ -1,13 +1,10 @@-use std::fmt::format;+use std::ops::Range;++use gpui::{Entity, Render, div, uniform_list};+use gpui::{prelude::*, *};+use ui::{AbsoluteLength, Color, DefiniteLength, Label, LabelCommon, px, v_flex};-use gpui::{- DefaultColor, DefaultThemeAppearance, Hsla, Render, colors, div, prelude::*, uniform_list,-};use story::Story;-use strum::IntoEnumIterator;-use ui::{- AbsoluteLength, ActiveTheme, Color, DefiniteLength, Label, LabelCommon, h_flex, px, v_flex,-};const LENGTH: usize = 100;@@ -16,7 +13,7 @@ pub struct IndentGuidesStory {}impl IndentGuidesStory {- pub fn model(window: &mut Window, cx: &mut AppContext) -> Model<Self> {+ pub fn model(_window: &mut Window, cx: &mut App) -> Entity<Self> {let mut depths = Vec::new();depths.push(0);depths.push(1);@@ -33,16 +30,15 @@ impl IndentGuidesStory {}impl Render for IndentGuidesStory {- fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {+ fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {Story::container(cx)- .child(Story::title("Indent guides"))+ .child(Story::title("Indent guides", cx)).child(v_flex().size_full().child(uniform_list(- cx.entity().clone(),"some-list",self.depths.len(),- |this, range, cx| {+ cx.processor(move |this, range: Range<usize>, _window, _cx| {this.depths.iter().enumerate()@@ -56,7 +52,7 @@ impl Render for IndentGuidesStory {.child(Label::new(format!("Item {}", i)).color(Color::Info))}).collect()- },+ }),).with_sizing_behavior(gpui::ListSizingBehavior::Infer).with_decoration(ui::indent_guides(@@ -64,10 +60,10 @@ impl Render for IndentGuidesStory {px(16.),ui::IndentGuideColors {default: Color::Info.color(cx),- hovered: Color::Accent.color(cx),+ hover: Color::Accent.color(cx),active: Color::Accent.color(cx),},- |this, range, cx| {+ |this, range, _cx, _context| {this.depths.iter().skip(range.start)diff --git a/crates/storybook/src/story_selector.rs b/crates/storybook/src/story_selector.rsindex 1de6191367f..fd0be97ff6f 100644--- a/crates/storybook/src/story_selector.rs+++ b/crates/storybook/src/story_selector.rs@@ -31,6 +31,7 @@ pub enum ComponentStory {ToggleButton,ViewportUnits,WithRemSize,+ IndentGuides,}impl ComponentStory {@@ -60,6 +61,7 @@ impl ComponentStory {Self::ToggleButton => cx.new(|_| ui::ToggleButtonStory).into(),Self::ViewportUnits => cx.new(|_| crate::stories::ViewportUnitsStory).into(),Self::WithRemSize => cx.new(|_| crate::stories::WithRemSizeStory).into(),+ Self::IndentGuides => crate::stories::IndentGuidesStory::model(window, cx).into(),}}}diff --git a/crates/storybook/src/storybook.rs b/crates/storybook/src/storybook.rsindex c8b055a67e6..4c5b6272ef1 100644--- a/crates/storybook/src/storybook.rs+++ b/crates/storybook/src/storybook.rs@@ -9,7 +9,9 @@ use std::sync::Arc;use clap::Parser;use dialoguer::FuzzySelect;use gpui::{- AnyView, App, Bounds, Context, Render, Window, WindowBounds, WindowOptions, div, px, size,+ AnyView, App, Bounds, Context, Render, Window, WindowBounds, WindowOptions,+ colors::{Colors, GlobalColors},+ div, px, size,};use log::LevelFilter;use project::Project;@@ -68,6 +70,8 @@ fn main() {gpui::Application::new().with_assets(Assets).run(move |cx| {load_embedded_fonts(cx).unwrap();+ cx.set_global(GlobalColors(Arc::new(Colors::default())));+let http_client = ReqwestClient::user_agent("zed_storybook").unwrap();cx.set_http_client(Arc::new(http_client));diff --git a/crates/ui_input/src/ui_input.rs b/crates/ui_input/src/ui_input.rsindex dfecc08dac2..bd99814cb30 100644--- a/crates/ui_input/src/ui_input.rs+++ b/crates/ui_input/src/ui_input.rs@@ -29,7 +29,7 @@ pub struct SingleLineInput {label: Option<SharedString>,/// The placeholder text for the text field.placeholder: SharedString,- /// Exposes the underlying [`Model<Editor>`] to allow for customizing the editor beyond the provided API.+ /// Exposes the underlying [`Entity<Editor>`] to allow for customizing the editor beyond the provided API.////// This likely will only be public in the short term, ideally the API will be expanded to cover necessary use cases.pub editor: Entity<Editor>,