chore: Unify icon parameter types in ListItem and Dropdown. (#857)
## Changes This PR unifies icon parameter types in UI components: - Changed `ListItem.check_icon` parameter type from `IconName` to `impl Into<Icon>` - Changed `Dropdown.icon` parameter type from `impl Into<IconName>` to `impl Into<Icon>` - Updated related rendering logic ## Impact - **API Consistency**: All components now accept the same icon parameter type - **Backward Compatible**: Existing code using `IconName` continues to work - **Enhanced Flexibility**: Components can now accept custom `Icon` instances directly
This commit is contained in:
parent
c0e0d82594
commit
f3d97bf8e2
2 changed files with 8 additions and 8 deletions
|
|
@ -247,7 +247,7 @@ pub struct Dropdown<D: DropdownDelegate + 'static> {
|
|||
focus_handle: FocusHandle,
|
||||
list: Entity<List<DropdownListDelegate<D>>>,
|
||||
size: Size,
|
||||
icon: Option<IconName>,
|
||||
icon: Option<Icon>,
|
||||
open: bool,
|
||||
cleanable: bool,
|
||||
placeholder: Option<SharedString>,
|
||||
|
|
@ -408,7 +408,7 @@ where
|
|||
}
|
||||
|
||||
/// Set the right icon for the dropdown input, instead of the default arrow icon.
|
||||
pub fn icon(mut self, icon: impl Into<IconName>) -> Self {
|
||||
pub fn icon(mut self, icon: impl Into<Icon>) -> Self {
|
||||
self.icon = Some(icon.into());
|
||||
self
|
||||
}
|
||||
|
|
@ -719,14 +719,14 @@ where
|
|||
Some(icon) => icon,
|
||||
None => {
|
||||
if self.open {
|
||||
IconName::ChevronUp
|
||||
Icon::new(IconName::ChevronUp)
|
||||
} else {
|
||||
IconName::ChevronDown
|
||||
Icon::new(IconName::ChevronDown)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.child(Icon::new(icon).xsmall().text_color(
|
||||
this.child(icon.xsmall().text_color(
|
||||
match self.disabled {
|
||||
true => cx.theme().muted_foreground.opacity(0.5),
|
||||
false => cx.theme().muted_foreground,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{h_flex, ActiveTheme, Disableable, Icon, IconName, Selectable, Sizable as _};
|
||||
use crate::{h_flex, ActiveTheme, Disableable, Icon, Selectable, Sizable as _};
|
||||
use gpui::{
|
||||
div, prelude::FluentBuilder as _, AnyElement, App, ClickEvent, Div, ElementId,
|
||||
InteractiveElement, IntoElement, MouseButton, MouseMoveEvent, ParentElement, RenderOnce,
|
||||
|
|
@ -38,8 +38,8 @@ impl ListItem {
|
|||
}
|
||||
|
||||
/// Set to show check icon, default is None.
|
||||
pub fn check_icon(mut self, icon: IconName) -> Self {
|
||||
self.check_icon = Some(Icon::new(icon));
|
||||
pub fn check_icon(mut self, icon: impl Into<Icon>) -> Self {
|
||||
self.check_icon = Some(icon.into());
|
||||
self
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue