Rename IntoAnyElement trait to Component

This commit is contained in:
Nathan Sobo 2023-10-26 12:46:52 +02:00
parent 8ecfea55cd
commit 0285284ae1
60 changed files with 297 additions and 300 deletions

View file

@ -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"))