dropdown_button: Support outline style (#716)

This commit is contained in:
Floyd Wang 2025-03-12 17:23:37 +08:00 committed by GitHub
parent 87b8958059
commit 8e7ef5631e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -21,6 +21,7 @@ pub struct DropdownButton {
// The button props // The button props
compact: Option<bool>, compact: Option<bool>,
outline: Option<bool>,
variant: Option<ButtonVariant>, variant: Option<ButtonVariant>,
size: Option<Size>, size: Option<Size>,
rounded: ButtonRounded, rounded: ButtonRounded,
@ -35,6 +36,7 @@ impl DropdownButton {
popup_menu: None, popup_menu: None,
compact: None, compact: None,
outline: None,
variant: None, variant: None,
size: None, size: None,
rounded: ButtonRounded::Medium, rounded: ButtonRounded::Medium,
@ -63,6 +65,11 @@ impl DropdownButton {
self.compact = Some(true); self.compact = Some(true);
self self
} }
pub fn outline(mut self) -> Self {
self.outline = Some(true);
self
}
} }
impl Styled for DropdownButton { impl Styled for DropdownButton {
@ -104,6 +111,7 @@ impl RenderOnce for DropdownButton {
bottom: true, bottom: true,
}) })
.when_some(self.compact, |this, _| this.compact()) .when_some(self.compact, |this, _| this.compact())
.when_some(self.outline, |this, _| this.outline())
.when_some(self.size, |this, size| this.with_size(size)) .when_some(self.size, |this, size| this.with_size(size))
.when_some(self.variant, |this, variant| this.with_variant(variant)), .when_some(self.variant, |this, variant| this.with_variant(variant)),
) )
@ -125,6 +133,7 @@ impl RenderOnce for DropdownButton {
bottom_right: true, bottom_right: true,
}) })
.when_some(self.compact, |this, _| this.compact()) .when_some(self.compact, |this, _| this.compact())
.when_some(self.outline, |this, _| this.outline())
.when_some(self.size, |this, size| this.with_size(size)) .when_some(self.size, |this, size| this.with_size(size))
.when_some(self.variant, |this, variant| this.with_variant(variant)) .when_some(self.variant, |this, variant| this.with_variant(variant))
.popup_menu_with_anchor(Corner::TopRight, move |this, window, cx| { .popup_menu_with_anchor(Corner::TopRight, move |this, window, cx| {