Rename IntoAnyElement trait to Component
This commit is contained in:
parent
8ecfea55cd
commit
0285284ae1
60 changed files with 297 additions and 300 deletions
|
@ -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