Remove hacky children
This commit is contained in:
parent
24bab48043
commit
d320d3a8bf
6 changed files with 10 additions and 40 deletions
|
@ -82,31 +82,6 @@ pub trait ParentElement {
|
||||||
.extend(iter.into_iter().map(|item| item.into_any()));
|
.extend(iter.into_iter().map(|item| item.into_any()));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
// HACK: This is a temporary hack to get children working for the purposes
|
|
||||||
// of building UI on top of the current version of gpui2.
|
|
||||||
//
|
|
||||||
// We'll (hopefully) be moving away from this in the future.
|
|
||||||
fn children_any<I>(mut self, children: I) -> Self
|
|
||||||
where
|
|
||||||
I: IntoIterator<Item = AnyElement<Self::State>>,
|
|
||||||
Self: Sized,
|
|
||||||
{
|
|
||||||
self.children_mut().extend(children.into_iter());
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
// HACK: This is a temporary hack to get children working for the purposes
|
|
||||||
// of building UI on top of the current version of gpui2.
|
|
||||||
//
|
|
||||||
// We'll (hopefully) be moving away from this in the future.
|
|
||||||
fn child_any(mut self, children: AnyElement<Self::State>) -> Self
|
|
||||||
where
|
|
||||||
Self: Sized,
|
|
||||||
{
|
|
||||||
self.children_mut().push(children);
|
|
||||||
self
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
trait ElementObject<S>: 'static + Send + Sync {
|
trait ElementObject<S>: 'static + Send + Sync {
|
||||||
|
|
|
@ -19,16 +19,20 @@ impl<S: 'static + Send + Sync + Clone> KitchenSinkStory<S> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
|
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
|
||||||
let element_stories = ElementStory::iter().map(|selector| selector.story());
|
let element_stories = ElementStory::iter()
|
||||||
let component_stories = ComponentStory::iter().map(|selector| selector.story(cx)).collect::<Vec<_>>();
|
.map(|selector| selector.story())
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
let component_stories = ComponentStory::iter()
|
||||||
|
.map(|selector| selector.story(cx))
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.overflow_y_scroll(ScrollState::default())
|
.overflow_y_scroll(ScrollState::default())
|
||||||
.child(Story::title(cx, "Kitchen Sink"))
|
.child(Story::title(cx, "Kitchen Sink"))
|
||||||
.child(Story::label(cx, "Elements"))
|
.child(Story::label(cx, "Elements"))
|
||||||
.child(div().flex().flex_col().children_any(element_stories))
|
.child(div().flex().flex_col().children(element_stories))
|
||||||
.child(Story::label(cx, "Components"))
|
.child(Story::label(cx, "Components"))
|
||||||
.child(div().flex().flex_col().children_any(component_stories))
|
.child(div().flex().flex_col().children(component_stories))
|
||||||
// Add a bit of space at the bottom of the kitchen sink so elements
|
// Add a bit of space at the bottom of the kitchen sink so elements
|
||||||
// don't end up squished right up against the bottom of the screen.
|
// don't end up squished right up against the bottom of the screen.
|
||||||
.child(div().p_4())
|
.child(div().p_4())
|
||||||
|
|
|
@ -109,7 +109,7 @@ impl StoryWrapper {
|
||||||
.flex()
|
.flex()
|
||||||
.flex_col()
|
.flex_col()
|
||||||
.size_full()
|
.size_full()
|
||||||
.child_any(self.selector.story(cx))
|
.child(self.selector.story(cx))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
use std::any::Any;
|
|
||||||
|
|
||||||
use gpui3::{AnyElement, ViewContext};
|
|
||||||
|
|
||||||
pub type HackyChildren<S> = fn(&mut ViewContext<S>, &dyn Any) -> Vec<AnyElement<S>>;
|
|
||||||
|
|
||||||
pub type HackyChildrenPayload = Box<dyn Any + Send + Sync>;
|
|
|
@ -1,6 +1,5 @@
|
||||||
#![allow(dead_code, unused_variables)]
|
#![allow(dead_code, unused_variables)]
|
||||||
|
|
||||||
mod children;
|
|
||||||
mod components;
|
mod components;
|
||||||
mod element_ext;
|
mod element_ext;
|
||||||
mod elements;
|
mod elements;
|
||||||
|
@ -8,7 +7,6 @@ pub mod prelude;
|
||||||
mod static_data;
|
mod static_data;
|
||||||
mod theme;
|
mod theme;
|
||||||
|
|
||||||
pub use children::*;
|
|
||||||
pub use components::*;
|
pub use components::*;
|
||||||
pub use element_ext::*;
|
pub use element_ext::*;
|
||||||
pub use elements::*;
|
pub use elements::*;
|
||||||
|
|
|
@ -3,7 +3,7 @@ pub use gpui3::{
|
||||||
WindowContext,
|
WindowContext,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use crate::{theme, ButtonVariant, ElementExt, HackyChildren, HackyChildrenPayload, Theme};
|
pub use crate::{theme, ButtonVariant, ElementExt, Theme};
|
||||||
|
|
||||||
use gpui3::{hsla, rems, rgb, AbsoluteLength, Hsla};
|
use gpui3::{hsla, rems, rgb, AbsoluteLength, Hsla};
|
||||||
use strum::EnumIter;
|
use strum::EnumIter;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue