The button compact method defaults to true (#99)
This commit is contained in:
parent
22a1157378
commit
48efdecdef
2 changed files with 40 additions and 39 deletions
|
|
@ -7,6 +7,7 @@ use ui::{
|
||||||
button::{Button, ButtonCustomStyle, ButtonStyle},
|
button::{Button, ButtonCustomStyle, ButtonStyle},
|
||||||
checkbox::Checkbox,
|
checkbox::Checkbox,
|
||||||
h_flex,
|
h_flex,
|
||||||
|
prelude::FluentBuilder,
|
||||||
theme::ActiveTheme,
|
theme::ActiveTheme,
|
||||||
v_flex, Clickable, Disableable as _, Icon, IconName, Selectable as _, Size,
|
v_flex, Clickable, Disableable as _, Icon, IconName, Selectable as _, Size,
|
||||||
};
|
};
|
||||||
|
|
@ -97,7 +98,7 @@ impl Render for ButtonStory {
|
||||||
.disabled(disabled)
|
.disabled(disabled)
|
||||||
.selected(selected)
|
.selected(selected)
|
||||||
.loading(loading)
|
.loading(loading)
|
||||||
.compact(compact)
|
.when(compact, |this| this.compact())
|
||||||
.on_click(Self::on_click),
|
.on_click(Self::on_click),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
|
|
@ -106,7 +107,7 @@ impl Render for ButtonStory {
|
||||||
.disabled(disabled)
|
.disabled(disabled)
|
||||||
.selected(selected)
|
.selected(selected)
|
||||||
.loading(loading)
|
.loading(loading)
|
||||||
.compact(compact)
|
.when(compact, |this| this.compact())
|
||||||
.on_click(Self::on_click),
|
.on_click(Self::on_click),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
|
|
@ -116,7 +117,7 @@ impl Render for ButtonStory {
|
||||||
.disabled(disabled)
|
.disabled(disabled)
|
||||||
.selected(selected)
|
.selected(selected)
|
||||||
.loading(loading)
|
.loading(loading)
|
||||||
.compact(compact)
|
.when(compact, |this| this.compact())
|
||||||
.on_click(Self::on_click),
|
.on_click(Self::on_click),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
|
|
@ -126,7 +127,7 @@ impl Render for ButtonStory {
|
||||||
.disabled(disabled)
|
.disabled(disabled)
|
||||||
.selected(selected)
|
.selected(selected)
|
||||||
.loading(loading)
|
.loading(loading)
|
||||||
.compact(compact)
|
.when(compact, |this| this.compact())
|
||||||
.on_click(Self::on_click),
|
.on_click(Self::on_click),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
|
|
@ -136,7 +137,7 @@ impl Render for ButtonStory {
|
||||||
.disabled(disabled)
|
.disabled(disabled)
|
||||||
.selected(selected)
|
.selected(selected)
|
||||||
.loading(loading)
|
.loading(loading)
|
||||||
.compact(compact)
|
.when(compact, |this| this.compact())
|
||||||
.on_click(Self::on_click),
|
.on_click(Self::on_click),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
|
|
@ -146,7 +147,7 @@ impl Render for ButtonStory {
|
||||||
.disabled(disabled)
|
.disabled(disabled)
|
||||||
.selected(selected)
|
.selected(selected)
|
||||||
.loading(loading)
|
.loading(loading)
|
||||||
.compact(compact)
|
.when(compact, |this| this.compact())
|
||||||
.on_click(Self::on_click),
|
.on_click(Self::on_click),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
|
|
@ -163,7 +164,7 @@ impl Render for ButtonStory {
|
||||||
.disabled(disabled)
|
.disabled(disabled)
|
||||||
.selected(selected)
|
.selected(selected)
|
||||||
.loading(loading)
|
.loading(loading)
|
||||||
.compact(compact)
|
.when(compact, |this| this.compact())
|
||||||
.on_click(Self::on_click),
|
.on_click(Self::on_click),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
@ -177,7 +178,7 @@ impl Render for ButtonStory {
|
||||||
.disabled(disabled)
|
.disabled(disabled)
|
||||||
.selected(selected)
|
.selected(selected)
|
||||||
.loading(loading)
|
.loading(loading)
|
||||||
.compact(compact)
|
.when(compact, |this| this.compact())
|
||||||
.on_click(Self::on_click),
|
.on_click(Self::on_click),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
|
|
@ -187,7 +188,7 @@ impl Render for ButtonStory {
|
||||||
.disabled(disabled)
|
.disabled(disabled)
|
||||||
.selected(selected)
|
.selected(selected)
|
||||||
.loading(loading)
|
.loading(loading)
|
||||||
.compact(compact)
|
.when(compact, |this| this.compact())
|
||||||
.on_click(Self::on_click),
|
.on_click(Self::on_click),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
|
|
@ -197,7 +198,7 @@ impl Render for ButtonStory {
|
||||||
.disabled(disabled)
|
.disabled(disabled)
|
||||||
.selected(selected)
|
.selected(selected)
|
||||||
.loading(loading)
|
.loading(loading)
|
||||||
.compact(compact)
|
.when(compact, |this| this.compact())
|
||||||
.on_click(Self::on_click),
|
.on_click(Self::on_click),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
|
|
@ -214,7 +215,7 @@ impl Render for ButtonStory {
|
||||||
.disabled(disabled)
|
.disabled(disabled)
|
||||||
.selected(selected)
|
.selected(selected)
|
||||||
.loading(loading)
|
.loading(loading)
|
||||||
.compact(compact)
|
.when(compact, |this| this.compact())
|
||||||
.on_click(Self::on_click),
|
.on_click(Self::on_click),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
|
|
@ -225,7 +226,7 @@ impl Render for ButtonStory {
|
||||||
.disabled(disabled)
|
.disabled(disabled)
|
||||||
.selected(selected)
|
.selected(selected)
|
||||||
.loading(loading)
|
.loading(loading)
|
||||||
.compact(compact)
|
.when(compact, |this| this.compact())
|
||||||
.on_click(Self::on_click),
|
.on_click(Self::on_click),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
|
|
@ -236,7 +237,7 @@ impl Render for ButtonStory {
|
||||||
.disabled(disabled)
|
.disabled(disabled)
|
||||||
.selected(selected)
|
.selected(selected)
|
||||||
.loading(loading)
|
.loading(loading)
|
||||||
.compact(compact)
|
.when(compact, |this| this.compact())
|
||||||
.on_click(Self::on_click),
|
.on_click(Self::on_click),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
@ -255,7 +256,7 @@ impl Render for ButtonStory {
|
||||||
.disabled(disabled)
|
.disabled(disabled)
|
||||||
.selected(selected)
|
.selected(selected)
|
||||||
.loading(loading)
|
.loading(loading)
|
||||||
.compact(compact)
|
.when(compact, |this| this.compact())
|
||||||
.on_click(Self::on_click),
|
.on_click(Self::on_click),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
|
|
@ -266,7 +267,7 @@ impl Render for ButtonStory {
|
||||||
.disabled(disabled)
|
.disabled(disabled)
|
||||||
.selected(selected)
|
.selected(selected)
|
||||||
.loading(loading)
|
.loading(loading)
|
||||||
.compact(compact)
|
.when(compact, |this| this.compact())
|
||||||
.on_click(Self::on_click),
|
.on_click(Self::on_click),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
|
|
@ -277,7 +278,7 @@ impl Render for ButtonStory {
|
||||||
.disabled(disabled)
|
.disabled(disabled)
|
||||||
.selected(selected)
|
.selected(selected)
|
||||||
.loading(loading)
|
.loading(loading)
|
||||||
.compact(compact)
|
.when(compact, |this| this.compact())
|
||||||
.on_click(Self::on_click),
|
.on_click(Self::on_click),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
|
|
@ -288,7 +289,7 @@ impl Render for ButtonStory {
|
||||||
.disabled(disabled)
|
.disabled(disabled)
|
||||||
.selected(selected)
|
.selected(selected)
|
||||||
.loading(loading)
|
.loading(loading)
|
||||||
.compact(compact)
|
.when(compact, |this| this.compact())
|
||||||
.on_click(Self::on_click),
|
.on_click(Self::on_click),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
|
|
@ -299,7 +300,7 @@ impl Render for ButtonStory {
|
||||||
.disabled(disabled)
|
.disabled(disabled)
|
||||||
.selected(selected)
|
.selected(selected)
|
||||||
.loading(loading)
|
.loading(loading)
|
||||||
.compact(compact)
|
.when(compact, |this| this.compact())
|
||||||
.on_click(Self::on_click),
|
.on_click(Self::on_click),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
|
|
@ -310,7 +311,7 @@ impl Render for ButtonStory {
|
||||||
.disabled(disabled)
|
.disabled(disabled)
|
||||||
.selected(selected)
|
.selected(selected)
|
||||||
.loading(loading)
|
.loading(loading)
|
||||||
.compact(compact)
|
.when(compact, |this| this.compact())
|
||||||
.on_click(Self::on_click),
|
.on_click(Self::on_click),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
@ -324,7 +325,7 @@ impl Render for ButtonStory {
|
||||||
.disabled(disabled)
|
.disabled(disabled)
|
||||||
.selected(selected)
|
.selected(selected)
|
||||||
.loading(loading)
|
.loading(loading)
|
||||||
.compact(compact)
|
.when(compact, |this| this.compact())
|
||||||
.on_click(Self::on_click),
|
.on_click(Self::on_click),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
|
|
@ -336,7 +337,7 @@ impl Render for ButtonStory {
|
||||||
.disabled(disabled)
|
.disabled(disabled)
|
||||||
.selected(selected)
|
.selected(selected)
|
||||||
.loading(loading)
|
.loading(loading)
|
||||||
.compact(compact)
|
.when(compact, |this| this.compact())
|
||||||
.on_click(Self::on_click),
|
.on_click(Self::on_click),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
|
|
@ -347,7 +348,7 @@ impl Render for ButtonStory {
|
||||||
.disabled(disabled)
|
.disabled(disabled)
|
||||||
.selected(selected)
|
.selected(selected)
|
||||||
.loading(loading)
|
.loading(loading)
|
||||||
.compact(compact)
|
.when(compact, |this| this.compact())
|
||||||
.on_click(Self::on_click),
|
.on_click(Self::on_click),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
|
|
@ -358,7 +359,7 @@ impl Render for ButtonStory {
|
||||||
.disabled(disabled)
|
.disabled(disabled)
|
||||||
.selected(selected)
|
.selected(selected)
|
||||||
.loading(loading)
|
.loading(loading)
|
||||||
.compact(compact)
|
.when(compact, |this| this.compact())
|
||||||
.on_click(Self::on_click),
|
.on_click(Self::on_click),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
|
|
@ -369,7 +370,7 @@ impl Render for ButtonStory {
|
||||||
.disabled(disabled)
|
.disabled(disabled)
|
||||||
.selected(selected)
|
.selected(selected)
|
||||||
.loading(loading)
|
.loading(loading)
|
||||||
.compact(compact)
|
.when(compact, |this| this.compact())
|
||||||
.on_click(Self::on_click),
|
.on_click(Self::on_click),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
|
|
@ -380,7 +381,7 @@ impl Render for ButtonStory {
|
||||||
.disabled(disabled)
|
.disabled(disabled)
|
||||||
.selected(selected)
|
.selected(selected)
|
||||||
.loading(loading)
|
.loading(loading)
|
||||||
.compact(compact)
|
.when(compact, |this| this.compact())
|
||||||
.on_click(Self::on_click),
|
.on_click(Self::on_click),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
@ -394,7 +395,7 @@ impl Render for ButtonStory {
|
||||||
.disabled(disabled)
|
.disabled(disabled)
|
||||||
.selected(selected)
|
.selected(selected)
|
||||||
.loading(loading)
|
.loading(loading)
|
||||||
.compact(compact),
|
.when(compact, |this| this.compact()),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
Button::new("icon-button-secondary", cx)
|
Button::new("icon-button-secondary", cx)
|
||||||
|
|
@ -403,7 +404,7 @@ impl Render for ButtonStory {
|
||||||
.disabled(disabled)
|
.disabled(disabled)
|
||||||
.selected(selected)
|
.selected(selected)
|
||||||
.loading(loading)
|
.loading(loading)
|
||||||
.compact(compact),
|
.when(compact, |this| this.compact()),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
Button::new("icon-button-danger", cx)
|
Button::new("icon-button-danger", cx)
|
||||||
|
|
@ -412,7 +413,7 @@ impl Render for ButtonStory {
|
||||||
.disabled(disabled)
|
.disabled(disabled)
|
||||||
.selected(selected)
|
.selected(selected)
|
||||||
.loading(loading)
|
.loading(loading)
|
||||||
.compact(compact),
|
.when(compact, |this| this.compact()),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
Button::new("icon-button-small-primary", cx)
|
Button::new("icon-button-small-primary", cx)
|
||||||
|
|
@ -422,7 +423,7 @@ impl Render for ButtonStory {
|
||||||
.disabled(disabled)
|
.disabled(disabled)
|
||||||
.selected(selected)
|
.selected(selected)
|
||||||
.loading(loading)
|
.loading(loading)
|
||||||
.compact(compact),
|
.when(compact, |this| this.compact()),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
Button::new("icon-button-outline", cx)
|
Button::new("icon-button-outline", cx)
|
||||||
|
|
@ -431,7 +432,7 @@ impl Render for ButtonStory {
|
||||||
.disabled(disabled)
|
.disabled(disabled)
|
||||||
.selected(selected)
|
.selected(selected)
|
||||||
.loading(loading)
|
.loading(loading)
|
||||||
.compact(compact),
|
.when(compact, |this| this.compact()),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
Button::new("icon-button-ghost", cx)
|
Button::new("icon-button-ghost", cx)
|
||||||
|
|
@ -440,7 +441,7 @@ impl Render for ButtonStory {
|
||||||
.disabled(disabled)
|
.disabled(disabled)
|
||||||
.selected(selected)
|
.selected(selected)
|
||||||
.loading(loading)
|
.loading(loading)
|
||||||
.compact(compact),
|
.when(compact, |this| this.compact()),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
|
|
@ -452,7 +453,7 @@ impl Render for ButtonStory {
|
||||||
.disabled(disabled)
|
.disabled(disabled)
|
||||||
.selected(selected)
|
.selected(selected)
|
||||||
.loading(loading)
|
.loading(loading)
|
||||||
.compact(compact),
|
.when(compact, |this| this.compact()),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
Button::new("icon-button-5", cx)
|
Button::new("icon-button-5", cx)
|
||||||
|
|
@ -462,7 +463,7 @@ impl Render for ButtonStory {
|
||||||
.disabled(disabled)
|
.disabled(disabled)
|
||||||
.selected(selected)
|
.selected(selected)
|
||||||
.loading(loading)
|
.loading(loading)
|
||||||
.compact(compact),
|
.when(compact, |this| this.compact()),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
Button::new("icon-button-6", cx)
|
Button::new("icon-button-6", cx)
|
||||||
|
|
@ -472,7 +473,7 @@ impl Render for ButtonStory {
|
||||||
.disabled(disabled)
|
.disabled(disabled)
|
||||||
.selected(selected)
|
.selected(selected)
|
||||||
.loading(loading)
|
.loading(loading)
|
||||||
.compact(compact),
|
.when(compact, |this| this.compact()),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
Button::new("icon-button-7", cx)
|
Button::new("icon-button-7", cx)
|
||||||
|
|
@ -481,7 +482,7 @@ impl Render for ButtonStory {
|
||||||
.disabled(disabled)
|
.disabled(disabled)
|
||||||
.selected(selected)
|
.selected(selected)
|
||||||
.loading(loading)
|
.loading(loading)
|
||||||
.compact(compact),
|
.when(compact, |this| this.compact()),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
Button::new("icon-button-8", cx)
|
Button::new("icon-button-8", cx)
|
||||||
|
|
@ -491,7 +492,7 @@ impl Render for ButtonStory {
|
||||||
.disabled(disabled)
|
.disabled(disabled)
|
||||||
.selected(selected)
|
.selected(selected)
|
||||||
.loading(loading)
|
.loading(loading)
|
||||||
.compact(compact),
|
.when(compact, |this| this.compact()),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
Button::new("icon-button-9", cx)
|
Button::new("icon-button-9", cx)
|
||||||
|
|
@ -501,7 +502,7 @@ impl Render for ButtonStory {
|
||||||
.disabled(disabled)
|
.disabled(disabled)
|
||||||
.selected(selected)
|
.selected(selected)
|
||||||
.loading(loading)
|
.loading(loading)
|
||||||
.compact(compact),
|
.when(compact, |this| this.compact()),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -212,8 +212,8 @@ impl Button {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the button to compact mode, then padding will be reduced.
|
/// Set the button to compact mode, then padding will be reduced.
|
||||||
pub fn compact(mut self, compact: bool) -> Self {
|
pub fn compact(mut self) -> Self {
|
||||||
self.compact = compact;
|
self.compact = true;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue