Rename IntoAnyElement trait to Component
This commit is contained in:
parent
8ecfea55cd
commit
0285284ae1
60 changed files with 297 additions and 300 deletions
|
@ -46,20 +46,20 @@ pub struct GlobalElementId(SmallVec<[ElementId; 32]>);
|
|||
pub trait ParentElement<V: 'static> {
|
||||
fn children_mut(&mut self) -> &mut SmallVec<[AnyElement<V>; 2]>;
|
||||
|
||||
fn child(mut self, child: impl IntoAnyElement<V>) -> Self
|
||||
fn child(mut self, child: impl Component<V>) -> Self
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
self.children_mut().push(child.into_any());
|
||||
self.children_mut().push(child.render());
|
||||
self
|
||||
}
|
||||
|
||||
fn children(mut self, iter: impl IntoIterator<Item = impl IntoAnyElement<V>>) -> Self
|
||||
fn children(mut self, iter: impl IntoIterator<Item = impl Component<V>>) -> Self
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
self.children_mut()
|
||||
.extend(iter.into_iter().map(|item| item.into_any()));
|
||||
.extend(iter.into_iter().map(|item| item.render()));
|
||||
self
|
||||
}
|
||||
}
|
||||
|
@ -207,8 +207,8 @@ impl<V> AnyElement<V> {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait IntoAnyElement<V> {
|
||||
fn into_any(self) -> AnyElement<V>;
|
||||
pub trait Component<V> {
|
||||
fn render(self) -> AnyElement<V>;
|
||||
|
||||
fn when(mut self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self
|
||||
where
|
||||
|
@ -221,8 +221,8 @@ pub trait IntoAnyElement<V> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<V> IntoAnyElement<V> for AnyElement<V> {
|
||||
fn into_any(self) -> AnyElement<V> {
|
||||
impl<V> Component<V> for AnyElement<V> {
|
||||
fn render(self) -> AnyElement<V> {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ impl<V> IntoAnyElement<V> for AnyElement<V> {
|
|||
impl<V, E, F> Element<V> for Option<F>
|
||||
where
|
||||
V: 'static,
|
||||
E: 'static + IntoAnyElement<V> + Send + Sync,
|
||||
E: 'static + Component<V> + Send + Sync,
|
||||
F: FnOnce(&mut V, &mut ViewContext<'_, '_, V>) -> E + Send + Sync + 'static,
|
||||
{
|
||||
type ElementState = AnyElement<V>;
|
||||
|
@ -246,7 +246,7 @@ where
|
|||
cx: &mut ViewContext<V>,
|
||||
) -> Self::ElementState {
|
||||
let render = self.take().unwrap();
|
||||
(render)(view_state, cx).into_any()
|
||||
(render)(view_state, cx).render()
|
||||
}
|
||||
|
||||
fn layout(
|
||||
|
@ -269,24 +269,24 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl<V, E, F> IntoAnyElement<V> for Option<F>
|
||||
impl<V, E, F> Component<V> for Option<F>
|
||||
where
|
||||
V: 'static,
|
||||
E: 'static + IntoAnyElement<V> + Send + Sync,
|
||||
E: 'static + Component<V> + Send + Sync,
|
||||
F: FnOnce(&mut V, &mut ViewContext<'_, '_, V>) -> E + Send + Sync + 'static,
|
||||
{
|
||||
fn into_any(self) -> AnyElement<V> {
|
||||
fn render(self) -> AnyElement<V> {
|
||||
AnyElement::new(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<V, E, F> IntoAnyElement<V> for F
|
||||
impl<V, E, F> Component<V> for F
|
||||
where
|
||||
V: 'static,
|
||||
E: 'static + IntoAnyElement<V> + Send + Sync,
|
||||
E: 'static + Component<V> + Send + Sync,
|
||||
F: FnOnce(&mut V, &mut ViewContext<'_, '_, V>) -> E + Send + Sync + 'static,
|
||||
{
|
||||
fn into_any(self) -> AnyElement<V> {
|
||||
fn render(self) -> AnyElement<V> {
|
||||
AnyElement::new(Some(self))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::{
|
||||
point, AnyElement, BorrowWindow, Bounds, Element, ElementFocus, ElementId, ElementInteraction,
|
||||
FocusDisabled, FocusEnabled, FocusHandle, FocusListeners, Focusable, GlobalElementId,
|
||||
GroupBounds, InteractiveElementState, IntoAnyElement, LayoutId, Overflow, ParentElement,
|
||||
point, AnyElement, BorrowWindow, Bounds, Component, Element, ElementFocus, ElementId,
|
||||
ElementInteraction, FocusDisabled, FocusEnabled, FocusHandle, FocusListeners, Focusable,
|
||||
GlobalElementId, GroupBounds, InteractiveElementState, LayoutId, Overflow, ParentElement,
|
||||
Pixels, Point, SharedString, StatefulInteraction, StatefulInteractive, StatelessInteraction,
|
||||
StatelessInteractive, Style, StyleRefinement, Styled, ViewContext,
|
||||
};
|
||||
|
@ -303,13 +303,13 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl<V, I, F> IntoAnyElement<V> for Div<V, I, F>
|
||||
impl<V, I, F> Component<V> for Div<V, I, F>
|
||||
where
|
||||
// V: Any + Send + Sync,
|
||||
I: ElementInteraction<V>,
|
||||
F: ElementFocus<V>,
|
||||
{
|
||||
fn into_any(self) -> AnyElement<V> {
|
||||
fn render(self) -> AnyElement<V> {
|
||||
AnyElement::new(self)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{
|
||||
div, AnyElement, BorrowWindow, Bounds, Div, DivState, Element, ElementFocus, ElementId,
|
||||
ElementInteraction, FocusDisabled, FocusEnabled, FocusListeners, Focusable, IntoAnyElement,
|
||||
div, AnyElement, BorrowWindow, Bounds, Component, Div, DivState, Element, ElementFocus,
|
||||
ElementId, ElementInteraction, FocusDisabled, FocusEnabled, FocusListeners, Focusable,
|
||||
LayoutId, Pixels, SharedString, StatefulInteraction, StatefulInteractive, StatelessInteraction,
|
||||
StatelessInteractive, StyleRefinement, Styled, ViewContext,
|
||||
};
|
||||
|
@ -55,12 +55,12 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl<V, I, F> IntoAnyElement<V> for Img<V, I, F>
|
||||
impl<V, I, F> Component<V> for Img<V, I, F>
|
||||
where
|
||||
I: ElementInteraction<V>,
|
||||
F: ElementFocus<V>,
|
||||
{
|
||||
fn into_any(self) -> AnyElement<V> {
|
||||
fn render(self) -> AnyElement<V> {
|
||||
AnyElement::new(self)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{
|
||||
div, AnyElement, Bounds, Div, DivState, Element, ElementFocus, ElementId, ElementInteraction,
|
||||
FocusDisabled, FocusEnabled, FocusListeners, Focusable, IntoAnyElement, LayoutId, Pixels,
|
||||
div, AnyElement, Bounds, Component, Div, DivState, Element, ElementFocus, ElementId,
|
||||
ElementInteraction, FocusDisabled, FocusEnabled, FocusListeners, Focusable, LayoutId, Pixels,
|
||||
SharedString, StatefulInteraction, StatefulInteractive, StatelessInteraction,
|
||||
StatelessInteractive, StyleRefinement, Styled, ViewContext,
|
||||
};
|
||||
|
@ -45,12 +45,12 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl<V, I, F> IntoAnyElement<V> for Svg<V, I, F>
|
||||
impl<V, I, F> Component<V> for Svg<V, I, F>
|
||||
where
|
||||
I: ElementInteraction<V>,
|
||||
F: ElementFocus<V>,
|
||||
{
|
||||
fn into_any(self) -> AnyElement<V> {
|
||||
fn render(self) -> AnyElement<V> {
|
||||
AnyElement::new(self)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,41 +1,41 @@
|
|||
use crate::{
|
||||
AnyElement, BorrowWindow, Bounds, Element, IntoAnyElement, LayoutId, Line, Pixels,
|
||||
SharedString, Size, ViewContext,
|
||||
AnyElement, BorrowWindow, Bounds, Component, Element, LayoutId, Line, Pixels, SharedString,
|
||||
Size, ViewContext,
|
||||
};
|
||||
use parking_lot::Mutex;
|
||||
use smallvec::SmallVec;
|
||||
use std::{marker::PhantomData, sync::Arc};
|
||||
use util::ResultExt;
|
||||
|
||||
impl<V: 'static> IntoAnyElement<V> for SharedString {
|
||||
fn into_any(self) -> AnyElement<V> {
|
||||
impl<V: 'static> Component<V> for SharedString {
|
||||
fn render(self) -> AnyElement<V> {
|
||||
Text {
|
||||
text: self,
|
||||
state_type: PhantomData,
|
||||
}
|
||||
.into_any()
|
||||
.render()
|
||||
}
|
||||
}
|
||||
|
||||
impl<V: 'static> IntoAnyElement<V> for &'static str {
|
||||
fn into_any(self) -> AnyElement<V> {
|
||||
impl<V: 'static> Component<V> for &'static str {
|
||||
fn render(self) -> AnyElement<V> {
|
||||
Text {
|
||||
text: self.into(),
|
||||
state_type: PhantomData,
|
||||
}
|
||||
.into_any()
|
||||
.render()
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Figure out how to pass `String` to `child` without this.
|
||||
// This impl doesn't exist in the `gpui2` crate.
|
||||
impl<V: 'static> IntoAnyElement<V> for String {
|
||||
fn into_any(self) -> AnyElement<V> {
|
||||
impl<V: 'static> Component<V> for String {
|
||||
fn render(self) -> AnyElement<V> {
|
||||
Text {
|
||||
text: self.into(),
|
||||
state_type: PhantomData,
|
||||
}
|
||||
.into_any()
|
||||
.render()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,8 +47,8 @@ pub struct Text<V> {
|
|||
unsafe impl<V> Send for Text<V> {}
|
||||
unsafe impl<V> Sync for Text<V> {}
|
||||
|
||||
impl<V: 'static> IntoAnyElement<V> for Text<V> {
|
||||
fn into_any(self) -> AnyElement<V> {
|
||||
impl<V: 'static> Component<V> for Text<V> {
|
||||
fn render(self) -> AnyElement<V> {
|
||||
AnyElement::new(self)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::{
|
||||
point, px, view, Action, AnyBox, AnyDrag, AppContext, BorrowWindow, Bounds, DispatchContext,
|
||||
DispatchPhase, Element, ElementId, FocusHandle, IntoAnyElement, KeyMatch, Keystroke, Modifiers,
|
||||
Overflow, Pixels, Point, SharedString, Size, Style, StyleRefinement, ViewContext,
|
||||
point, px, view, Action, AnyBox, AnyDrag, AppContext, BorrowWindow, Bounds, Component,
|
||||
DispatchContext, DispatchPhase, Element, ElementId, FocusHandle, KeyMatch, Keystroke,
|
||||
Modifiers, Overflow, Pixels, Point, SharedString, Size, Style, StyleRefinement, ViewContext,
|
||||
};
|
||||
use collections::HashMap;
|
||||
use derive_more::{Deref, DerefMut};
|
||||
|
@ -327,7 +327,7 @@ pub trait StatefulInteractive<V: 'static>: StatelessInteractive<V> {
|
|||
S: Any + Send + Sync,
|
||||
R: Fn(&mut V, &mut ViewContext<V>) -> E,
|
||||
R: 'static + Send + Sync,
|
||||
E: IntoAnyElement<V>,
|
||||
E: Component<V>,
|
||||
{
|
||||
debug_assert!(
|
||||
self.stateful_interaction().drag_listener.is_none(),
|
||||
|
@ -871,7 +871,7 @@ pub struct Drag<S, R, V, E>
|
|||
where
|
||||
R: Fn(&mut V, &mut ViewContext<V>) -> E,
|
||||
V: 'static,
|
||||
E: IntoAnyElement<V>,
|
||||
E: Component<V>,
|
||||
{
|
||||
pub state: S,
|
||||
pub render_drag_handle: R,
|
||||
|
@ -882,7 +882,7 @@ impl<S, R, V, E> Drag<S, R, V, E>
|
|||
where
|
||||
R: Fn(&mut V, &mut ViewContext<V>) -> E,
|
||||
V: 'static,
|
||||
E: IntoAnyElement<V>,
|
||||
E: Component<V>,
|
||||
{
|
||||
pub fn new(state: S, render_drag_handle: R) -> Self {
|
||||
Drag {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use parking_lot::Mutex;
|
||||
|
||||
use crate::{
|
||||
AnyBox, AnyElement, BorrowWindow, Bounds, Element, ElementId, EntityId, Handle, IntoAnyElement,
|
||||
AnyBox, AnyElement, BorrowWindow, Bounds, Component, Element, ElementId, EntityId, Handle,
|
||||
LayoutId, Pixels, ViewContext, WindowContext,
|
||||
};
|
||||
use std::{marker::PhantomData, sync::Arc};
|
||||
|
@ -33,16 +33,16 @@ pub fn view<V, E>(
|
|||
render: impl Fn(&mut V, &mut ViewContext<V>) -> E + Send + Sync + 'static,
|
||||
) -> View<V>
|
||||
where
|
||||
E: IntoAnyElement<V>,
|
||||
E: Component<V>,
|
||||
{
|
||||
View {
|
||||
state,
|
||||
render: Arc::new(move |state, cx| render(state, cx).into_any()),
|
||||
render: Arc::new(move |state, cx| render(state, cx).render()),
|
||||
}
|
||||
}
|
||||
|
||||
impl<V: 'static, ParentViewState: 'static> IntoAnyElement<ParentViewState> for View<V> {
|
||||
fn into_any(self) -> AnyElement<ParentViewState> {
|
||||
impl<V: 'static, ParentViewState: 'static> Component<ParentViewState> for View<V> {
|
||||
fn render(self) -> AnyElement<ParentViewState> {
|
||||
AnyElement::new(EraseViewState {
|
||||
view: self,
|
||||
parent_view_state_type: PhantomData,
|
||||
|
@ -98,8 +98,8 @@ struct EraseViewState<V, ParentV> {
|
|||
unsafe impl<V, ParentV> Send for EraseViewState<V, ParentV> {}
|
||||
unsafe impl<V, ParentV> Sync for EraseViewState<V, ParentV> {}
|
||||
|
||||
impl<V: 'static, ParentV: 'static> IntoAnyElement<ParentV> for EraseViewState<V, ParentV> {
|
||||
fn into_any(self) -> AnyElement<ParentV> {
|
||||
impl<V: 'static, ParentV: 'static> Component<ParentV> for EraseViewState<V, ParentV> {
|
||||
fn render(self) -> AnyElement<ParentV> {
|
||||
AnyElement::new(self)
|
||||
}
|
||||
}
|
||||
|
@ -185,8 +185,8 @@ pub struct AnyView {
|
|||
view: Arc<Mutex<dyn ViewObject>>,
|
||||
}
|
||||
|
||||
impl<ParentV: 'static> IntoAnyElement<ParentV> for AnyView {
|
||||
fn into_any(self) -> AnyElement<ParentV> {
|
||||
impl<ParentV: 'static> Component<ParentV> for AnyView {
|
||||
fn render(self) -> AnyElement<ParentV> {
|
||||
AnyElement::new(EraseAnyViewState {
|
||||
view: self,
|
||||
parent_view_state_type: PhantomData,
|
||||
|
@ -238,8 +238,8 @@ struct EraseAnyViewState<ParentViewState> {
|
|||
unsafe impl<ParentV> Send for EraseAnyViewState<ParentV> {}
|
||||
unsafe impl<ParentV> Sync for EraseAnyViewState<ParentV> {}
|
||||
|
||||
impl<ParentV: 'static> IntoAnyElement<ParentV> for EraseAnyViewState<ParentV> {
|
||||
fn into_any(self) -> AnyElement<ParentV> {
|
||||
impl<ParentV: 'static> Component<ParentV> for EraseAnyViewState<ParentV> {
|
||||
fn render(self) -> AnyElement<ParentV> {
|
||||
AnyElement::new(self)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ use proc_macro::TokenStream;
|
|||
use quote::quote;
|
||||
use syn::{parse_macro_input, DeriveInput};
|
||||
|
||||
pub fn derive_into_any_element(input: TokenStream) -> TokenStream {
|
||||
pub fn derive_component(input: TokenStream) -> TokenStream {
|
||||
let ast = parse_macro_input!(input as DeriveInput);
|
||||
let name = &ast.ident;
|
||||
let generics = &ast.generics;
|
||||
|
@ -11,7 +11,7 @@ pub fn derive_into_any_element(input: TokenStream) -> TokenStream {
|
|||
let specified_view_type = ast
|
||||
.attrs
|
||||
.iter()
|
||||
.find(|attr| attr.path.is_ident("element"))
|
||||
.find(|attr| attr.path.is_ident("component"))
|
||||
.and_then(|attr| {
|
||||
if let Ok(syn::Meta::List(meta_list)) = attr.parse_meta() {
|
||||
meta_list.nested.iter().find_map(|nested| {
|
||||
|
@ -42,10 +42,10 @@ pub fn derive_into_any_element(input: TokenStream) -> TokenStream {
|
|||
});
|
||||
|
||||
let expanded = quote! {
|
||||
impl #impl_generics gpui2::IntoAnyElement<#view_type> for #name #ty_generics #where_clause {
|
||||
fn into_any(self) -> gpui2::AnyElement<#view_type> {
|
||||
impl #impl_generics gpui2::Component<#view_type> for #name #ty_generics #where_clause {
|
||||
fn render(self) -> gpui2::AnyElement<#view_type> {
|
||||
(move |view_state: &mut #view_type, cx: &mut gpui2::ViewContext<'_, '_, #view_type>| self.render(view_state, cx))
|
||||
.into_any()
|
||||
.render()
|
||||
}
|
||||
}
|
||||
};
|
|
@ -1,6 +1,6 @@
|
|||
use proc_macro::TokenStream;
|
||||
|
||||
mod derive_into_any_element;
|
||||
mod derive_component;
|
||||
mod style_helpers;
|
||||
mod test;
|
||||
|
||||
|
@ -9,9 +9,9 @@ pub fn style_helpers(args: TokenStream) -> TokenStream {
|
|||
style_helpers::style_helpers(args)
|
||||
}
|
||||
|
||||
#[proc_macro_derive(IntoAnyElement, attributes(element))]
|
||||
pub fn derive_into_any_element(input: TokenStream) -> TokenStream {
|
||||
derive_into_any_element::derive_into_any_element(input)
|
||||
#[proc_macro_derive(Component, attributes(component))]
|
||||
pub fn derive_component(input: TokenStream) -> TokenStream {
|
||||
derive_component::derive_component(input)
|
||||
}
|
||||
|
||||
#[proc_macro_attribute]
|
||||
|
|
|
@ -14,7 +14,7 @@ impl<V, D> Default for ButtonHandlers<V, D> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct Button<V: 'static, D: 'static> {
|
||||
handlers: ButtonHandlers<V, D>,
|
||||
label: Option<ArcCow<'static, str>>,
|
||||
|
|
|
@ -16,7 +16,7 @@ impl KitchenSinkStory {
|
|||
view(cx.entity(|cx| Self::new()), Self::render)
|
||||
}
|
||||
|
||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoAnyElement<Self> {
|
||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Component<Self> {
|
||||
let element_stories = ElementStory::iter()
|
||||
.map(|selector| selector.story(cx))
|
||||
.collect::<Vec<_>>();
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
use crate::themes::rose_pine;
|
||||
use gpui2::{
|
||||
div, px, view, Context, IntoAnyElement, ParentElement, SharedString, Styled, View,
|
||||
WindowContext,
|
||||
div, px, view, Component, Context, ParentElement, SharedString, Styled, View, WindowContext,
|
||||
};
|
||||
|
||||
pub struct ScrollStory {
|
||||
|
@ -16,7 +15,7 @@ impl ScrollStory {
|
|||
}
|
||||
}
|
||||
|
||||
fn checkerboard<S>(depth: usize) -> impl IntoAnyElement<S>
|
||||
fn checkerboard<S>(depth: usize) -> impl Component<S>
|
||||
where
|
||||
S: 'static + Send + Sync,
|
||||
{
|
||||
|
|
|
@ -7,7 +7,7 @@ use crate::story::Story;
|
|||
|
||||
/// A reimplementation of the MDN `z-index` example, found here:
|
||||
/// [https://developer.mozilla.org/en-US/docs/Web/CSS/z-index](https://developer.mozilla.org/en-US/docs/Web/CSS/z-index).
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct ZIndexStory<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ impl<S: 'static + Send + Sync> ZIndexStory<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
Story::container(cx)
|
||||
.child(Story::title(cx, "z-index"))
|
||||
.child(
|
||||
|
@ -88,7 +88,7 @@ trait Styles: Styled + Sized {
|
|||
|
||||
impl<V: 'static + Send + Sync> Styles for Div<V> {}
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
struct ZIndexExample<V: 'static + Send + Sync> {
|
||||
view_type: PhantomData<V>,
|
||||
z_index: u32,
|
||||
|
@ -102,7 +102,7 @@ impl<V: 'static + Send + Sync> ZIndexExample<V> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl IntoAnyElement<V> {
|
||||
fn render(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
div()
|
||||
.relative()
|
||||
.size_full()
|
||||
|
|
|
@ -28,29 +28,29 @@ impl ElementStory {
|
|||
pub fn story(&self, cx: &mut WindowContext) -> AnyView {
|
||||
match self {
|
||||
Self::Avatar => {
|
||||
view(cx.entity(|cx| ()), |_, _| ui::AvatarStory::new().into_any()).into_any()
|
||||
view(cx.entity(|cx| ()), |_, _| ui::AvatarStory::new().render()).into_any()
|
||||
}
|
||||
Self::Button => {
|
||||
view(cx.entity(|cx| ()), |_, _| ui::ButtonStory::new().into_any()).into_any()
|
||||
view(cx.entity(|cx| ()), |_, _| ui::ButtonStory::new().render()).into_any()
|
||||
}
|
||||
Self::Details => view(cx.entity(|cx| ()), |_, _| {
|
||||
ui::DetailsStory::new().into_any()
|
||||
ui::DetailsStory::new().render()
|
||||
})
|
||||
.into_any(),
|
||||
Self::Focus => FocusStory::view(cx).into_any(),
|
||||
Self::Icon => {
|
||||
view(cx.entity(|cx| ()), |_, _| ui::IconStory::new().into_any()).into_any()
|
||||
view(cx.entity(|cx| ()), |_, _| ui::IconStory::new().render()).into_any()
|
||||
}
|
||||
Self::Input => {
|
||||
view(cx.entity(|cx| ()), |_, _| ui::InputStory::new().into_any()).into_any()
|
||||
view(cx.entity(|cx| ()), |_, _| ui::InputStory::new().render()).into_any()
|
||||
}
|
||||
Self::Label => {
|
||||
view(cx.entity(|cx| ()), |_, _| ui::LabelStory::new().into_any()).into_any()
|
||||
view(cx.entity(|cx| ()), |_, _| ui::LabelStory::new().render()).into_any()
|
||||
}
|
||||
Self::Scroll => ScrollStory::view(cx).into_any(),
|
||||
Self::Text => TextStory::view(cx).into_any(),
|
||||
Self::ZIndex => {
|
||||
view(cx.entity(|cx| ()), |_, _| ZIndexStory::new().into_any()).into_any()
|
||||
view(cx.entity(|cx| ()), |_, _| ZIndexStory::new().render()).into_any()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -91,93 +91,93 @@ impl ComponentStory {
|
|||
pub fn story(&self, cx: &mut WindowContext) -> AnyView {
|
||||
match self {
|
||||
Self::AssistantPanel => view(cx.entity(|cx| ()), |_, _| {
|
||||
ui::AssistantPanelStory::new().into_any()
|
||||
ui::AssistantPanelStory::new().render()
|
||||
})
|
||||
.into_any(),
|
||||
Self::Buffer => {
|
||||
view(cx.entity(|cx| ()), |_, _| ui::BufferStory::new().into_any()).into_any()
|
||||
view(cx.entity(|cx| ()), |_, _| ui::BufferStory::new().render()).into_any()
|
||||
}
|
||||
Self::Breadcrumb => view(cx.entity(|cx| ()), |_, _| {
|
||||
ui::BreadcrumbStory::new().into_any()
|
||||
ui::BreadcrumbStory::new().render()
|
||||
})
|
||||
.into_any(),
|
||||
Self::ChatPanel => view(cx.entity(|cx| ()), |_, _| {
|
||||
ui::ChatPanelStory::new().into_any()
|
||||
ui::ChatPanelStory::new().render()
|
||||
})
|
||||
.into_any(),
|
||||
Self::CollabPanel => view(cx.entity(|cx| ()), |_, _| {
|
||||
ui::CollabPanelStory::new().into_any()
|
||||
ui::CollabPanelStory::new().render()
|
||||
})
|
||||
.into_any(),
|
||||
Self::CommandPalette => view(cx.entity(|cx| ()), |_, _| {
|
||||
ui::CommandPaletteStory::new().into_any()
|
||||
ui::CommandPaletteStory::new().render()
|
||||
})
|
||||
.into_any(),
|
||||
Self::ContextMenu => view(cx.entity(|cx| ()), |_, _| {
|
||||
ui::ContextMenuStory::new().into_any()
|
||||
ui::ContextMenuStory::new().render()
|
||||
})
|
||||
.into_any(),
|
||||
Self::Facepile => view(cx.entity(|cx| ()), |_, _| {
|
||||
ui::FacepileStory::new().into_any()
|
||||
ui::FacepileStory::new().render()
|
||||
})
|
||||
.into_any(),
|
||||
Self::Keybinding => view(cx.entity(|cx| ()), |_, _| {
|
||||
ui::KeybindingStory::new().into_any()
|
||||
ui::KeybindingStory::new().render()
|
||||
})
|
||||
.into_any(),
|
||||
Self::LanguageSelector => view(cx.entity(|cx| ()), |_, _| {
|
||||
ui::LanguageSelectorStory::new().into_any()
|
||||
ui::LanguageSelectorStory::new().render()
|
||||
})
|
||||
.into_any(),
|
||||
Self::MultiBuffer => view(cx.entity(|cx| ()), |_, _| {
|
||||
ui::MultiBufferStory::new().into_any()
|
||||
ui::MultiBufferStory::new().render()
|
||||
})
|
||||
.into_any(),
|
||||
Self::NotificationsPanel => view(cx.entity(|cx| ()), |_, _| {
|
||||
ui::NotificationsPanelStory::new().into_any()
|
||||
ui::NotificationsPanelStory::new().render()
|
||||
})
|
||||
.into_any(),
|
||||
Self::Palette => view(cx.entity(|cx| ()), |_, _| {
|
||||
ui::PaletteStory::new().into_any()
|
||||
ui::PaletteStory::new().render()
|
||||
})
|
||||
.into_any(),
|
||||
Self::Panel => {
|
||||
view(cx.entity(|cx| ()), |_, _| ui::PanelStory::new().into_any()).into_any()
|
||||
view(cx.entity(|cx| ()), |_, _| ui::PanelStory::new().render()).into_any()
|
||||
}
|
||||
Self::ProjectPanel => view(cx.entity(|cx| ()), |_, _| {
|
||||
ui::ProjectPanelStory::new().into_any()
|
||||
ui::ProjectPanelStory::new().render()
|
||||
})
|
||||
.into_any(),
|
||||
Self::RecentProjects => view(cx.entity(|cx| ()), |_, _| {
|
||||
ui::RecentProjectsStory::new().into_any()
|
||||
ui::RecentProjectsStory::new().render()
|
||||
})
|
||||
.into_any(),
|
||||
Self::Tab => view(cx.entity(|cx| ()), |_, _| ui::TabStory::new().into_any()).into_any(),
|
||||
Self::Tab => view(cx.entity(|cx| ()), |_, _| ui::TabStory::new().render()).into_any(),
|
||||
Self::TabBar => {
|
||||
view(cx.entity(|cx| ()), |_, _| ui::TabBarStory::new().into_any()).into_any()
|
||||
view(cx.entity(|cx| ()), |_, _| ui::TabBarStory::new().render()).into_any()
|
||||
}
|
||||
Self::Terminal => view(cx.entity(|cx| ()), |_, _| {
|
||||
ui::TerminalStory::new().into_any()
|
||||
ui::TerminalStory::new().render()
|
||||
})
|
||||
.into_any(),
|
||||
Self::ThemeSelector => view(cx.entity(|cx| ()), |_, _| {
|
||||
ui::ThemeSelectorStory::new().into_any()
|
||||
ui::ThemeSelectorStory::new().render()
|
||||
})
|
||||
.into_any(),
|
||||
Self::TitleBar => ui::TitleBarStory::view(cx).into_any(),
|
||||
Self::Toast => {
|
||||
view(cx.entity(|cx| ()), |_, _| ui::ToastStory::new().into_any()).into_any()
|
||||
view(cx.entity(|cx| ()), |_, _| ui::ToastStory::new().render()).into_any()
|
||||
}
|
||||
Self::Toolbar => view(cx.entity(|cx| ()), |_, _| {
|
||||
ui::ToolbarStory::new().into_any()
|
||||
ui::ToolbarStory::new().render()
|
||||
})
|
||||
.into_any(),
|
||||
Self::TrafficLights => view(cx.entity(|cx| ()), |_, _| {
|
||||
ui::TrafficLightsStory::new().into_any()
|
||||
ui::TrafficLightsStory::new().render()
|
||||
})
|
||||
.into_any(),
|
||||
Self::Copilot => view(cx.entity(|cx| ()), |_, _| {
|
||||
ui::CopilotModalStory::new().into_any()
|
||||
ui::CopilotModalStory::new().render()
|
||||
})
|
||||
.into_any(),
|
||||
Self::Workspace => ui::WorkspaceStory::view(cx).into_any(),
|
||||
|
|
|
@ -107,7 +107,7 @@ impl StoryWrapper {
|
|||
Self { story, theme }
|
||||
}
|
||||
|
||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoAnyElement<Self> {
|
||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Component<Self> {
|
||||
themed(self.theme.clone(), cx, |cx| {
|
||||
div()
|
||||
.flex()
|
||||
|
|
|
@ -5,7 +5,7 @@ use gpui2::{rems, AbsoluteLength};
|
|||
use crate::prelude::*;
|
||||
use crate::{Icon, IconButton, Label, Panel, PanelSide};
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct AssistantPanel<S: 'static + Send + Sync> {
|
||||
id: ElementId,
|
||||
state_type: PhantomData<S>,
|
||||
|
@ -26,7 +26,7 @@ impl<S: 'static + Send + Sync> AssistantPanel<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(self, view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
Panel::new(self.id.clone(), cx)
|
||||
.children(vec![div()
|
||||
.flex()
|
||||
|
@ -69,7 +69,7 @@ impl<S: 'static + Send + Sync> AssistantPanel<S> {
|
|||
.overflow_y_scroll()
|
||||
.child(Label::new("Is this thing on?")),
|
||||
)
|
||||
.into_any()])
|
||||
.render()])
|
||||
.side(self.current_side)
|
||||
.width(AbsoluteLength::Rems(rems(32.)))
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct AssistantPanelStory<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, AssistantPanel<S>>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -9,7 +9,7 @@ use crate::{h_stack, HighlightedText};
|
|||
#[derive(Clone)]
|
||||
pub struct Symbol(pub Vec<HighlightedText>);
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct Breadcrumb<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
path: PathBuf,
|
||||
|
@ -31,7 +31,7 @@ impl<S: 'static + Send + Sync> Breadcrumb<S> {
|
|||
div().child(" › ").text_color(theme.text_muted)
|
||||
}
|
||||
|
||||
fn render(self, view_state: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, view_state: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
let symbols_len = self.symbols.len();
|
||||
|
@ -86,7 +86,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct BreadcrumbStory<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, view_state: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, view_state: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
Story::container(cx)
|
||||
|
|
|
@ -109,7 +109,7 @@ impl BufferRow {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(IntoAnyElement, Clone)]
|
||||
#[derive(Component, Clone)]
|
||||
pub struct Buffer<S: 'static + Send + Sync + Clone> {
|
||||
id: ElementId,
|
||||
state_type: PhantomData<S>,
|
||||
|
@ -158,7 +158,7 @@ impl<S: 'static + Send + Sync + Clone> Buffer<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render_row(row: BufferRow, cx: &WindowContext) -> impl IntoAnyElement<S> {
|
||||
fn render_row(row: BufferRow, cx: &WindowContext) -> impl Component<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
let line_background = if row.current {
|
||||
|
@ -208,7 +208,7 @@ impl<S: 'static + Send + Sync + Clone> Buffer<S> {
|
|||
}))
|
||||
}
|
||||
|
||||
fn render_rows(&self, cx: &WindowContext) -> Vec<impl IntoAnyElement<S>> {
|
||||
fn render_rows(&self, cx: &WindowContext) -> Vec<impl Component<S>> {
|
||||
match &self.rows {
|
||||
Some(rows) => rows
|
||||
.rows
|
||||
|
@ -219,7 +219,7 @@ impl<S: 'static + Send + Sync + Clone> Buffer<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let theme = theme(cx);
|
||||
let rows = self.render_rows(cx);
|
||||
|
||||
|
@ -246,7 +246,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct BufferStory<S: 'static + Send + Sync + Clone> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -258,7 +258,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
Story::container(cx)
|
||||
|
|
|
@ -25,7 +25,7 @@ impl BufferSearch {
|
|||
view(cx.entity(|cx| Self::new()), Self::render)
|
||||
}
|
||||
|
||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoAnyElement<Self> {
|
||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Component<Self> {
|
||||
let theme = theme(cx);
|
||||
|
||||
h_stack().bg(theme.toolbar).p_2().child(
|
||||
|
|
|
@ -5,7 +5,7 @@ use chrono::NaiveDateTime;
|
|||
use crate::prelude::*;
|
||||
use crate::{Icon, IconButton, Input, Label, LabelColor};
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct ChatPanel<S: 'static + Send + Sync> {
|
||||
element_id: ElementId,
|
||||
messages: Vec<ChatMessage<S>>,
|
||||
|
@ -24,7 +24,7 @@ impl<S: 'static + Send + Sync> ChatPanel<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
div()
|
||||
.id(self.element_id.clone())
|
||||
.flex()
|
||||
|
@ -70,7 +70,7 @@ impl<S: 'static + Send + Sync> ChatPanel<S> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct ChatMessage<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
author: String,
|
||||
|
@ -88,7 +88,7 @@ impl<S: 'static + Send + Sync> ChatMessage<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
div()
|
||||
.flex()
|
||||
.flex_col()
|
||||
|
@ -117,7 +117,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct ChatPanelStory<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, ChatPanel<S>>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -5,7 +5,7 @@ use crate::{
|
|||
};
|
||||
use std::marker::PhantomData;
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct CollabPanel<S: 'static + Send + Sync> {
|
||||
id: ElementId,
|
||||
state_type: PhantomData<S>,
|
||||
|
@ -19,7 +19,7 @@ impl<S: 'static + Send + Sync> CollabPanel<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
v_stack()
|
||||
|
@ -98,7 +98,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct CollabPanelStory<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, CollabPanel<S>>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::marker::PhantomData;
|
|||
use crate::prelude::*;
|
||||
use crate::{example_editor_actions, OrderMethod, Palette};
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct CommandPalette<S: 'static + Send + Sync> {
|
||||
id: ElementId,
|
||||
state_type: PhantomData<S>,
|
||||
|
@ -17,7 +17,7 @@ impl<S: 'static + Send + Sync> CommandPalette<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
div().id(self.id.clone()).child(
|
||||
Palette::new("palette")
|
||||
.items(example_editor_actions())
|
||||
|
@ -37,7 +37,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct CommandPaletteStory<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, CommandPalette<S>>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -31,7 +31,7 @@ impl<S: 'static + Send + Sync> ContextMenuItem<S> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct ContextMenu<S: 'static + Send + Sync> {
|
||||
items: Vec<ContextMenuItem<S>>,
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ impl<S: 'static + Send + Sync> ContextMenu<S> {
|
|||
items: items.into_iter().collect(),
|
||||
}
|
||||
}
|
||||
fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
v_stack()
|
||||
|
@ -73,7 +73,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct ContextMenuStory<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, ContextMenu<S>>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::marker::PhantomData;
|
|||
|
||||
use crate::{prelude::*, Button, Label, LabelColor, Modal};
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct CopilotModal<S: 'static + Send + Sync + Clone> {
|
||||
id: ElementId,
|
||||
state_type: PhantomData<S>,
|
||||
|
@ -16,7 +16,7 @@ impl<S: 'static + Send + Sync + Clone> CopilotModal<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
div().id(self.id.clone()).child(
|
||||
Modal::new("some-id")
|
||||
.title("Connect Copilot to Zed")
|
||||
|
@ -35,7 +35,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct CopilotModalStory<S: 'static + Send + Sync + Clone> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, CopilotModal<S>>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -49,7 +49,7 @@ impl EditorPane {
|
|||
)
|
||||
}
|
||||
|
||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoAnyElement<Self> {
|
||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Component<Self> {
|
||||
v_stack()
|
||||
.w_full()
|
||||
.h_full()
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::marker::PhantomData;
|
|||
use crate::prelude::*;
|
||||
use crate::{Avatar, Player};
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct Facepile<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
players: Vec<Player>,
|
||||
|
@ -17,7 +17,7 @@ impl<S: 'static + Send + Sync> Facepile<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let player_count = self.players.len();
|
||||
let player_list = self.players.iter().enumerate().map(|(ix, player)| {
|
||||
let isnt_last = ix < player_count - 1;
|
||||
|
@ -39,7 +39,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct FacepileStory<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let players = static_players();
|
||||
|
||||
Story::container(cx)
|
||||
|
|
|
@ -16,7 +16,7 @@ impl<S: 'static + Send + Sync> Default for IconButtonHandlers<S> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct IconButton<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
id: ElementId,
|
||||
|
@ -68,7 +68,7 @@ impl<S: 'static + Send + Sync> IconButton<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
let icon_color = match (self.state, self.color) {
|
||||
|
|
|
@ -5,7 +5,7 @@ use strum::{EnumIter, IntoEnumIterator};
|
|||
|
||||
use crate::prelude::*;
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct Keybinding<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
|
||||
|
@ -34,7 +34,7 @@ impl<S: 'static + Send + Sync> Keybinding<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
div()
|
||||
.flex()
|
||||
.gap_2()
|
||||
|
@ -54,7 +54,7 @@ impl<S: 'static + Send + Sync> Keybinding<S> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct Key<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
key: SharedString,
|
||||
|
@ -68,7 +68,7 @@ impl<S: 'static + Send + Sync> Key<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
div()
|
||||
|
@ -173,7 +173,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct KeybindingStory<S: 'static + Send + Sync + Clone> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let all_modifier_permutations = ModifierKey::iter().permutations(2);
|
||||
|
||||
Story::container(cx)
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::marker::PhantomData;
|
|||
use crate::prelude::*;
|
||||
use crate::{OrderMethod, Palette, PaletteItem};
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct LanguageSelector<S: 'static + Send + Sync + Clone> {
|
||||
id: ElementId,
|
||||
state_type: PhantomData<S>,
|
||||
|
@ -17,7 +17,7 @@ impl<S: 'static + Send + Sync + Clone> LanguageSelector<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
div().id(self.id.clone()).child(
|
||||
Palette::new("palette")
|
||||
.items(vec![
|
||||
|
@ -48,7 +48,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct LanguageSelectorStory<S: 'static + Send + Sync + Clone> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, LanguageSelector<S>>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -17,7 +17,7 @@ pub enum ListItemVariant {
|
|||
Inset,
|
||||
}
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct ListHeader<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
label: SharedString,
|
||||
|
@ -92,7 +92,7 @@ impl<S: 'static + Send + Sync> ListHeader<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
let is_toggleable = self.toggleable != Toggleable::NotToggleable;
|
||||
|
@ -134,7 +134,7 @@ impl<S: 'static + Send + Sync> ListHeader<S> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct ListSubHeader<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
label: SharedString,
|
||||
|
@ -157,7 +157,7 @@ impl<S: 'static + Send + Sync> ListSubHeader<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
h_stack().flex_1().w_full().relative().py_1().child(
|
||||
div()
|
||||
.h_6()
|
||||
|
@ -197,7 +197,7 @@ pub enum ListEntrySize {
|
|||
Medium,
|
||||
}
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub enum ListItem<S: 'static + Send + Sync> {
|
||||
Entry(ListEntry<S>),
|
||||
Details(ListDetailsEntry<S>),
|
||||
|
@ -230,7 +230,7 @@ impl<S: 'static + Send + Sync> From<ListSubHeader<S>> for ListItem<S> {
|
|||
}
|
||||
|
||||
impl<S: 'static + Send + Sync> ListItem<S> {
|
||||
fn render(self, view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
match self {
|
||||
ListItem::Entry(entry) => div().child(entry.render(view, cx)),
|
||||
ListItem::Separator(separator) => div().child(separator.render(view, cx)),
|
||||
|
@ -252,7 +252,7 @@ impl<S: 'static + Send + Sync> ListItem<S> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct ListEntry<S: 'static + Send + Sync> {
|
||||
disclosure_control_style: DisclosureControlVisibility,
|
||||
indent_level: u32,
|
||||
|
@ -344,7 +344,7 @@ impl<S: 'static + Send + Sync> ListEntry<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn disclosure_control(&mut self, cx: &mut ViewContext<S>) -> Option<impl IntoAnyElement<S>> {
|
||||
fn disclosure_control(&mut self, cx: &mut ViewContext<S>) -> Option<impl Component<S>> {
|
||||
let disclosure_control_icon = if let Some(ToggleState::Toggled) = self.toggle {
|
||||
IconElement::new(Icon::ChevronDown)
|
||||
} else {
|
||||
|
@ -364,7 +364,7 @@ impl<S: 'static + Send + Sync> ListEntry<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let settings = user_settings(cx);
|
||||
let theme = theme(cx);
|
||||
|
||||
|
@ -430,7 +430,7 @@ impl<S: 'static + Send + Sync> Default for ListDetailsEntryHandlers<S> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct ListDetailsEntry<S: 'static + Send + Sync> {
|
||||
label: SharedString,
|
||||
meta: Option<SharedString>,
|
||||
|
@ -474,7 +474,7 @@ impl<S: 'static + Send + Sync> ListDetailsEntry<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let theme = theme(cx);
|
||||
let settings = user_settings(cx);
|
||||
|
||||
|
@ -519,7 +519,7 @@ impl<S: 'static + Send + Sync> ListDetailsEntry<S> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, IntoAnyElement)]
|
||||
#[derive(Clone, Component)]
|
||||
pub struct ListSeparator<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -531,14 +531,14 @@ impl<S: 'static + Send + Sync> ListSeparator<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
div().h_px().w_full().bg(theme.border)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct List<S: 'static + Send + Sync> {
|
||||
items: Vec<ListItem<S>>,
|
||||
empty_message: SharedString,
|
||||
|
@ -571,7 +571,7 @@ impl<S: 'static + Send + Sync> List<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let is_toggleable = self.toggleable != Toggleable::NotToggleable;
|
||||
let is_toggled = Toggleable::is_toggled(&self.toggleable);
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ use smallvec::SmallVec;
|
|||
|
||||
use crate::{h_stack, prelude::*, v_stack, Button, Icon, IconButton, Label};
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct Modal<S: 'static + Send + Sync> {
|
||||
id: ElementId,
|
||||
state_type: PhantomData<S>,
|
||||
|
@ -42,7 +42,7 @@ impl<S: 'static + Send + Sync> Modal<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
v_stack()
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::marker::PhantomData;
|
|||
use crate::prelude::*;
|
||||
use crate::{v_stack, Buffer, Icon, IconButton, Label};
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct MultiBuffer<S: 'static + Send + Sync + Clone> {
|
||||
state_type: PhantomData<S>,
|
||||
buffers: Vec<Buffer<S>>,
|
||||
|
@ -17,7 +17,7 @@ impl<S: 'static + Send + Sync + Clone> MultiBuffer<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
v_stack()
|
||||
|
@ -50,7 +50,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct MultiBufferStory<S: 'static + Send + Sync + Clone> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
Story::container(cx)
|
||||
|
|
|
@ -4,7 +4,7 @@ use gpui2::rems;
|
|||
|
||||
use crate::{h_stack, prelude::*, Icon};
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct NotificationToast<S: 'static + Send + Sync + Clone> {
|
||||
state_type: PhantomData<S>,
|
||||
label: SharedString,
|
||||
|
@ -28,7 +28,7 @@ impl<S: 'static + Send + Sync + Clone> NotificationToast<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
h_stack()
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::marker::PhantomData;
|
|||
use crate::{prelude::*, static_new_notification_items, static_read_notification_items};
|
||||
use crate::{List, ListHeader};
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct NotificationsPanel<S: 'static + Send + Sync> {
|
||||
id: ElementId,
|
||||
state_type: PhantomData<S>,
|
||||
|
@ -17,7 +17,7 @@ impl<S: 'static + Send + Sync> NotificationsPanel<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
div()
|
||||
|
@ -58,7 +58,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct NotificationsPanelStory<S: 'static + Send + Sync + Clone> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, NotificationsPanel<S>>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::marker::PhantomData;
|
|||
use crate::prelude::*;
|
||||
use crate::{h_stack, v_stack, Keybinding, Label, LabelColor};
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct Palette<S: 'static + Send + Sync> {
|
||||
id: ElementId,
|
||||
state_type: PhantomData<S>,
|
||||
|
@ -46,7 +46,7 @@ impl<S: 'static + Send + Sync> Palette<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
v_stack()
|
||||
|
@ -101,7 +101,7 @@ impl<S: 'static + Send + Sync> Palette<S> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct PaletteItem<S: 'static + Send + Sync> {
|
||||
pub label: SharedString,
|
||||
pub sublabel: Option<SharedString>,
|
||||
|
@ -135,7 +135,7 @@ impl<S: 'static + Send + Sync> PaletteItem<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
div()
|
||||
.flex()
|
||||
.flex_row()
|
||||
|
@ -160,7 +160,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct PaletteStory<S: 'static + Send + Sync + Clone> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, Palette<S>>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -40,7 +40,7 @@ pub enum PanelSide {
|
|||
|
||||
use std::collections::HashSet;
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct Panel<S: 'static + Send + Sync> {
|
||||
id: ElementId,
|
||||
state_type: PhantomData<S>,
|
||||
|
@ -96,7 +96,7 @@ impl<S: 'static + Send + Sync> Panel<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
let current_size = self.width.unwrap_or(self.initial_width);
|
||||
|
@ -136,7 +136,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct PanelStory<S: 'static + Send + Sync + Clone> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, Panel<S>>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -12,7 +12,7 @@ pub enum SplitDirection {
|
|||
Vertical,
|
||||
}
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct Pane<V: 'static> {
|
||||
id: ElementId,
|
||||
size: Size<Length>,
|
||||
|
@ -44,7 +44,7 @@ impl<V: 'static> Pane<V> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(self, view: &mut V, cx: &mut ViewContext<V>) -> impl IntoAnyElement<V> {
|
||||
fn render(self, view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
div()
|
||||
.id(self.id.clone())
|
||||
.flex()
|
||||
|
@ -75,7 +75,7 @@ impl<V: 'static> ParentElement<V> for Pane<V> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct PaneGroup<V: 'static + Send + Sync> {
|
||||
state_type: PhantomData<V>,
|
||||
groups: Vec<PaneGroup<V>>,
|
||||
|
@ -102,7 +102,7 @@ impl<V: 'static + Send + Sync> PaneGroup<V> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(mut self, view: &mut V, cx: &mut ViewContext<V>) -> impl IntoAnyElement<V> {
|
||||
fn render(mut self, view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
let theme = theme(cx);
|
||||
|
||||
if !self.panes.is_empty() {
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::marker::PhantomData;
|
|||
use crate::prelude::*;
|
||||
use crate::{Avatar, Facepile, PlayerWithCallStatus};
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct PlayerStack<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
player_with_call_status: PlayerWithCallStatus,
|
||||
|
@ -17,7 +17,7 @@ impl<S: 'static + Send + Sync> PlayerStack<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let theme = theme(cx);
|
||||
let player = self.player_with_call_status.get_player();
|
||||
self.player_with_call_status.get_call_status();
|
||||
|
|
|
@ -5,7 +5,7 @@ use crate::{
|
|||
static_project_panel_project_items, static_project_panel_single_items, Input, List, ListHeader,
|
||||
};
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct ProjectPanel<S: 'static + Send + Sync> {
|
||||
id: ElementId,
|
||||
state_type: PhantomData<S>,
|
||||
|
@ -19,7 +19,7 @@ impl<S: 'static + Send + Sync> ProjectPanel<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
div()
|
||||
|
@ -67,7 +67,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct ProjectPanelStory<S: 'static + Send + Sync + Clone> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, ProjectPanel<S>>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::marker::PhantomData;
|
|||
use crate::prelude::*;
|
||||
use crate::{OrderMethod, Palette, PaletteItem};
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct RecentProjects<S: 'static + Send + Sync + Clone> {
|
||||
id: ElementId,
|
||||
state_type: PhantomData<S>,
|
||||
|
@ -17,7 +17,7 @@ impl<S: 'static + Send + Sync + Clone> RecentProjects<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
div().id(self.id.clone()).child(
|
||||
Palette::new("palette")
|
||||
.items(vec![
|
||||
|
@ -44,7 +44,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct RecentProjectsStory<S: 'static + Send + Sync + Clone> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, RecentProjects<S>>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -28,8 +28,8 @@ impl Default for ToolGroup {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[element(view_type = "Workspace")]
|
||||
#[derive(Component)]
|
||||
#[component(view_type = "Workspace")]
|
||||
pub struct StatusBar {
|
||||
left_tools: Option<ToolGroup>,
|
||||
right_tools: Option<ToolGroup>,
|
||||
|
@ -86,7 +86,7 @@ impl StatusBar {
|
|||
self,
|
||||
view: &mut Workspace,
|
||||
cx: &mut ViewContext<Workspace>,
|
||||
) -> impl IntoAnyElement<Workspace> {
|
||||
) -> impl Component<Workspace> {
|
||||
let theme = theme(cx);
|
||||
|
||||
div()
|
||||
|
@ -105,7 +105,7 @@ impl StatusBar {
|
|||
&self,
|
||||
workspace: &mut Workspace,
|
||||
cx: &WindowContext,
|
||||
) -> impl IntoAnyElement<Workspace> {
|
||||
) -> impl Component<Workspace> {
|
||||
div()
|
||||
.flex()
|
||||
.items_center()
|
||||
|
@ -136,7 +136,7 @@ impl StatusBar {
|
|||
&self,
|
||||
workspace: &mut Workspace,
|
||||
cx: &WindowContext,
|
||||
) -> impl IntoAnyElement<Workspace> {
|
||||
) -> impl Component<Workspace> {
|
||||
div()
|
||||
.flex()
|
||||
.items_center()
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::marker::PhantomData;
|
|||
use crate::prelude::*;
|
||||
use crate::{Icon, IconColor, IconElement, Label, LabelColor};
|
||||
|
||||
#[derive(IntoAnyElement, Clone)]
|
||||
#[derive(Component, Clone)]
|
||||
pub struct Tab<S: 'static + Send + Sync + Clone> {
|
||||
state_type: PhantomData<S>,
|
||||
id: ElementId,
|
||||
|
@ -81,7 +81,7 @@ impl<S: 'static + Send + Sync + Clone> Tab<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let theme = theme(cx);
|
||||
let has_fs_conflict = self.fs_status == FileSystemStatus::Conflict;
|
||||
let is_deleted = self.fs_status == FileSystemStatus::Deleted;
|
||||
|
@ -176,7 +176,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct TabStory<S: 'static + Send + Sync + Clone> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let git_statuses = GitStatus::iter();
|
||||
let fs_statuses = FileSystemStatus::iter();
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::marker::PhantomData;
|
|||
use crate::prelude::*;
|
||||
use crate::{Icon, IconButton, Tab};
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct TabBar<S: 'static + Send + Sync + Clone> {
|
||||
id: ElementId,
|
||||
state_type: PhantomData<S>,
|
||||
|
@ -27,7 +27,7 @@ impl<S: 'static + Send + Sync + Clone> TabBar<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
let (can_navigate_back, can_navigate_forward) = self.can_navigate;
|
||||
|
@ -100,7 +100,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct TabBarStory<S: 'static + Send + Sync + Clone> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, TabBar<S>>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -5,7 +5,7 @@ use gpui2::{relative, rems, Size};
|
|||
use crate::prelude::*;
|
||||
use crate::{Icon, IconButton, Pane, Tab};
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct Terminal<S: 'static + Send + Sync + Clone> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ impl<S: 'static + Send + Sync + Clone> Terminal<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
let can_navigate_back = true;
|
||||
|
@ -93,7 +93,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct TerminalStory<S: 'static + Send + Sync + Clone> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, Terminal<S>>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::marker::PhantomData;
|
|||
use crate::prelude::*;
|
||||
use crate::{OrderMethod, Palette, PaletteItem};
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct ThemeSelector<S: 'static + Send + Sync> {
|
||||
id: ElementId,
|
||||
state_type: PhantomData<S>,
|
||||
|
@ -17,7 +17,7 @@ impl<S: 'static + Send + Sync> ThemeSelector<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
div().child(
|
||||
Palette::new(self.id.clone())
|
||||
.items(vec![
|
||||
|
@ -49,7 +49,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct ThemeSelectorStory<S: 'static + Send + Sync + Clone> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, ThemeSelector<S>>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -87,7 +87,7 @@ impl TitleBar {
|
|||
)
|
||||
}
|
||||
|
||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoAnyElement<Self> {
|
||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Component<Self> {
|
||||
let theme = theme(cx);
|
||||
let settings = user_settings(cx);
|
||||
|
||||
|
@ -204,7 +204,7 @@ mod stories {
|
|||
)
|
||||
}
|
||||
|
||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoAnyElement<Self> {
|
||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Component<Self> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, TitleBar>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -22,7 +22,7 @@ pub enum ToastOrigin {
|
|||
/// they are actively showing the a process in progress.
|
||||
///
|
||||
/// Only one toast may be visible at a time.
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct Toast<S: 'static + Send + Sync> {
|
||||
origin: ToastOrigin,
|
||||
children: SmallVec<[AnyElement<S>; 2]>,
|
||||
|
@ -36,7 +36,7 @@ impl<S: 'static + Send + Sync> Toast<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
let mut div = div();
|
||||
|
@ -78,7 +78,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct ToastStory<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, Toast<S>>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -6,7 +6,7 @@ use crate::prelude::*;
|
|||
#[derive(Clone)]
|
||||
pub struct ToolbarItem {}
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct Toolbar<S: 'static + Send + Sync> {
|
||||
left_items: SmallVec<[AnyElement<S>; 2]>,
|
||||
right_items: SmallVec<[AnyElement<S>; 2]>,
|
||||
|
@ -20,41 +20,41 @@ impl<S: 'static + Send + Sync> Toolbar<S> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn left_item(mut self, child: impl IntoAnyElement<S>) -> Self
|
||||
pub fn left_item(mut self, child: impl Component<S>) -> Self
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
self.left_items.push(child.into_any());
|
||||
self.left_items.push(child.render());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn left_items(mut self, iter: impl IntoIterator<Item = impl IntoAnyElement<S>>) -> Self
|
||||
pub fn left_items(mut self, iter: impl IntoIterator<Item = impl Component<S>>) -> Self
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
self.left_items
|
||||
.extend(iter.into_iter().map(|item| item.into_any()));
|
||||
.extend(iter.into_iter().map(|item| item.render()));
|
||||
self
|
||||
}
|
||||
|
||||
pub fn right_item(mut self, child: impl IntoAnyElement<S>) -> Self
|
||||
pub fn right_item(mut self, child: impl Component<S>) -> Self
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
self.right_items.push(child.into_any());
|
||||
self.right_items.push(child.render());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn right_items(mut self, iter: impl IntoIterator<Item = impl IntoAnyElement<S>>) -> Self
|
||||
pub fn right_items(mut self, iter: impl IntoIterator<Item = impl Component<S>>) -> Self
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
self.right_items
|
||||
.extend(iter.into_iter().map(|item| item.into_any()));
|
||||
.extend(iter.into_iter().map(|item| item.render()));
|
||||
self
|
||||
}
|
||||
|
||||
fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
div()
|
||||
|
@ -80,7 +80,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct ToolbarStory<S: 'static + Send + Sync + Clone> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
Story::container(cx)
|
||||
|
|
|
@ -9,7 +9,7 @@ enum TrafficLightColor {
|
|||
Green,
|
||||
}
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
struct TrafficLight<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
color: TrafficLightColor,
|
||||
|
@ -25,7 +25,7 @@ impl<S: 'static + Send + Sync> TrafficLight<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
let fill = match (self.window_has_focus, self.color) {
|
||||
|
@ -39,7 +39,7 @@ impl<S: 'static + Send + Sync> TrafficLight<S> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct TrafficLights<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
window_has_focus: bool,
|
||||
|
@ -58,7 +58,7 @@ impl<S: 'static + Send + Sync> TrafficLights<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
div()
|
||||
.flex()
|
||||
.items_center()
|
||||
|
@ -87,7 +87,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct TrafficLightsStory<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, TrafficLights<S>>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -174,7 +174,7 @@ impl Workspace {
|
|||
view(cx.entity(|cx| Self::new(cx)), Self::render)
|
||||
}
|
||||
|
||||
pub fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoAnyElement<Self> {
|
||||
pub fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Component<Self> {
|
||||
let theme = old_theme(cx).clone();
|
||||
|
||||
// HACK: This should happen inside of `debug_toggle_user_settings`, but
|
||||
|
|
|
@ -4,7 +4,7 @@ use gpui2::img;
|
|||
|
||||
use crate::prelude::*;
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct Avatar<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
src: SharedString,
|
||||
|
@ -25,7 +25,7 @@ impl<S: 'static + Send + Sync> Avatar<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
let mut img = img();
|
||||
|
@ -51,7 +51,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct AvatarStory<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, Avatar<S>>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -61,7 +61,7 @@ impl<S: 'static + Send + Sync> Default for ButtonHandlers<S> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct Button<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
disabled: bool,
|
||||
|
@ -150,7 +150,7 @@ impl<S: 'static + Send + Sync> Button<S> {
|
|||
self.icon.map(|i| IconElement::new(i).color(icon_color))
|
||||
}
|
||||
|
||||
pub fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
pub fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let icon_color = self.icon_color();
|
||||
|
||||
let mut button = h_stack()
|
||||
|
@ -193,7 +193,7 @@ impl<S: 'static + Send + Sync> Button<S> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct ButtonGroup<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
buttons: Vec<Button<S>>,
|
||||
|
@ -207,7 +207,7 @@ impl<S: 'static + Send + Sync> ButtonGroup<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let mut el = h_stack().text_size(ui_size(cx, 1.));
|
||||
|
||||
for button in self.buttons {
|
||||
|
@ -230,7 +230,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct ButtonStory<S: 'static + Send + Sync + Clone> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -242,7 +242,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let states = InteractionState::iter();
|
||||
|
||||
Story::container(cx)
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::marker::PhantomData;
|
|||
|
||||
use crate::{prelude::*, v_stack, ButtonGroup};
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct Details<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
text: &'static str,
|
||||
|
@ -30,7 +30,7 @@ impl<S: 'static + Send + Sync> Details<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
v_stack()
|
||||
|
@ -54,7 +54,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct DetailsStory<S: 'static + Send + Sync + Clone> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, Details<S>>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -148,7 +148,7 @@ impl Icon {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct IconElement<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
icon: Icon,
|
||||
|
@ -176,7 +176,7 @@ impl<S: 'static + Send + Sync> IconElement<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let fill = self.color.color(cx);
|
||||
let svg_size = match self.size {
|
||||
IconSize::Small => ui_size(cx, 12. / 14.),
|
||||
|
@ -202,7 +202,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct IconStory<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -214,7 +214,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let icons = Icon::iter();
|
||||
|
||||
Story::container(cx)
|
||||
|
|
|
@ -11,7 +11,7 @@ pub enum InputVariant {
|
|||
Filled,
|
||||
}
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct Input<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
placeholder: SharedString,
|
||||
|
@ -60,7 +60,7 @@ impl<S: 'static + Send + Sync> Input<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
let (input_bg, input_hover_bg, input_active_bg) = match self.variant {
|
||||
|
@ -120,7 +120,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct InputStory<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, Input<S>>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -48,7 +48,7 @@ pub enum LineHeightStyle {
|
|||
UILabel,
|
||||
}
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct Label<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
label: SharedString,
|
||||
|
@ -83,7 +83,7 @@ impl<S: 'static + Send + Sync> Label<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
div()
|
||||
.when(self.strikethrough, |this| {
|
||||
this.relative().child(
|
||||
|
@ -105,7 +105,7 @@ impl<S: 'static + Send + Sync> Label<S> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct HighlightedLabel<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
label: SharedString,
|
||||
|
@ -135,7 +135,7 @@ impl<S: 'static + Send + Sync> HighlightedLabel<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
let highlight_color = theme.text_accent;
|
||||
|
@ -211,7 +211,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct LabelStory<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -223,7 +223,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, Label<S>>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::marker::PhantomData;
|
|||
|
||||
use crate::prelude::*;
|
||||
|
||||
#[derive(IntoAnyElement)]
|
||||
#[derive(Component)]
|
||||
pub struct ToolDivider<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ impl<S: 'static + Send + Sync> ToolDivider<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
div().w_px().h_3().bg(theme.border)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
pub use gpui2::{
|
||||
div, Element, ElementId, IntoAnyElement, ParentElement, SharedString, StatefulInteractive,
|
||||
div, Element, ElementId, Component, ParentElement, SharedString, StatefulInteractive,
|
||||
StatelessInteractive, Styled, ViewContext, WindowContext,
|
||||
};
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ impl Story {
|
|||
pub fn title<S: 'static + Send + Sync>(
|
||||
cx: &mut ViewContext<S>,
|
||||
title: &str,
|
||||
) -> impl IntoAnyElement<S> {
|
||||
) -> impl Component<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
div()
|
||||
|
@ -30,16 +30,14 @@ impl Story {
|
|||
.child(title.to_owned())
|
||||
}
|
||||
|
||||
pub fn title_for<S: 'static + Send + Sync, T>(
|
||||
cx: &mut ViewContext<S>,
|
||||
) -> impl IntoAnyElement<S> {
|
||||
pub fn title_for<S: 'static + Send + Sync, T>(cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
Self::title(cx, std::any::type_name::<T>())
|
||||
}
|
||||
|
||||
pub fn label<S: 'static + Send + Sync>(
|
||||
cx: &mut ViewContext<S>,
|
||||
label: &str,
|
||||
) -> impl IntoAnyElement<S> {
|
||||
) -> impl Component<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
div()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use gpui2::{
|
||||
AnyElement, Bounds, Element, Hsla, IntoAnyElement, LayoutId, Pixels, Result, ViewContext,
|
||||
AnyElement, Bounds, Component, Element, Hsla, LayoutId, Pixels, Result, ViewContext,
|
||||
WindowContext,
|
||||
};
|
||||
use serde::{de::Visitor, Deserialize, Deserializer};
|
||||
|
@ -149,13 +149,13 @@ pub struct Themed<E> {
|
|||
pub(crate) child: E,
|
||||
}
|
||||
|
||||
impl<V, E> IntoAnyElement<V> for Themed<E>
|
||||
impl<V, E> Component<V> for Themed<E>
|
||||
where
|
||||
V: 'static,
|
||||
E: 'static + Element<V> + Send + Sync,
|
||||
E::ElementState: Send + Sync,
|
||||
{
|
||||
fn into_any(self) -> AnyElement<V> {
|
||||
fn render(self) -> AnyElement<V> {
|
||||
AnyElement::new(self)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue