gpui-component/crates/story/examples/list.rs
Jason Lee 878a51e5a9
example: Split single examples. (#574)
```bash
cargo run --example table
cargo run --example list
```
2025-01-24 11:13:24 +08:00

35 lines
708 B
Rust

use gpui::*;
use story::{Assets, ListStory};
pub struct Example {
root: View<ListStory>,
}
impl Example {
pub fn new(cx: &mut ViewContext<Self>) -> Self {
let root = ListStory::view(cx);
Self { root }
}
fn view(cx: &mut WindowContext) -> View<Self> {
cx.new_view(Self::new)
}
}
impl Render for Example {
fn render(&mut self, _: &mut ViewContext<Self>) -> impl IntoElement {
div().p_4().size_full().child(self.root.clone())
}
}
fn main() {
let app = App::new().with_assets(Assets);
app.run(move |cx| {
story::init(cx);
cx.activate(true);
story::create_new_window("List Example", Example::view, cx);
});
}