gpui-component/crates/story/examples/button.rs
Jason Lee c9c6449d24
toggle: Add Toggle and ToggleGroup. (#691)
- Improve `Icon` to inherit parent element font size by default.

<img width="777" alt="image"
src="https://github.com/user-attachments/assets/1a0ee94e-46ef-4b02-9538-09880586d3f2"
/>
<img width="777" alt="image"
src="https://github.com/user-attachments/assets/4ecb016f-2e7c-4266-9a25-eae2566b2844"
/>
2025-03-06 19:10:28 +08:00

35 lines
796 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().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);
});
}