Add more example for buttons.
This commit is contained in:
parent
483d199c45
commit
0d1b1aa784
2 changed files with 27 additions and 12 deletions
|
|
@ -118,7 +118,7 @@ impl Clickable for Button {
|
|||
|
||||
impl RenderOnce for Button {
|
||||
fn render(self, cx: &mut WindowContext) -> impl IntoElement {
|
||||
let style = self.style;
|
||||
let style: ButtonStyle = self.style;
|
||||
let normal_style = style.normal(cx);
|
||||
|
||||
self.base
|
||||
|
|
@ -277,21 +277,36 @@ impl RenderOnce for ButtonPreview {
|
|||
.child(
|
||||
Button::new("button-4", "Danger Button")
|
||||
.style(ButtonStyle::Danger)
|
||||
.on_click(Self::on_click)
|
||||
.render(cx),
|
||||
)
|
||||
.child(
|
||||
Button::new("button-5", "Disabled Button")
|
||||
.style(ButtonStyle::Primary)
|
||||
.on_click(Self::on_click)
|
||||
.disabled(true)
|
||||
.render(cx),
|
||||
.on_click(Self::on_click),
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.flex()
|
||||
.items_center()
|
||||
.gap_3()
|
||||
.child(
|
||||
Button::new("button-disabled1", "Disabled Button")
|
||||
.style(ButtonStyle::Primary)
|
||||
.on_click(Self::on_click)
|
||||
.disabled(true),
|
||||
)
|
||||
.child(
|
||||
Button::new("button-disabled1", "Disabled Button")
|
||||
.style(ButtonStyle::Secondary)
|
||||
.on_click(Self::on_click)
|
||||
.disabled(true),
|
||||
)
|
||||
.child(
|
||||
Button::new("button-disabled1", "Disabled Button")
|
||||
.style(ButtonStyle::Danger)
|
||||
.on_click(Self::on_click)
|
||||
.disabled(true),
|
||||
),
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.flex()
|
||||
.items_center()
|
||||
.justify_center()
|
||||
.gap_3()
|
||||
.child(
|
||||
Button::new("button-6", "Primary Button")
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ impl Workspace {
|
|||
app_state: Arc<AppState>,
|
||||
cx: &mut AppContext,
|
||||
) -> Task<anyhow::Result<WindowHandle<Workspace>>> {
|
||||
let window_bounds = Bounds::centered(None, size(px(800.0), px(600.0)), cx);
|
||||
let window_bounds = Bounds::centered(None, size(px(1200.0), px(900.0)), cx);
|
||||
|
||||
cx.spawn(|mut cx| async move {
|
||||
let options = WindowOptions {
|
||||
|
|
|
|||
Loading…
Reference in a new issue