gpui-component/crates/story/examples/table.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
716 B
Rust

use gpui::*;
use story::{Assets, TableStory};
pub struct Example {
table: View<TableStory>,
}
impl Example {
pub fn new(cx: &mut ViewContext<Self>) -> Self {
let table = TableStory::view(cx);
Self { table }
}
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.table.clone())
}
}
fn main() {
let app = App::new().with_assets(Assets);
app.run(move |cx| {
story::init(cx);
cx.activate(true);
story::create_new_window("Table Example", Example::view, cx);
});
}