gpui-component/crates/story/examples/button.rs
Michael Angerman eb9a0ed881
chore: Fix button example so that it scrolls in the y direction (#999)
The button example was not scrolling in the y direction and therefore
you were *NOT* able to see the entire ButtonStory.

This minor fix now enables one to see the entire ButtonStory.

The only code that needed to be added was

```rust
            .id("button_example")
            .overflow_y_scroll()
```
2025-06-24 11:54:51 +08:00

40 lines
902 B
Rust

use gpui::*;
use story::{Assets, ButtonStory};
pub struct Example {
root: Entity<ButtonStory>,
}
impl Example {
pub fn new(window: &mut Window, cx: &mut Context<Self>) -> Self {
let root = ButtonStory::view(window, cx);
Self { root }
}
fn view(window: &mut Window, cx: &mut App) -> Entity<Self> {
cx.new(|cx| Self::new(window, cx))
}
}
impl Render for Example {
fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
div()
.p_4()
.id("button_example")
.overflow_y_scroll()
.size_full()
.child(self.root.clone())
}
}
fn main() {
let app = Application::new().with_assets(Assets);
app.run(move |cx| {
story::init(cx);
cx.activate(true);
story::create_new_window("Button Example", Example::view, cx);
});
}