Add Toast
component
This commit is contained in:
parent
333e3e4f01
commit
02d32de044
6 changed files with 122 additions and 0 deletions
|
@ -14,6 +14,7 @@ pub mod tab;
|
|||
pub mod tab_bar;
|
||||
pub mod terminal;
|
||||
pub mod title_bar;
|
||||
pub mod toast;
|
||||
pub mod toolbar;
|
||||
pub mod traffic_lights;
|
||||
pub mod workspace;
|
||||
|
|
31
crates/storybook2/src/stories/components/toast.rs
Normal file
31
crates/storybook2/src/stories/components/toast.rs
Normal file
|
@ -0,0 +1,31 @@
|
|||
use std::marker::PhantomData;
|
||||
use std::sync::Arc;
|
||||
|
||||
use ui::prelude::*;
|
||||
use ui::{Label, Toast, ToastOrigin};
|
||||
|
||||
use crate::story::Story;
|
||||
|
||||
#[derive(Element)]
|
||||
pub struct ToastStory<S: 'static + Send + Sync + Clone> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
||||
impl<S: 'static + Send + Sync + Clone> ToastStory<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::<_, Toast<S>>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
.child(Toast::new(
|
||||
ToastOrigin::Bottom,
|
||||
|_, _| vec![Label::new("label").into_any()],
|
||||
Box::new(()),
|
||||
))
|
||||
}
|
||||
}
|
|
@ -52,6 +52,7 @@ pub enum ComponentStory {
|
|||
TabBar,
|
||||
Terminal,
|
||||
TitleBar,
|
||||
Toast,
|
||||
Toolbar,
|
||||
TrafficLights,
|
||||
Workspace,
|
||||
|
@ -82,6 +83,7 @@ impl ComponentStory {
|
|||
Self::TabBar => components::tab_bar::TabBarStory::new().into_any(),
|
||||
Self::Terminal => components::terminal::TerminalStory::new().into_any(),
|
||||
Self::TitleBar => components::title_bar::TitleBarStory::new().into_any(),
|
||||
Self::Toast => components::toast::ToastStory::new().into_any(),
|
||||
Self::Toolbar => components::toolbar::ToolbarStory::new().into_any(),
|
||||
Self::TrafficLights => components::traffic_lights::TrafficLightsStory::new().into_any(),
|
||||
Self::Workspace => components::workspace::WorkspaceStory::new().into_any(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue