audit button

This commit is contained in:
2026-11-07 15:16:25 +07:00
parent d696b1e707
commit fd36ada35e
7 changed files with 157 additions and 314 deletions
+60 -9
View File
@@ -879,24 +879,75 @@ impl Render for ButtonDemo {
button = button.tooltip(Tooltip::text("Removes the selected item"));
}
button
}))
})),
))
.child(demo_section(
"icon + label",
colors,
h_flex()
.flex_wrap()
.gap_2()
.children(variants.map(|(name, variant)| {
let view = view.clone();
let mut button =
Button::new(SharedString::from(format!("button-demo-icon-{name}")))
.label(button_label(variant))
.icon(IconRole::Folder)
.variant(variant)
.on_click(move |_, _, cx| {
view.update(cx, |demo, cx| {
demo.clicks += 1;
cx.notify();
});
});
if variant == ButtonVariant::Destructive {
button = button.tooltip(Tooltip::text("Removes the selected item"));
}
button
})),
))
.child(demo_section(
"icon only",
colors,
h_flex()
.flex_wrap()
.gap_2()
.children(variants.map(|(name, variant)| {
let view = view.clone();
Button::new(SharedString::from(format!("button-demo-icon-only-{name}")))
.icon(IconRole::Folder)
.variant(variant)
.accessibility_label("Open the selected file")
.tooltip(Tooltip::text("Opens the selected file"))
.on_click(move |_, _, cx| {
view.update(cx, |demo, cx| {
demo.clicks += 1;
cx.notify();
});
})
})),
))
.child(demo_section(
"states",
colors,
h_flex()
.flex_wrap()
.gap_2()
.child(
Button::new("button-demo-disabled")
.label("Disabled")
.disabled(true),
)
.child(
Button::new("button-demo-icon")
.label("Open")
.icon(IconRole::Folder)
.tooltip(Tooltip::text("Opens the selected file")),
Button::new("button-demo-loading")
.label("Saving")
.loading(true),
)
.child(
Button::new("button-demo-icon-only")
Button::new("button-demo-loading-icon-only")
.icon(IconRole::Folder)
.variant(ButtonVariant::Ghost)
.accessibility_label("Open the selected file")
.tooltip(Tooltip::text("Opens the selected file")),
.accessibility_label("Saving the selected file")
.loading(true),
),
))
.child(demo_section(