1use gpui2::elements::div;
2use gpui2::{elements::div::ScrollState, ViewContext};
3use gpui2::{Element, IntoElement, ParentElement};
4use std::marker::PhantomData;
5
6use crate::{example_editor_actions, palette, OrderMethod};
7
8#[derive(Element)]
9pub struct CommandPalette<V: 'static> {
10 view_type: PhantomData<V>,
11 scroll_state: ScrollState,
12}
13
14pub fn command_palette<V: 'static>(scroll_state: ScrollState) -> CommandPalette<V> {
15 CommandPalette {
16 view_type: PhantomData,
17 scroll_state,
18 }
19}
20
21impl<V: 'static> CommandPalette<V> {
22 fn render(&mut self, _: &mut V, cx: &mut ViewContext<V>) -> impl IntoElement<V> {
23 div().child(
24 palette(self.scroll_state.clone())
25 .items(example_editor_actions())
26 .placeholder("Execute a command...")
27 .empty_string("No items found.")
28 .default_order(OrderMethod::Ascending),
29 )
30 }
31}