diff --git a/crates/storybook/src/stories.rs b/crates/storybook/src/stories.rs index b824235b00..63992d259c 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.rs index 068890ae50..e83c9ed383 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 { + pub fn model(_window: &mut Window, cx: &mut App) -> Entity { 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) -> impl IntoElement { + fn render(&mut self, _window: &mut Window, cx: &mut Context) -> 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, _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.rs index 1de6191367..fd0be97ff6 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.rs index c8b055a67e..4c5b6272ef 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.rs index dfecc08dac..bd99814cb3 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, /// The placeholder text for the text field. placeholder: SharedString, - /// Exposes the underlying [`Model`] to allow for customizing the editor beyond the provided API. + /// Exposes the underlying [`Entity`] 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,