Add Facepile and PlayerStack components

This commit is contained in:
Marshall Bowers 2023-10-07 12:02:42 -04:00
parent 5e7954f152
commit f33d41af63
9 changed files with 314 additions and 2 deletions

View file

@ -2,6 +2,7 @@ pub mod assistant_panel;
pub mod breadcrumb;
pub mod buffer;
pub mod chat_panel;
pub mod facepile;
pub mod panel;
pub mod project_panel;
pub mod tab;

View file

@ -0,0 +1,35 @@
use std::marker::PhantomData;
use ui::prelude::*;
use ui::{static_players, Facepile};
use crate::story::Story;
#[derive(Element)]
pub struct FacepileStory<S: 'static + Send + Sync> {
state_type: PhantomData<S>,
}
impl<S: 'static + Send + Sync> FacepileStory<S> {
pub fn new() -> Self {
Self {
state_type: PhantomData,
}
}
fn render(&mut self, cx: &mut ViewContext<S>) -> impl Element<State = S> {
let players = static_players();
Story::container(cx)
.child(Story::title_for::<_, Facepile<S>>(cx))
.child(Story::label(cx, "Default"))
.child(
div()
.flex()
.gap_3()
.child(Facepile::new(players.clone().into_iter().take(1)))
.child(Facepile::new(players.clone().into_iter().take(2)))
.child(Facepile::new(players.clone().into_iter().take(3))),
)
}
}

View file

@ -40,6 +40,7 @@ pub enum ComponentStory {
Breadcrumb,
Buffer,
ChatPanel,
Facepile,
Panel,
ProjectPanel,
Tab,
@ -61,6 +62,7 @@ impl ComponentStory {
Self::Buffer => components::buffer::BufferStory::new().into_any(),
Self::Breadcrumb => components::breadcrumb::BreadcrumbStory::new().into_any(),
Self::ChatPanel => components::chat_panel::ChatPanelStory::new().into_any(),
Self::Facepile => components::facepile::FacepileStory::new().into_any(),
Self::Panel => components::panel::PanelStory::new().into_any(),
Self::ProjectPanel => components::project_panel::ProjectPanelStory::new().into_any(),
Self::Tab => components::tab::TabStory::new().into_any(),