Checkpoint

This commit is contained in:
Nathan Sobo 2023-11-14 01:15:48 -07:00
parent ce30a689a0
commit 27fb381cca
82 changed files with 661 additions and 1907 deletions

View file

@ -44,12 +44,12 @@ pub use stories::*;
mod stories {
use super::*;
use crate::Story;
use gpui::{Div, Render};
use gpui::{Node, Render};
pub struct AvatarStory;
impl Render for AvatarStory {
type Element = Div<Self>;
type Element = Node<Self>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
Story::container(cx)

View file

@ -1,6 +1,6 @@
use std::sync::Arc;
use gpui::{div, DefiniteLength, Hsla, MouseButton, WindowContext};
use gpui::{div, DefiniteLength, Hsla, MouseButton, StatefulInteractiveComponent, WindowContext};
use crate::{
h_stack, prelude::*, Icon, IconButton, IconColor, IconElement, Label, LabelColor,
@ -236,13 +236,13 @@ pub use stories::*;
mod stories {
use super::*;
use crate::{h_stack, v_stack, LabelColor, Story};
use gpui::{rems, Div, Render};
use gpui::{rems, Node, Render};
use strum::IntoEnumIterator;
pub struct ButtonStory;
impl Render for ButtonStory {
type Element = Div<Self>;
type Element = Node<Self>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
let states = InteractionState::iter();

View file

@ -1,9 +1,5 @@
use gpui::{div, prelude::*, Component, ElementId, Styled, ViewContext};
use std::sync::Arc;
use gpui::{
div, Component, ElementId, ParentElement, StatefulInteractive, StatelessInteractive, Styled,
ViewContext,
};
use theme2::ActiveTheme;
use crate::{Icon, IconColor, IconElement, Selection};
@ -175,12 +171,12 @@ pub use stories::*;
mod stories {
use super::*;
use crate::{h_stack, Story};
use gpui::{Div, Render};
use gpui::{Node, Render};
pub struct CheckboxStory;
impl Render for CheckboxStory {
type Element = Div<Self>;
type Element = Node<Self>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
Story::container(cx)

View file

@ -65,12 +65,12 @@ pub use stories::*;
mod stories {
use super::*;
use crate::story::Story;
use gpui::{Div, Render};
use gpui::{Node, Render};
pub struct ContextMenuStory;
impl Render for ContextMenuStory {
type Element = Div<Self>;
type Element = Node<Self>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
Story::container(cx)

View file

@ -47,12 +47,12 @@ pub use stories::*;
mod stories {
use super::*;
use crate::{Button, Story};
use gpui::{Div, Render};
use gpui::{Node, Render};
pub struct DetailsStory;
impl Render for DetailsStory {
type Element = Div<Self>;
type Element = Node<Self>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
Story::container(cx)

View file

@ -1,11 +1,11 @@
use gpui::Div;
use gpui::Node;
use crate::{prelude::*, v_stack};
/// Create an elevated surface.
///
/// Must be used inside of a relative parent element
pub fn elevated_surface<V: 'static>(level: ElevationIndex, cx: &mut ViewContext<V>) -> Div<V> {
pub fn elevated_surface<V: 'static>(level: ElevationIndex, cx: &mut ViewContext<V>) -> Node<V> {
let colors = cx.theme().colors();
// let shadow = BoxShadow {
@ -23,6 +23,6 @@ pub fn elevated_surface<V: 'static>(level: ElevationIndex, cx: &mut ViewContext<
.shadow(level.shadow())
}
pub fn modal<V>(cx: &mut ViewContext<V>) -> Div<V> {
pub fn modal<V: 'static>(cx: &mut ViewContext<V>) -> Node<V> {
elevated_surface(ElevationIndex::ModalSurface, cx)
}

View file

@ -33,12 +33,12 @@ pub use stories::*;
mod stories {
use super::*;
use crate::{static_players, Story};
use gpui::{Div, Render};
use gpui::{Node, Render};
pub struct FacepileStory;
impl Render for FacepileStory {
type Element = Div<Self>;
type Element = Node<Self>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
let players = static_players();

View file

@ -204,7 +204,7 @@ pub use stories::*;
#[cfg(feature = "stories")]
mod stories {
use gpui::{Div, Render};
use gpui::{Node, Render};
use strum::IntoEnumIterator;
use crate::Story;
@ -214,7 +214,7 @@ mod stories {
pub struct IconStory;
impl Render for IconStory {
type Element = Div<Self>;
type Element = Node<Self>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
let icons = Icon::iter();

View file

@ -1,9 +1,7 @@
use std::sync::Arc;
use gpui::{rems, MouseButton};
use crate::{h_stack, prelude::*};
use crate::{ClickHandler, Icon, IconColor, IconElement};
use gpui::{prelude::*, rems, MouseButton};
use std::sync::Arc;
struct IconButtonHandlers<V: 'static> {
click: Option<ClickHandler<V>>,

View file

@ -1,6 +1,5 @@
use crate::prelude::*;
use crate::Label;
use crate::LabelColor;
use crate::{prelude::*, Label, LabelColor};
use gpui::prelude::*;
#[derive(Default, PartialEq)]
pub enum InputVariant {
@ -111,12 +110,12 @@ pub use stories::*;
mod stories {
use super::*;
use crate::Story;
use gpui::{Div, Render};
use gpui::{Node, Render};
pub struct InputStory;
impl Render for InputStory {
type Element = Div<Self>;
type Element = Node<Self>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
Story::container(cx)

View file

@ -158,13 +158,13 @@ pub use stories::*;
mod stories {
use super::*;
use crate::Story;
use gpui::{Div, Render};
use gpui::{Node, Render};
use itertools::Itertools;
pub struct KeybindingStory;
impl Render for KeybindingStory {
type Element = Div<Self>;
type Element = Node<Self>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
let all_modifier_permutations = ModifierKey::iter().permutations(2);

View file

@ -196,12 +196,12 @@ pub use stories::*;
mod stories {
use super::*;
use crate::Story;
use gpui::{Div, Render};
use gpui::{Node, Render};
pub struct LabelStory;
impl Render for LabelStory {
type Element = Div<Self>;
type Element = Node<Self>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
Story::container(cx)

View file

@ -74,7 +74,7 @@ impl<V: 'static> Modal<V> {
}
}
impl<V: 'static> ParentElement<V> for Modal<V> {
impl<V: 'static> ParentComponent<V> for Modal<V> {
fn children_mut(&mut self) -> &mut SmallVec<[AnyElement<V>; 2]> {
&mut self.children
}

View file

@ -1,5 +1,5 @@
use crate::prelude::*;
use crate::{h_stack, v_stack, Keybinding, Label, LabelColor};
use crate::{h_stack, prelude::*, v_stack, Keybinding, Label, LabelColor};
use gpui::prelude::*;
#[derive(Component)]
pub struct Palette {
@ -159,7 +159,7 @@ pub use stories::*;
#[cfg(feature = "stories")]
mod stories {
use gpui::{Div, Render};
use gpui::{Node, Render};
use crate::{ModifierKeys, Story};
@ -168,7 +168,7 @@ mod stories {
pub struct PaletteStory;
impl Render for PaletteStory {
type Element = Div<Self>;
type Element = Node<Self>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
{

View file

@ -1,4 +1,4 @@
use gpui::{AbsoluteLength, AnyElement};
use gpui::{prelude::*, AbsoluteLength, AnyElement};
use smallvec::SmallVec;
use crate::prelude::*;
@ -113,7 +113,7 @@ impl<V: 'static> Panel<V> {
}
}
impl<V: 'static> ParentElement<V> for Panel<V> {
impl<V: 'static> ParentComponent<V> for Panel<V> {
fn children_mut(&mut self) -> &mut SmallVec<[AnyElement<V>; 2]> {
&mut self.children
}
@ -126,12 +126,12 @@ pub use stories::*;
mod stories {
use super::*;
use crate::{Label, Story};
use gpui::{Div, Render};
use gpui::{InteractiveComponent, Node, Render};
pub struct PanelStory;
impl Render for PanelStory {
type Element = Div<Self>;
type Element = Node<Self>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
Story::container(cx)

View file

@ -1,17 +1,17 @@
use gpui::{div, Div};
use gpui::{div, Node};
use crate::StyledExt;
/// Horizontally stacks elements.
///
/// Sets `flex()`, `flex_row()`, `items_center()`
pub fn h_stack<V: 'static>() -> Div<V> {
pub fn h_stack<V: 'static>() -> Node<V> {
div().h_flex()
}
/// Vertically stacks elements.
///
/// Sets `flex()`, `flex_col()`
pub fn v_stack<V: 'static>() -> Div<V> {
pub fn v_stack<V: 'static>() -> Node<V> {
div().v_flex()
}

View file

@ -1,6 +1,6 @@
use crate::prelude::*;
use crate::{Icon, IconColor, IconElement, Label, LabelColor};
use gpui::{red, Div, ElementId, Render, View, VisualContext};
use gpui::{prelude::*, red, ElementId, Node, Render, View};
#[derive(Component, Clone)]
pub struct Tab {
@ -21,7 +21,7 @@ struct TabDragState {
}
impl Render for TabDragState {
type Element = Div<Self>;
type Element = Node<Self>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
div().w_8().h_4().bg(red())
@ -178,7 +178,7 @@ mod stories {
pub struct TabStory;
impl Render for TabStory {
type Element = Div<Self>;
type Element = Node<Self>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
let git_statuses = GitStatus::iter();

View file

@ -1,7 +1,6 @@
use gpui::AnyElement;
use smallvec::SmallVec;
use crate::prelude::*;
use gpui::{prelude::*, AnyElement};
use smallvec::SmallVec;
#[derive(Default, Debug, PartialEq, Eq, Clone, Copy)]
pub enum ToastOrigin {
@ -59,7 +58,7 @@ impl<V: 'static> Toast<V> {
}
}
impl<V: 'static> ParentElement<V> for Toast<V> {
impl<V: 'static> ParentComponent<V> for Toast<V> {
fn children_mut(&mut self) -> &mut SmallVec<[AnyElement<V>; 2]> {
&mut self.children
}
@ -70,7 +69,7 @@ pub use stories::*;
#[cfg(feature = "stories")]
mod stories {
use gpui::{Div, Render};
use gpui::{Node, Render};
use crate::{Label, Story};
@ -79,7 +78,7 @@ mod stories {
pub struct ToastStory;
impl Render for ToastStory {
type Element = Div<Self>;
type Element = Node<Self>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
Story::container(cx)

View file

@ -1,4 +1,4 @@
use gpui::{div, Component, ParentElement};
use gpui::{div, Component, ParentComponent};
use crate::{Icon, IconColor, IconElement, IconSize};

View file

@ -1,4 +1,4 @@
use gpui::{div, Div, ParentElement, Render, SharedString, Styled, ViewContext};
use gpui::{div, Node, ParentComponent, Render, SharedString, Styled, ViewContext};
use theme2::ActiveTheme;
#[derive(Clone, Debug)]
@ -13,7 +13,7 @@ impl TextTooltip {
}
impl Render for TextTooltip {
type Element = Div<Self>;
type Element = Node<Self>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
let theme = cx.theme();