diff --git a/crates/ui/src/button/button.rs b/crates/ui/src/button/button.rs index c464e750..5cb36505 100644 --- a/crates/ui/src/button/button.rs +++ b/crates/ui/src/button/button.rs @@ -10,10 +10,11 @@ use gpui::{ RenderOnce, SharedString, StatefulInteractiveElement as _, Styled, Window, }; -#[derive(Clone, Copy)] +#[derive(Default, Clone, Copy)] pub enum ButtonRounded { None, Small, + #[default] Medium, Large, Size(Pixels), @@ -155,14 +156,22 @@ impl Default for ButtonVariant { } impl ButtonVariant { - fn is_link(&self) -> bool { + #[inline] + pub fn is_link(&self) -> bool { matches!(self, Self::Link) } - fn is_text(&self) -> bool { + #[inline] + pub fn is_text(&self) -> bool { matches!(self, Self::Text) } + #[inline] + pub fn is_ghost(&self) -> bool { + matches!(self, Self::Ghost) + } + + #[inline] fn no_padding(&self) -> bool { self.is_link() || self.is_text() } diff --git a/crates/ui/src/button/dropdown_button.rs b/crates/ui/src/button/dropdown_button.rs index c996f508..3483a08c 100644 --- a/crates/ui/src/button/dropdown_button.rs +++ b/crates/ui/src/button/dropdown_button.rs @@ -1,25 +1,24 @@ use gpui::{ - prelude::FluentBuilder, App, Context, Corner, Corners, Div, Edges, ElementId, - InteractiveElement as _, IntoElement, ParentElement, RenderOnce, Styled, Window, + div, prelude::FluentBuilder, App, Context, Corner, Corners, Edges, ElementId, + InteractiveElement as _, IntoElement, ParentElement, RenderOnce, StyleRefinement, Styled, + Window, }; use crate::{ - h_flex, popup_menu::{PopupMenu, PopupMenuExt}, - IconName, Selectable, Sizable, Size, + IconName, Selectable, Sizable, Size, StyledExt as _, }; use super::{Button, ButtonRounded, ButtonVariant, ButtonVariants}; #[derive(IntoElement)] pub struct DropdownButton { - base: Div, + style: StyleRefinement, id: ElementId, button: Option