Rename S
type to V
This commit is contained in:
parent
8a70ef3e8f
commit
1887f3b594
34 changed files with 140 additions and 152 deletions
|
@ -14,7 +14,7 @@ impl ZIndexStory {
|
||||||
Self
|
Self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title(cx, "z-index"))
|
.child(Story::title(cx, "z-index"))
|
||||||
.child(
|
.child(
|
||||||
|
|
|
@ -154,7 +154,7 @@ impl Buffer {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_row<S: 'static>(row: BufferRow, cx: &WindowContext) -> impl Component<S> {
|
fn render_row<V: 'static>(row: BufferRow, cx: &WindowContext) -> impl Component<V> {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
|
|
||||||
let line_background = if row.current {
|
let line_background = if row.current {
|
||||||
|
@ -204,7 +204,7 @@ impl Buffer {
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_rows<S: 'static>(&self, cx: &WindowContext) -> Vec<impl Component<S>> {
|
fn render_rows<V: 'static>(&self, cx: &WindowContext) -> Vec<impl Component<V>> {
|
||||||
match &self.rows {
|
match &self.rows {
|
||||||
Some(rows) => rows
|
Some(rows) => rows
|
||||||
.rows
|
.rows
|
||||||
|
@ -215,7 +215,7 @@ impl Buffer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
let rows = self.render_rows(cx);
|
let rows = self.render_rows(cx);
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ mod stories {
|
||||||
Self
|
Self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
|
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
|
|
|
@ -22,7 +22,7 @@ impl ChatPanel {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
div()
|
div()
|
||||||
.id(self.element_id.clone())
|
.id(self.element_id.clone())
|
||||||
.flex()
|
.flex()
|
||||||
|
@ -84,7 +84,7 @@ impl ChatMessage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
div()
|
div()
|
||||||
.flex()
|
.flex()
|
||||||
.flex_col()
|
.flex_col()
|
||||||
|
@ -121,7 +121,7 @@ mod stories {
|
||||||
Self
|
Self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, ChatPanel>(cx))
|
.child(Story::title_for::<_, ChatPanel>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
|
|
|
@ -14,7 +14,7 @@ impl CollabPanel {
|
||||||
Self { id: id.into() }
|
Self { id: id.into() }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
|
|
||||||
v_stack()
|
v_stack()
|
||||||
|
@ -101,7 +101,7 @@ mod stories {
|
||||||
Self
|
Self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, CollabPanel>(cx))
|
.child(Story::title_for::<_, CollabPanel>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
|
|
|
@ -11,7 +11,7 @@ impl CommandPalette {
|
||||||
Self { id: id.into() }
|
Self { id: id.into() }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
div().id(self.id.clone()).child(
|
div().id(self.id.clone()).child(
|
||||||
Palette::new("palette")
|
Palette::new("palette")
|
||||||
.items(example_editor_actions())
|
.items(example_editor_actions())
|
||||||
|
@ -39,7 +39,7 @@ mod stories {
|
||||||
Self
|
Self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, CommandPalette>(cx))
|
.child(Story::title_for::<_, CommandPalette>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
|
|
|
@ -43,7 +43,7 @@ impl ContextMenu {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
|
|
||||||
v_stack()
|
v_stack()
|
||||||
|
@ -80,7 +80,7 @@ mod stories {
|
||||||
Self
|
Self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, ContextMenu>(cx))
|
.child(Story::title_for::<_, ContextMenu>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
|
|
|
@ -10,7 +10,7 @@ impl CopilotModal {
|
||||||
Self { id: id.into() }
|
Self { id: id.into() }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
div().id(self.id.clone()).child(
|
div().id(self.id.clone()).child(
|
||||||
Modal::new("some-id")
|
Modal::new("some-id")
|
||||||
.title("Connect Copilot to Zed")
|
.title("Connect Copilot to Zed")
|
||||||
|
@ -37,7 +37,7 @@ mod stories {
|
||||||
Self
|
Self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, CopilotModal>(cx))
|
.child(Story::title_for::<_, CopilotModal>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
|
|
|
@ -13,7 +13,7 @@ impl Facepile {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
let player_count = self.players.len();
|
let player_count = self.players.len();
|
||||||
let player_list = self.players.iter().enumerate().map(|(ix, player)| {
|
let player_list = self.players.iter().enumerate().map(|(ix, player)| {
|
||||||
let isnt_last = ix < player_count - 1;
|
let isnt_last = ix < player_count - 1;
|
||||||
|
@ -43,7 +43,7 @@ mod stories {
|
||||||
Self
|
Self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
let players = static_players();
|
let players = static_players();
|
||||||
|
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
|
|
|
@ -5,27 +5,27 @@ use gpui2::MouseButton;
|
||||||
use crate::{h_stack, prelude::*};
|
use crate::{h_stack, prelude::*};
|
||||||
use crate::{ClickHandler, Icon, IconColor, IconElement};
|
use crate::{ClickHandler, Icon, IconColor, IconElement};
|
||||||
|
|
||||||
struct IconButtonHandlers<S: 'static> {
|
struct IconButtonHandlers<V: 'static> {
|
||||||
click: Option<ClickHandler<S>>,
|
click: Option<ClickHandler<V>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static> Default for IconButtonHandlers<S> {
|
impl<V: 'static> Default for IconButtonHandlers<V> {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self { click: None }
|
Self { click: None }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct IconButton<S: 'static> {
|
pub struct IconButton<V: 'static> {
|
||||||
id: ElementId,
|
id: ElementId,
|
||||||
icon: Icon,
|
icon: Icon,
|
||||||
color: IconColor,
|
color: IconColor,
|
||||||
variant: ButtonVariant,
|
variant: ButtonVariant,
|
||||||
state: InteractionState,
|
state: InteractionState,
|
||||||
handlers: IconButtonHandlers<S>,
|
handlers: IconButtonHandlers<V>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static> IconButton<S> {
|
impl<V: 'static> IconButton<V> {
|
||||||
pub fn new(id: impl Into<ElementId>, icon: Icon) -> Self {
|
pub fn new(id: impl Into<ElementId>, icon: Icon) -> Self {
|
||||||
Self {
|
Self {
|
||||||
id: id.into(),
|
id: id.into(),
|
||||||
|
@ -57,12 +57,12 @@ impl<S: 'static> IconButton<S> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn on_click(mut self, handler: impl 'static + Fn(&mut S, &mut ViewContext<S>) + Send + Sync) -> Self {
|
pub fn on_click(mut self, handler: impl 'static + Fn(&mut V, &mut ViewContext<V>) + Send + Sync) -> Self {
|
||||||
self.handlers.click = Some(Arc::new(handler));
|
self.handlers.click = Some(Arc::new(handler));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
|
|
||||||
let icon_color = match (self.state, self.color) {
|
let icon_color = match (self.state, self.color) {
|
||||||
|
|
|
@ -29,7 +29,7 @@ impl Keybinding {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
div()
|
div()
|
||||||
.flex()
|
.flex()
|
||||||
.gap_2()
|
.gap_2()
|
||||||
|
@ -59,7 +59,7 @@ impl Key {
|
||||||
Self { key: key.into() }
|
Self { key: key.into() }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
|
|
||||||
div()
|
div()
|
||||||
|
|
|
@ -11,7 +11,7 @@ impl LanguageSelector {
|
||||||
Self { id: id.into() }
|
Self { id: id.into() }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
div().id(self.id.clone()).child(
|
div().id(self.id.clone()).child(
|
||||||
Palette::new("palette")
|
Palette::new("palette")
|
||||||
.items(vec![
|
.items(vec![
|
||||||
|
@ -50,7 +50,7 @@ mod stories {
|
||||||
Self
|
Self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, LanguageSelector>(cx))
|
.child(Story::title_for::<_, LanguageSelector>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
|
|
|
@ -55,7 +55,7 @@ impl ListHeader {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn disclosure_control<S: 'static>(&self) -> Div<S> {
|
fn disclosure_control<V: 'static>(&self) -> Div<V> {
|
||||||
let is_toggleable = self.toggleable != Toggleable::NotToggleable;
|
let is_toggleable = self.toggleable != Toggleable::NotToggleable;
|
||||||
let is_toggled = Toggleable::is_toggled(&self.toggleable);
|
let is_toggled = Toggleable::is_toggled(&self.toggleable);
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ impl ListHeader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
|
|
||||||
let is_toggleable = self.toggleable != Toggleable::NotToggleable;
|
let is_toggleable = self.toggleable != Toggleable::NotToggleable;
|
||||||
|
@ -151,7 +151,7 @@ impl ListSubHeader {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
h_stack().flex_1().w_full().relative().py_1().child(
|
h_stack().flex_1().w_full().relative().py_1().child(
|
||||||
div()
|
div()
|
||||||
.h_6()
|
.h_6()
|
||||||
|
@ -192,39 +192,39 @@ pub enum ListEntrySize {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub enum ListItem<S: 'static> {
|
pub enum ListItem<V: 'static> {
|
||||||
Entry(ListEntry),
|
Entry(ListEntry),
|
||||||
Details(ListDetailsEntry<S>),
|
Details(ListDetailsEntry<V>),
|
||||||
Separator(ListSeparator),
|
Separator(ListSeparator),
|
||||||
Header(ListSubHeader),
|
Header(ListSubHeader),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static> From<ListEntry> for ListItem<S> {
|
impl<V: 'static> From<ListEntry> for ListItem<V> {
|
||||||
fn from(entry: ListEntry) -> Self {
|
fn from(entry: ListEntry) -> Self {
|
||||||
Self::Entry(entry)
|
Self::Entry(entry)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static> From<ListDetailsEntry<S>> for ListItem<S> {
|
impl<V: 'static> From<ListDetailsEntry<V>> for ListItem<V> {
|
||||||
fn from(entry: ListDetailsEntry<S>) -> Self {
|
fn from(entry: ListDetailsEntry<V>) -> Self {
|
||||||
Self::Details(entry)
|
Self::Details(entry)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static> From<ListSeparator> for ListItem<S> {
|
impl<V: 'static> From<ListSeparator> for ListItem<V> {
|
||||||
fn from(entry: ListSeparator) -> Self {
|
fn from(entry: ListSeparator) -> Self {
|
||||||
Self::Separator(entry)
|
Self::Separator(entry)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static> From<ListSubHeader> for ListItem<S> {
|
impl<V: 'static> From<ListSubHeader> for ListItem<V> {
|
||||||
fn from(entry: ListSubHeader) -> Self {
|
fn from(entry: ListSubHeader) -> Self {
|
||||||
Self::Header(entry)
|
Self::Header(entry)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static> ListItem<S> {
|
impl<V: 'static> ListItem<V> {
|
||||||
fn render(self, view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render(self, view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
match self {
|
match self {
|
||||||
ListItem::Entry(entry) => div().child(entry.render(view, cx)),
|
ListItem::Entry(entry) => div().child(entry.render(view, cx)),
|
||||||
ListItem::Separator(separator) => div().child(separator.render(view, cx)),
|
ListItem::Separator(separator) => div().child(separator.render(view, cx)),
|
||||||
|
@ -361,7 +361,7 @@ impl ListEntry {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<S: 'static>(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<V: 'static>(mut self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
let settings = user_settings(cx);
|
let settings = user_settings(cx);
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
|
|
||||||
|
@ -417,29 +417,29 @@ impl ListEntry {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ListDetailsEntryHandlers<S: 'static> {
|
struct ListDetailsEntryHandlers<V: 'static> {
|
||||||
click: Option<ClickHandler<S>>,
|
click: Option<ClickHandler<V>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static> Default for ListDetailsEntryHandlers<S> {
|
impl<V: 'static> Default for ListDetailsEntryHandlers<V> {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self { click: None }
|
Self { click: None }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct ListDetailsEntry<S: 'static> {
|
pub struct ListDetailsEntry<V: 'static> {
|
||||||
label: SharedString,
|
label: SharedString,
|
||||||
meta: Option<SharedString>,
|
meta: Option<SharedString>,
|
||||||
left_content: Option<LeftContent>,
|
left_content: Option<LeftContent>,
|
||||||
handlers: ListDetailsEntryHandlers<S>,
|
handlers: ListDetailsEntryHandlers<V>,
|
||||||
actions: Option<Vec<Button<S>>>,
|
actions: Option<Vec<Button<V>>>,
|
||||||
// TODO: make this more generic instead of
|
// TODO: make this more generic instead of
|
||||||
// specifically for notifications
|
// specifically for notifications
|
||||||
seen: bool,
|
seen: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static> ListDetailsEntry<S> {
|
impl<V: 'static> ListDetailsEntry<V> {
|
||||||
pub fn new(label: impl Into<SharedString>) -> Self {
|
pub fn new(label: impl Into<SharedString>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
label: label.into(),
|
label: label.into(),
|
||||||
|
@ -461,17 +461,17 @@ impl<S: 'static> ListDetailsEntry<S> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn on_click(mut self, handler: ClickHandler<S>) -> Self {
|
pub fn on_click(mut self, handler: ClickHandler<V>) -> Self {
|
||||||
self.handlers.click = Some(handler);
|
self.handlers.click = Some(handler);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn actions(mut self, actions: Vec<Button<S>>) -> Self {
|
pub fn actions(mut self, actions: Vec<Button<V>>) -> Self {
|
||||||
self.actions = Some(actions);
|
self.actions = Some(actions);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
let settings = user_settings(cx);
|
let settings = user_settings(cx);
|
||||||
|
|
||||||
|
@ -531,15 +531,15 @@ impl ListSeparator {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct List<S: 'static> {
|
pub struct List<V: 'static> {
|
||||||
items: Vec<ListItem<S>>,
|
items: Vec<ListItem<V>>,
|
||||||
empty_message: SharedString,
|
empty_message: SharedString,
|
||||||
header: Option<ListHeader>,
|
header: Option<ListHeader>,
|
||||||
toggleable: Toggleable,
|
toggleable: Toggleable,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static> List<S> {
|
impl<V: 'static> List<V> {
|
||||||
pub fn new(items: Vec<ListItem<S>>) -> Self {
|
pub fn new(items: Vec<ListItem<V>>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
items,
|
items,
|
||||||
empty_message: "No items".into(),
|
empty_message: "No items".into(),
|
||||||
|
@ -563,7 +563,7 @@ impl<S: 'static> List<S> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
let is_toggleable = self.toggleable != Toggleable::NotToggleable;
|
let is_toggleable = self.toggleable != Toggleable::NotToggleable;
|
||||||
let is_toggled = Toggleable::is_toggled(&self.toggleable);
|
let is_toggled = Toggleable::is_toggled(&self.toggleable);
|
||||||
|
|
||||||
|
|
|
@ -4,15 +4,15 @@ use smallvec::SmallVec;
|
||||||
use crate::{h_stack, prelude::*, v_stack, Button, Icon, IconButton, Label};
|
use crate::{h_stack, prelude::*, v_stack, Button, Icon, IconButton, Label};
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct Modal<S: 'static> {
|
pub struct Modal<V: 'static> {
|
||||||
id: ElementId,
|
id: ElementId,
|
||||||
title: Option<SharedString>,
|
title: Option<SharedString>,
|
||||||
primary_action: Option<Button<S>>,
|
primary_action: Option<Button<V>>,
|
||||||
secondary_action: Option<Button<S>>,
|
secondary_action: Option<Button<V>>,
|
||||||
children: SmallVec<[AnyElement<S>; 2]>,
|
children: SmallVec<[AnyElement<V>; 2]>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static> Modal<S> {
|
impl<V: 'static> Modal<V> {
|
||||||
pub fn new(id: impl Into<ElementId>) -> Self {
|
pub fn new(id: impl Into<ElementId>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
id: id.into(),
|
id: id.into(),
|
||||||
|
@ -28,17 +28,17 @@ impl<S: 'static> Modal<S> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn primary_action(mut self, action: Button<S>) -> Self {
|
pub fn primary_action(mut self, action: Button<V>) -> Self {
|
||||||
self.primary_action = Some(action);
|
self.primary_action = Some(action);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn secondary_action(mut self, action: Button<S>) -> Self {
|
pub fn secondary_action(mut self, action: Button<V>) -> Self {
|
||||||
self.secondary_action = Some(action);
|
self.secondary_action = Some(action);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
|
|
||||||
v_stack()
|
v_stack()
|
||||||
|
@ -76,8 +76,8 @@ impl<S: 'static> Modal<S> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static> ParentElement<S> for Modal<S> {
|
impl<V: 'static> ParentElement<V> for Modal<V> {
|
||||||
fn children_mut(&mut self) -> &mut SmallVec<[AnyElement<S>; 2]> {
|
fn children_mut(&mut self) -> &mut SmallVec<[AnyElement<V>; 2]> {
|
||||||
&mut self.children
|
&mut self.children
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,10 +10,7 @@ pub struct NotificationToast {
|
||||||
|
|
||||||
impl NotificationToast {
|
impl NotificationToast {
|
||||||
pub fn new(label: SharedString) -> Self {
|
pub fn new(label: SharedString) -> Self {
|
||||||
Self {
|
Self { label, icon: None }
|
||||||
label,
|
|
||||||
icon: None,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn icon<I>(mut self, icon: I) -> Self
|
pub fn icon<I>(mut self, icon: I) -> Self
|
||||||
|
@ -24,7 +21,7 @@ impl NotificationToast {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
|
|
||||||
h_stack()
|
h_stack()
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
use crate::{prelude::*, static_new_notification_items, static_read_notification_items};
|
use crate::{prelude::*, static_new_notification_items, static_read_notification_items};
|
||||||
use crate::{List, ListHeader};
|
use crate::{List, ListHeader};
|
||||||
|
|
||||||
|
@ -9,12 +8,10 @@ pub struct NotificationsPanel {
|
||||||
|
|
||||||
impl NotificationsPanel {
|
impl NotificationsPanel {
|
||||||
pub fn new(id: impl Into<ElementId>) -> Self {
|
pub fn new(id: impl Into<ElementId>) -> Self {
|
||||||
Self {
|
Self { id: id.into() }
|
||||||
id: id.into(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
|
|
||||||
div()
|
div()
|
||||||
|
|
|
@ -42,7 +42,7 @@ impl Palette {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
|
|
||||||
v_stack()
|
v_stack()
|
||||||
|
@ -131,7 +131,7 @@ impl PaletteItem {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
div()
|
div()
|
||||||
.flex()
|
.flex()
|
||||||
.flex_row()
|
.flex_row()
|
||||||
|
|
|
@ -39,17 +39,17 @@ pub enum PanelSide {
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct Panel<S: 'static> {
|
pub struct Panel<V: 'static> {
|
||||||
id: ElementId,
|
id: ElementId,
|
||||||
current_side: PanelSide,
|
current_side: PanelSide,
|
||||||
/// Defaults to PanelAllowedSides::LeftAndRight
|
/// Defaults to PanelAllowedSides::LeftAndRight
|
||||||
allowed_sides: PanelAllowedSides,
|
allowed_sides: PanelAllowedSides,
|
||||||
initial_width: AbsoluteLength,
|
initial_width: AbsoluteLength,
|
||||||
width: Option<AbsoluteLength>,
|
width: Option<AbsoluteLength>,
|
||||||
children: SmallVec<[AnyElement<S>; 2]>,
|
children: SmallVec<[AnyElement<V>; 2]>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static> Panel<S> {
|
impl<V: 'static> Panel<V> {
|
||||||
pub fn new(id: impl Into<ElementId>, cx: &mut WindowContext) -> Self {
|
pub fn new(id: impl Into<ElementId>, cx: &mut WindowContext) -> Self {
|
||||||
let settings = user_settings(cx);
|
let settings = user_settings(cx);
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ impl<S: 'static> Panel<S> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
|
|
||||||
let current_size = self.width.unwrap_or(self.initial_width);
|
let current_size = self.width.unwrap_or(self.initial_width);
|
||||||
|
@ -117,8 +117,8 @@ impl<S: 'static> Panel<S> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static> ParentElement<S> for Panel<S> {
|
impl<V: 'static> ParentElement<V> for Panel<V> {
|
||||||
fn children_mut(&mut self) -> &mut SmallVec<[AnyElement<S>; 2]> {
|
fn children_mut(&mut self) -> &mut SmallVec<[AnyElement<V>; 2]> {
|
||||||
&mut self.children
|
&mut self.children
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,9 +140,9 @@ mod stories {
|
||||||
Self
|
Self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, Panel<S>>(cx))
|
.child(Story::title_for::<_, Panel<V>>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
.child(
|
.child(
|
||||||
Panel::new("panel", cx).child(
|
Panel::new("panel", cx).child(
|
||||||
|
|
|
@ -13,7 +13,7 @@ impl PlayerStack {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
let player = self.player_with_call_status.get_player();
|
let player = self.player_with_call_status.get_player();
|
||||||
self.player_with_call_status.get_call_status();
|
self.player_with_call_status.get_call_status();
|
||||||
|
|
|
@ -13,7 +13,7 @@ impl ProjectPanel {
|
||||||
Self { id: id.into() }
|
Self { id: id.into() }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
|
|
||||||
div()
|
div()
|
||||||
|
@ -69,7 +69,7 @@ mod stories {
|
||||||
Self
|
Self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, ProjectPanel>(cx))
|
.child(Story::title_for::<_, ProjectPanel>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
|
|
|
@ -11,7 +11,7 @@ impl RecentProjects {
|
||||||
Self { id: id.into() }
|
Self { id: id.into() }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
div().id(self.id.clone()).child(
|
div().id(self.id.clone()).child(
|
||||||
Palette::new("palette")
|
Palette::new("palette")
|
||||||
.items(vec![
|
.items(vec![
|
||||||
|
@ -46,7 +46,7 @@ mod stories {
|
||||||
Self
|
Self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, RecentProjects>(cx))
|
.child(Story::title_for::<_, RecentProjects>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
|
|
|
@ -23,7 +23,7 @@ impl TabBar {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
|
|
||||||
let (can_navigate_back, can_navigate_forward) = self.can_navigate;
|
let (can_navigate_back, can_navigate_forward) = self.can_navigate;
|
||||||
|
@ -104,7 +104,7 @@ mod stories {
|
||||||
Self
|
Self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, TabBar>(cx))
|
.child(Story::title_for::<_, TabBar>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
|
|
|
@ -11,7 +11,7 @@ impl Terminal {
|
||||||
Self
|
Self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
|
|
||||||
let can_navigate_back = true;
|
let can_navigate_back = true;
|
||||||
|
@ -95,7 +95,7 @@ mod stories {
|
||||||
Self
|
Self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, Terminal>(cx))
|
.child(Story::title_for::<_, Terminal>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
|
|
|
@ -11,7 +11,7 @@ impl ThemeSelector {
|
||||||
Self { id: id.into() }
|
Self { id: id.into() }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
div().child(
|
div().child(
|
||||||
Palette::new(self.id.clone())
|
Palette::new(self.id.clone())
|
||||||
.items(vec![
|
.items(vec![
|
||||||
|
@ -51,7 +51,7 @@ mod stories {
|
||||||
Self
|
Self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, ThemeSelector>(cx))
|
.child(Story::title_for::<_, ThemeSelector>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
|
|
|
@ -23,12 +23,12 @@ pub enum ToastOrigin {
|
||||||
///
|
///
|
||||||
/// Only one toast may be visible at a time.
|
/// Only one toast may be visible at a time.
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct Toast<S: 'static> {
|
pub struct Toast<V: 'static> {
|
||||||
origin: ToastOrigin,
|
origin: ToastOrigin,
|
||||||
children: SmallVec<[AnyElement<S>; 2]>,
|
children: SmallVec<[AnyElement<V>; 2]>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static> Toast<S> {
|
impl<V: 'static> Toast<V> {
|
||||||
pub fn new(origin: ToastOrigin) -> Self {
|
pub fn new(origin: ToastOrigin) -> Self {
|
||||||
Self {
|
Self {
|
||||||
origin,
|
origin,
|
||||||
|
@ -36,7 +36,7 @@ impl<S: 'static> Toast<S> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
|
|
||||||
let mut div = div();
|
let mut div = div();
|
||||||
|
@ -61,8 +61,8 @@ impl<S: 'static> Toast<S> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static> ParentElement<S> for Toast<S> {
|
impl<V: 'static> ParentElement<V> for Toast<V> {
|
||||||
fn children_mut(&mut self) -> &mut SmallVec<[AnyElement<S>; 2]> {
|
fn children_mut(&mut self) -> &mut SmallVec<[AnyElement<V>; 2]> {
|
||||||
&mut self.children
|
&mut self.children
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,9 +84,9 @@ mod stories {
|
||||||
Self
|
Self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, Toast<S>>(cx))
|
.child(Story::title_for::<_, Toast<V>>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
.child(Toast::new(ToastOrigin::Bottom).child(Label::new("label")))
|
.child(Toast::new(ToastOrigin::Bottom).child(Label::new("label")))
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,12 +7,12 @@ use crate::prelude::*;
|
||||||
pub struct ToolbarItem {}
|
pub struct ToolbarItem {}
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct Toolbar<S: 'static> {
|
pub struct Toolbar<V: 'static> {
|
||||||
left_items: SmallVec<[AnyElement<S>; 2]>,
|
left_items: SmallVec<[AnyElement<V>; 2]>,
|
||||||
right_items: SmallVec<[AnyElement<S>; 2]>,
|
right_items: SmallVec<[AnyElement<V>; 2]>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static> Toolbar<S> {
|
impl<V: 'static> Toolbar<V> {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
left_items: SmallVec::new(),
|
left_items: SmallVec::new(),
|
||||||
|
@ -20,7 +20,7 @@ impl<S: 'static> Toolbar<S> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn left_item(mut self, child: impl Component<S>) -> Self
|
pub fn left_item(mut self, child: impl Component<V>) -> Self
|
||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
{
|
{
|
||||||
|
@ -28,7 +28,7 @@ impl<S: 'static> Toolbar<S> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn left_items(mut self, iter: impl IntoIterator<Item = impl Component<S>>) -> Self
|
pub fn left_items(mut self, iter: impl IntoIterator<Item = impl Component<V>>) -> Self
|
||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
{
|
{
|
||||||
|
@ -37,7 +37,7 @@ impl<S: 'static> Toolbar<S> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn right_item(mut self, child: impl Component<S>) -> Self
|
pub fn right_item(mut self, child: impl Component<V>) -> Self
|
||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
{
|
{
|
||||||
|
@ -45,7 +45,7 @@ impl<S: 'static> Toolbar<S> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn right_items(mut self, iter: impl IntoIterator<Item = impl Component<S>>) -> Self
|
pub fn right_items(mut self, iter: impl IntoIterator<Item = impl Component<V>>) -> Self
|
||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
{
|
{
|
||||||
|
@ -54,7 +54,7 @@ impl<S: 'static> Toolbar<S> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
|
|
||||||
div()
|
div()
|
||||||
|
|
|
@ -21,7 +21,7 @@ impl TrafficLight {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
|
|
||||||
let fill = match (self.window_has_focus, self.color) {
|
let fill = match (self.window_has_focus, self.color) {
|
||||||
|
@ -52,7 +52,7 @@ impl TrafficLights {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
div()
|
div()
|
||||||
.flex()
|
.flex()
|
||||||
.items_center()
|
.items_center()
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use gpui2::Element;
|
use gpui2::Element;
|
||||||
|
|
||||||
pub trait ElementExt<S: 'static>: Element<S> {
|
pub trait ElementExt<V: 'static>: Element<V> {
|
||||||
// fn when(mut self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self
|
// fn when(mut self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self
|
||||||
// where
|
// where
|
||||||
// Self: Sized,
|
// Self: Sized,
|
||||||
|
|
|
@ -50,23 +50,23 @@ impl ButtonVariant {
|
||||||
|
|
||||||
pub type ClickHandler<S> = Arc<dyn Fn(&mut S, &mut ViewContext<S>) + Send + Sync>;
|
pub type ClickHandler<S> = Arc<dyn Fn(&mut S, &mut ViewContext<S>) + Send + Sync>;
|
||||||
|
|
||||||
struct ButtonHandlers<S: 'static> {
|
struct ButtonHandlers<V: 'static> {
|
||||||
click: Option<ClickHandler<S>>,
|
click: Option<ClickHandler<V>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl<S> Send for ButtonHandlers<S> {}
|
unsafe impl<S> Send for ButtonHandlers<S> {}
|
||||||
unsafe impl<S> Sync for ButtonHandlers<S> {}
|
unsafe impl<S> Sync for ButtonHandlers<S> {}
|
||||||
|
|
||||||
impl<S: 'static> Default for ButtonHandlers<S> {
|
impl<V: 'static> Default for ButtonHandlers<V> {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self { click: None }
|
Self { click: None }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct Button<S: 'static> {
|
pub struct Button<V: 'static> {
|
||||||
disabled: bool,
|
disabled: bool,
|
||||||
handlers: ButtonHandlers<S>,
|
handlers: ButtonHandlers<V>,
|
||||||
icon: Option<Icon>,
|
icon: Option<Icon>,
|
||||||
icon_position: Option<IconPosition>,
|
icon_position: Option<IconPosition>,
|
||||||
label: SharedString,
|
label: SharedString,
|
||||||
|
@ -74,7 +74,7 @@ pub struct Button<S: 'static> {
|
||||||
width: Option<DefiniteLength>,
|
width: Option<DefiniteLength>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static> Button<S> {
|
impl<V: 'static> Button<V> {
|
||||||
pub fn new(label: impl Into<SharedString>) -> Self {
|
pub fn new(label: impl Into<SharedString>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
disabled: false,
|
disabled: false,
|
||||||
|
@ -114,7 +114,7 @@ impl<S: 'static> Button<S> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn on_click(mut self, handler: ClickHandler<S>) -> Self {
|
pub fn on_click(mut self, handler: ClickHandler<V>) -> Self {
|
||||||
self.handlers.click = Some(handler);
|
self.handlers.click = Some(handler);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
@ -150,7 +150,7 @@ impl<S: 'static> Button<S> {
|
||||||
self.icon.map(|i| IconElement::new(i).color(icon_color))
|
self.icon.map(|i| IconElement::new(i).color(icon_color))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
pub fn render(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
let icon_color = self.icon_color();
|
let icon_color = self.icon_color();
|
||||||
|
|
||||||
let mut button = h_stack()
|
let mut button = h_stack()
|
||||||
|
|
|
@ -7,7 +7,7 @@ pub struct Details<V: 'static> {
|
||||||
actions: Option<ButtonGroup<V>>,
|
actions: Option<ButtonGroup<V>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static> Details<S> {
|
impl<V: 'static> Details<V> {
|
||||||
pub fn new(text: &'static str) -> Self {
|
pub fn new(text: &'static str) -> Self {
|
||||||
Self {
|
Self {
|
||||||
text,
|
text,
|
||||||
|
@ -21,12 +21,12 @@ impl<S: 'static> Details<S> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn actions(mut self, actions: ButtonGroup<S>) -> Self {
|
pub fn actions(mut self, actions: ButtonGroup<V>) -> Self {
|
||||||
self.actions = Some(actions);
|
self.actions = Some(actions);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
|
|
||||||
v_stack()
|
v_stack()
|
||||||
|
|
|
@ -56,7 +56,7 @@ impl Input {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
|
|
||||||
let (input_bg, input_hover_bg, input_active_bg) = match self.variant {
|
let (input_bg, input_hover_bg, input_active_bg) = match self.variant {
|
||||||
|
|
|
@ -138,12 +138,12 @@ impl Player {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn cursor_color<S: 'static>(&self, cx: &mut ViewContext<S>) -> Hsla {
|
pub fn cursor_color<V: 'static>(&self, cx: &mut ViewContext<V>) -> Hsla {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
theme.players[self.index].cursor
|
theme.players[self.index].cursor
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn selection_color<S: 'static>(&self, cx: &mut ViewContext<S>) -> Hsla {
|
pub fn selection_color<V: 'static>(&self, cx: &mut ViewContext<V>) -> Hsla {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
theme.players[self.index].selection
|
theme.players[self.index].selection
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,18 +14,18 @@ pub trait Stack: Styled + Sized {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static> Stack for Div<S> {}
|
impl<V: 'static> Stack for Div<V> {}
|
||||||
|
|
||||||
/// Horizontally stacks elements.
|
/// Horizontally stacks elements.
|
||||||
///
|
///
|
||||||
/// Sets `flex()`, `flex_row()`, `items_center()`
|
/// Sets `flex()`, `flex_row()`, `items_center()`
|
||||||
pub fn h_stack<S: 'static>() -> Div<S> {
|
pub fn h_stack<V: 'static>() -> Div<V> {
|
||||||
div().h_stack()
|
div().h_stack()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Vertically stacks elements.
|
/// Vertically stacks elements.
|
||||||
///
|
///
|
||||||
/// Sets `flex()`, `flex_col()`
|
/// Sets `flex()`, `flex_col()`
|
||||||
pub fn v_stack<S: 'static>() -> Div<S> {
|
pub fn v_stack<V: 'static>() -> Div<V> {
|
||||||
div().v_stack()
|
div().v_stack()
|
||||||
}
|
}
|
||||||
|
|
|
@ -325,7 +325,7 @@ pub fn static_players_with_call_status() -> Vec<PlayerWithCallStatus> {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn static_new_notification_items<S: 'static>() -> Vec<ListItem<S>> {
|
pub fn static_new_notification_items<V: 'static>() -> Vec<ListItem<V>> {
|
||||||
vec![
|
vec![
|
||||||
ListDetailsEntry::new("maxdeviant invited you to join a stream in #design.")
|
ListDetailsEntry::new("maxdeviant invited you to join a stream in #design.")
|
||||||
.meta("4 people in stream."),
|
.meta("4 people in stream."),
|
||||||
|
@ -336,7 +336,7 @@ pub fn static_new_notification_items<S: 'static>() -> Vec<ListItem<S>> {
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn static_read_notification_items<S: 'static>() -> Vec<ListItem<S>> {
|
pub fn static_read_notification_items<V: 'static>() -> Vec<ListItem<V>> {
|
||||||
vec![
|
vec![
|
||||||
ListDetailsEntry::new("mikaylamaki added you as a contact.").actions(vec![
|
ListDetailsEntry::new("mikaylamaki added you as a contact.").actions(vec![
|
||||||
Button::new("Decline"),
|
Button::new("Decline"),
|
||||||
|
@ -352,7 +352,7 @@ pub fn static_read_notification_items<S: 'static>() -> Vec<ListItem<S>> {
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn static_project_panel_project_items<S: 'static>() -> Vec<ListItem<S>> {
|
pub fn static_project_panel_project_items<V: 'static>() -> Vec<ListItem<V>> {
|
||||||
vec![
|
vec![
|
||||||
ListEntry::new(Label::new("zed"))
|
ListEntry::new(Label::new("zed"))
|
||||||
.left_icon(Icon::FolderOpen.into())
|
.left_icon(Icon::FolderOpen.into())
|
||||||
|
@ -479,7 +479,7 @@ pub fn static_project_panel_project_items<S: 'static>() -> Vec<ListItem<S>> {
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn static_project_panel_single_items<S: 'static>() -> Vec<ListItem<S>> {
|
pub fn static_project_panel_single_items<V: 'static>() -> Vec<ListItem<V>> {
|
||||||
vec![
|
vec![
|
||||||
ListEntry::new(Label::new("todo.md"))
|
ListEntry::new(Label::new("todo.md"))
|
||||||
.left_icon(Icon::FileDoc.into())
|
.left_icon(Icon::FileDoc.into())
|
||||||
|
@ -496,7 +496,7 @@ pub fn static_project_panel_single_items<S: 'static>() -> Vec<ListItem<S>> {
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn static_collab_panel_current_call<S: 'static>() -> Vec<ListItem<S>> {
|
pub fn static_collab_panel_current_call<V: 'static>() -> Vec<ListItem<V>> {
|
||||||
vec![
|
vec![
|
||||||
ListEntry::new(Label::new("as-cii")).left_avatar("http://github.com/as-cii.png?s=50"),
|
ListEntry::new(Label::new("as-cii")).left_avatar("http://github.com/as-cii.png?s=50"),
|
||||||
ListEntry::new(Label::new("nathansobo"))
|
ListEntry::new(Label::new("nathansobo"))
|
||||||
|
@ -509,7 +509,7 @@ pub fn static_collab_panel_current_call<S: 'static>() -> Vec<ListItem<S>> {
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn static_collab_panel_channels<S: 'static>() -> Vec<ListItem<S>> {
|
pub fn static_collab_panel_channels<V: 'static>() -> Vec<ListItem<V>> {
|
||||||
vec![
|
vec![
|
||||||
ListEntry::new(Label::new("zed"))
|
ListEntry::new(Label::new("zed"))
|
||||||
.left_icon(Icon::Hash.into())
|
.left_icon(Icon::Hash.into())
|
||||||
|
|
|
@ -5,7 +5,7 @@ use crate::prelude::*;
|
||||||
pub struct Story {}
|
pub struct Story {}
|
||||||
|
|
||||||
impl Story {
|
impl Story {
|
||||||
pub fn container<S: 'static>(cx: &mut ViewContext<S>) -> Div<S> {
|
pub fn container<V: 'static>(cx: &mut ViewContext<V>) -> Div<V> {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
|
|
||||||
div()
|
div()
|
||||||
|
@ -18,10 +18,7 @@ impl Story {
|
||||||
.bg(theme.background)
|
.bg(theme.background)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn title<S: 'static>(
|
pub fn title<V: 'static>(cx: &mut ViewContext<V>, title: &str) -> impl Component<V> {
|
||||||
cx: &mut ViewContext<S>,
|
|
||||||
title: &str,
|
|
||||||
) -> impl Component<S> {
|
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
|
|
||||||
div()
|
div()
|
||||||
|
@ -30,14 +27,11 @@ impl Story {
|
||||||
.child(title.to_owned())
|
.child(title.to_owned())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn title_for<S: 'static, T>(cx: &mut ViewContext<S>) -> impl Component<S> {
|
pub fn title_for<V: 'static, T>(cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
Self::title(cx, std::any::type_name::<T>())
|
Self::title(cx, std::any::type_name::<T>())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn label<S: 'static>(
|
pub fn label<V: 'static>(cx: &mut ViewContext<V>, label: &str) -> impl Component<V> {
|
||||||
cx: &mut ViewContext<S>,
|
|
||||||
label: &str,
|
|
||||||
) -> impl Component<S> {
|
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
|
|
||||||
div()
|
div()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue