Add CommandPalette component

This commit is contained in:
Marshall Bowers 2023-10-09 11:20:10 -04:00
parent e5473fc51a
commit f7721d0523
6 changed files with 121 additions and 3 deletions

View file

@ -3,6 +3,7 @@ pub mod breadcrumb;
pub mod buffer;
pub mod chat_panel;
pub mod collab_panel;
pub mod command_palette;
pub mod facepile;
pub mod keybinding;
pub mod palette;

View file

@ -0,0 +1,26 @@
use std::marker::PhantomData;
use ui::prelude::*;
use ui::CommandPalette;
use crate::story::Story;
#[derive(Element)]
pub struct CommandPaletteStory<S: 'static + Send + Sync + Clone> {
state_type: PhantomData<S>,
}
impl<S: 'static + Send + Sync + Clone> CommandPaletteStory<S> {
pub fn new() -> Self {
Self {
state_type: PhantomData,
}
}
fn render(&mut self, cx: &mut ViewContext<S>) -> impl Element<State = S> {
Story::container(cx)
.child(Story::title_for::<_, CommandPalette<S>>(cx))
.child(Story::label(cx, "Default"))
.child(CommandPalette::new(ScrollState::default()))
}
}

View file

@ -41,6 +41,7 @@ pub enum ComponentStory {
Buffer,
ChatPanel,
CollabPanel,
CommandPalette,
Facepile,
Keybinding,
Palette,
@ -67,6 +68,9 @@ impl ComponentStory {
Self::Breadcrumb => components::breadcrumb::BreadcrumbStory::new().into_any(),
Self::ChatPanel => components::chat_panel::ChatPanelStory::new().into_any(),
Self::CollabPanel => components::collab_panel::CollabPanelStory::new().into_any(),
Self::CommandPalette => {
components::command_palette::CommandPaletteStory::new().into_any()
}
Self::Facepile => components::facepile::FacepileStory::new().into_any(),
Self::Keybinding => components::keybinding::KeybindingStory::new().into_any(),
Self::Palette => components::palette::PaletteStory::new().into_any(),