Detailed changes
@@ -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"))
@@ -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.")),
)
}
}
@@ -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()
@@ -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")),
),
)
}
@@ -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"))
@@ -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))),
- )
- }
- }
-}
@@ -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)))
}
@@ -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")))
}
@@ -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"))
@@ -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"))
@@ -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"))
@@ -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(
@@ -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")))
}
@@ -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()