diff --git a/assets/icons/close.svg b/assets/icons/close.svg new file mode 100644 index 00000000..346ec0b4 --- /dev/null +++ b/assets/icons/close.svg @@ -0,0 +1 @@ + diff --git a/crates/story/src/dropdown_story.rs b/crates/story/src/dropdown_story.rs index f7b75181..781a0d2b 100644 --- a/crates/story/src/dropdown_story.rs +++ b/crates/story/src/dropdown_story.rs @@ -1,5 +1,3 @@ -use std::borrow::Cow; - use gpui::{ px, IntoElement, ParentElement, Render, SharedString, Styled, View, ViewContext, VisualContext, WindowContext, @@ -13,24 +11,24 @@ use ui::{ }; struct Country { - name: String, - code: String, + name: SharedString, + code: SharedString, } impl Country { - pub fn new(name: &str, code: &str) -> Self { + pub fn new(name: impl Into, code: impl Into) -> Self { Self { - name: name.to_string(), - code: code.to_string(), + name: name.into(), + code: code.into(), } } } impl DropdownItem for Country { - type Value = String; + type Value = SharedString; - fn title(&self) -> Cow<'_, str> { - self.name.as_str().into() + fn title(&self) -> SharedString { + self.name.clone() } fn value(&self) -> &Self::Value { diff --git a/crates/ui/src/dropdown.rs b/crates/ui/src/dropdown.rs index 3e543943..8d815dc7 100644 --- a/crates/ui/src/dropdown.rs +++ b/crates/ui/src/dropdown.rs @@ -1,5 +1,3 @@ -use std::borrow::Cow; - use gpui::{ actions, deferred, div, prelude::FluentBuilder, px, rems, AnyElement, AppContext, ClickEvent, DismissEvent, Div, Element, ElementId, EventEmitter, FocusHandle, Focusable, FocusableView, @@ -31,15 +29,15 @@ pub fn init(cx: &mut AppContext) { /// A trait for items that can be displayed in a dropdown. pub trait DropdownItem { type Value: Clone; - fn title(&self) -> Cow<'_, str>; + fn title(&self) -> SharedString; fn value(&self) -> &Self::Value; } impl DropdownItem for String { type Value = Self; - fn title(&self) -> Cow<'_, str> { - self.as_str().into() + fn title(&self) -> SharedString { + SharedString::from(self.to_string()) } fn value(&self) -> &Self::Value { @@ -50,8 +48,8 @@ impl DropdownItem for String { impl DropdownItem for SharedString { type Value = Self; - fn title(&self) -> Cow<'_, str> { - self.as_ref().into() + fn title(&self) -> SharedString { + SharedString::from(self.to_string()) } fn value(&self) -> &Self::Value {