Return impl IntoElement from Render::render trait

This commit is contained in:
Nathan Sobo 2024-01-02 10:09:05 -07:00
parent 0f33775a91
commit 1b5c8b2b4a
84 changed files with 550 additions and 110 deletions

View file

@ -1,6 +1,6 @@
use editor::Editor;
use gpui::{
div, white, Element, KeyBinding, ParentElement, Render, Styled, View, ViewContext,
div, white, IntoElement, KeyBinding, ParentElement, Render, Styled, View, ViewContext,
VisualContext, WindowContext,
};
@ -22,7 +22,7 @@ impl AutoHeightEditorStory {
}
impl Render for AutoHeightEditorStory {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl Element {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
div()
.size_full()
.bg(white())

View file

@ -5,7 +5,7 @@ use ui::prelude::*;
pub struct CursorStory;
impl Render for CursorStory {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl Element {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
let all_cursors: [(&str, Box<dyn Fn(Stateful<Div>) -> Stateful<Div>>); 19] = [
(
"cursor_default",

View file

@ -56,7 +56,7 @@ impl FocusStory {
}
impl Render for FocusStory {
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> impl Element {
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> impl IntoElement {
let theme = cx.theme();
let color_1 = theme.status().created;
let color_2 = theme.status().modified;

View file

@ -14,7 +14,7 @@ impl KitchenSinkStory {
}
impl Render for KitchenSinkStory {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
let component_stories = ComponentStory::iter()
.map(|selector| selector.story(cx))
.collect::<Vec<_>>();

View file

@ -6,7 +6,7 @@ use ui::prelude::*;
pub struct OverflowScrollStory;
impl Render for OverflowScrollStory {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl Element {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
Story::container()
.child(Story::title("Overflow Scroll"))
.child(Story::label("`overflow_x_scroll`"))

View file

@ -200,7 +200,7 @@ impl PickerStory {
}
impl Render for PickerStory {
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> impl Element {
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> impl IntoElement {
div()
.bg(cx.theme().styles.colors.background)
.size_full()

View file

@ -11,7 +11,7 @@ impl ScrollStory {
}
impl Render for ScrollStory {
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> impl Element {
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> impl IntoElement {
let theme = cx.theme();
let color_1 = theme.status().created;
let color_2 = theme.status().modified;

View file

@ -1,6 +1,6 @@
use gpui::{
div, green, red, Element, HighlightStyle, InteractiveText, IntoElement, ParentElement, Render,
Styled, StyledText, View, VisualContext, WindowContext,
div, green, red, HighlightStyle, InteractiveText, IntoElement, ParentElement, Render, Styled,
StyledText, View, VisualContext, WindowContext,
};
use indoc::indoc;
use story::*;
@ -14,7 +14,7 @@ impl TextStory {
}
impl Render for TextStory {
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> impl Element {
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> impl IntoElement {
StoryContainer::new("Text Story", "crates/storybook2/src/stories/text.rs")
.children(
vec![

View file

@ -6,7 +6,7 @@ use ui::prelude::*;
pub struct ViewportUnitsStory;
impl Render for ViewportUnitsStory {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
Story::container().child(
div()
.flex()

View file

@ -7,7 +7,7 @@ use ui::prelude::*;
pub struct ZIndexStory;
impl Render for ZIndexStory {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl Element {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
Story::container().child(Story::title("z-index")).child(
div()
.flex()

View file

@ -113,7 +113,7 @@ impl StoryWrapper {
}
impl Render for StoryWrapper {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl Element {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
div()
.flex()
.flex_col()