Update prompt library styles (#12689)

- Extend Picker to allow passing a custom editor. This allows creating a
custom styled input.
- Updates various picker styles

Before:

![CleanShot 2024-06-05 at 22 08
36@2x](https://github.com/zed-industries/zed/assets/1714999/96bc62c6-839d-405b-b030-31491aab8710)

After:

![CleanShot 2024-06-05 at 22 09
15@2x](https://github.com/zed-industries/zed/assets/1714999/a4938885-e825-4880-955e-f3f47c81e1e3)

Release Notes:

- N/A
This commit is contained in:
Nate Butler 2024-06-05 22:10:02 -04:00 committed by GitHub
parent f476a8bc2a
commit 611bf2d905
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 167 additions and 84 deletions

View file

@ -103,6 +103,19 @@ pub trait PickerDelegate: Sized + 'static {
None
}
fn render_editor(&self, editor: &View<Editor>, _cx: &mut ViewContext<Picker<Self>>) -> Div {
v_flex()
.child(
h_flex()
.overflow_hidden()
.flex_none()
.h_9()
.px_4()
.child(editor.clone()),
)
.child(Divider::horizontal())
}
fn render_match(
&self,
ix: usize,
@ -552,16 +565,7 @@ impl<D: PickerDelegate> Render for Picker<D> {
.on_action(cx.listener(Self::use_selected_query))
.on_action(cx.listener(Self::confirm_input))
.child(match &self.head {
Head::Editor(editor) => v_flex()
.child(
h_flex()
.overflow_hidden()
.flex_none()
.h_9()
.px_4()
.child(editor.clone()),
)
.child(Divider::horizontal()),
Head::Editor(editor) => self.delegate.render_editor(&editor.clone(), cx),
Head::Empty(empty_head) => div().child(empty_head.clone()),
})
.when(self.delegate.match_count() > 0, |el| {