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 {
|
impl RenderOnce for Button {
|
||||||
fn render(self, cx: &mut WindowContext) -> impl IntoElement {
|
fn render(self, cx: &mut WindowContext) -> impl IntoElement {
|
||||||
let style = self.style;
|
let style: ButtonStyle = self.style;
|
||||||
let normal_style = style.normal(cx);
|
let normal_style = style.normal(cx);
|
||||||
|
|
||||||
self.base
|
self.base
|
||||||
|
|
@ -277,21 +277,36 @@ impl RenderOnce for ButtonPreview {
|
||||||
.child(
|
.child(
|
||||||
Button::new("button-4", "Danger Button")
|
Button::new("button-4", "Danger Button")
|
||||||
.style(ButtonStyle::Danger)
|
.style(ButtonStyle::Danger)
|
||||||
.on_click(Self::on_click)
|
.on_click(Self::on_click),
|
||||||
.render(cx),
|
)
|
||||||
)
|
.child(
|
||||||
.child(
|
div()
|
||||||
Button::new("button-5", "Disabled Button")
|
.flex()
|
||||||
.style(ButtonStyle::Primary)
|
.items_center()
|
||||||
.on_click(Self::on_click)
|
.gap_3()
|
||||||
.disabled(true)
|
.child(
|
||||||
.render(cx),
|
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(
|
.child(
|
||||||
div()
|
div()
|
||||||
.flex()
|
.flex()
|
||||||
.items_center()
|
.items_center()
|
||||||
.justify_center()
|
|
||||||
.gap_3()
|
.gap_3()
|
||||||
.child(
|
.child(
|
||||||
Button::new("button-6", "Primary Button")
|
Button::new("button-6", "Primary Button")
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ impl Workspace {
|
||||||
app_state: Arc<AppState>,
|
app_state: Arc<AppState>,
|
||||||
cx: &mut AppContext,
|
cx: &mut AppContext,
|
||||||
) -> Task<anyhow::Result<WindowHandle<Workspace>>> {
|
) -> 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 {
|
cx.spawn(|mut cx| async move {
|
||||||
let options = WindowOptions {
|
let options = WindowOptions {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue