This PR mainlines the current state of new GPUI2-based UI from the `gpui2-ui` branch. Release Notes: - N/A --------- Co-authored-by: Nate Butler <iamnbutler@gmail.com> Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com> Co-authored-by: Marshall Bowers <1486634+maxdeviant@users.noreply.github.com> Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Co-authored-by: Nate <nate@zed.dev> Co-authored-by: Mikayla <mikayla@zed.dev>
30 lines
805 B
Rust
30 lines
805 B
Rust
use std::marker::PhantomData;
|
|
|
|
use crate::prelude::*;
|
|
use crate::{example_editor_actions, OrderMethod, Palette};
|
|
|
|
#[derive(Element)]
|
|
pub struct CommandPalette<V: 'static> {
|
|
view_type: PhantomData<V>,
|
|
scroll_state: ScrollState,
|
|
}
|
|
|
|
impl<V: 'static> CommandPalette<V> {
|
|
pub fn new(scroll_state: ScrollState) -> Self {
|
|
Self {
|
|
view_type: PhantomData,
|
|
scroll_state,
|
|
}
|
|
}
|
|
|
|
fn render(&mut self, _: &mut V, cx: &mut ViewContext<V>) -> impl IntoElement<V> {
|
|
div().child(
|
|
Palette::new(self.scroll_state.clone())
|
|
.items(example_editor_actions())
|
|
.placeholder("Execute a command...")
|
|
.empty_string("No items found.")
|
|
.default_order(OrderMethod::Ascending),
|
|
)
|
|
}
|
|
}
|