diff --git a/crates/story/src/button_story.rs b/crates/story/src/button_story.rs index 9a000413..834b8b63 100644 --- a/crates/story/src/button_story.rs +++ b/crates/story/src/button_story.rs @@ -695,6 +695,7 @@ impl Render for ButtonStory { DropdownButton::new("dropdown-button1") .small() .button(Button::new("btn").label("Click Me")) + .selected(selected) .popup_menu(move |this, _, _| { this.menu("Disabled", Box::new(Disabled)) .menu("Loading", Box::new(Loading)) @@ -705,6 +706,7 @@ impl Render for ButtonStory { .child( DropdownButton::new("dropdown-button2") .button(Button::new("btn").label("Click Me")) + .selected(selected) .popup_menu(move |this, _, _| { this.menu("Disabled", Box::new(Disabled)) .menu("Loading", Box::new(Loading)) @@ -716,6 +718,19 @@ impl Render for ButtonStory { DropdownButton::new("dropdown-button3") .outline() .button(Button::new("btn").label("Outline Dropdown")) + .selected(selected) + .popup_menu(move |this, _, _| { + this.menu("Disabled", Box::new(Disabled)) + .menu("Loading", Box::new(Loading)) + .menu("Selected", Box::new(Selected)) + .menu("Compact", Box::new(Compact)) + }), + ) + .child( + DropdownButton::new("dropdown-button4") + .ghost() + .button(Button::new("btn").label("Ghost Dropdown")) + .selected(selected) .popup_menu(move |this, _, _| { this.menu("Disabled", Box::new(Disabled)) .menu("Loading", Box::new(Loading)) diff --git a/crates/ui/src/button/button.rs b/crates/ui/src/button/button.rs index ab45f4f9..c464e750 100644 --- a/crates/ui/src/button/button.rs +++ b/crates/ui/src/button/button.rs @@ -331,6 +331,10 @@ impl Selectable for Button { self.selected = selected; self } + + fn is_selected(&self) -> bool { + self.selected + } } impl Sizable for Button { diff --git a/crates/ui/src/button/dropdown_button.rs b/crates/ui/src/button/dropdown_button.rs index 2ff4e8c4..c996f508 100644 --- a/crates/ui/src/button/dropdown_button.rs +++ b/crates/ui/src/button/dropdown_button.rs @@ -6,7 +6,7 @@ use gpui::{ use crate::{ h_flex, popup_menu::{PopupMenu, PopupMenuExt}, - IconName, Sizable, Size, + IconName, Selectable, Sizable, Size, }; use super::{Button, ButtonRounded, ButtonVariant, ButtonVariants}; @@ -18,6 +18,7 @@ pub struct DropdownButton { button: Option