@@ -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)
@@ -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(),
}
}
}
@@ -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));
@@ -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>,