
The `ComponentPreview` trait enables rendering storybook-like previews of components inside of Zed.  This initial version will work for any component that doesn't return a view. Example impl: ```rust impl ComponentPreview for Checkbox { fn description() -> impl Into<Option<&'static str>> { "A checkbox lets people choose between opposing..." } fn examples() -> Vec<ComponentExampleGroup<Self>> { vec![ example_group( "Default", vec![ single_example( "Unselected", Checkbox::new("checkbox_unselected", Selection::Unselected), ), // ... more examples ], ), // ... more examples ] } } ``` Example usage: ```rust fn render_components_page(&self, cx: &ViewContext<Self>) -> impl IntoElement { v_flex() .gap_2() .child(Checkbox::render_component_previews(cx)) .child(Icon::render_component_previews(cx)) } } ``` Release Notes: - N/A
7 lines
148 B
Rust
7 lines
148 B
Rust
pub mod clickable;
|
|
pub mod component_preview;
|
|
pub mod disableable;
|
|
pub mod fixed;
|
|
pub mod selectable;
|
|
pub mod styled_ext;
|
|
pub mod visible_on_hover;
|