1use std::marker::PhantomData;
2
3use crate::prelude::*;
4use crate::{example_editor_actions, OrderMethod, Palette};
5
6#[derive(Element)]
7pub struct CommandPalette<S: 'static + Send + Sync + Clone> {
8 state_type: PhantomData<S>,
9 scroll_state: ScrollState,
10}
11
12impl<S: 'static + Send + Sync + Clone> CommandPalette<S> {
13 pub fn new(scroll_state: ScrollState) -> Self {
14 Self {
15 state_type: PhantomData,
16 scroll_state,
17 }
18 }
19
20 fn render(&mut self, cx: &mut ViewContext<S>) -> impl Element<State = S> {
21 div().child(
22 Palette::new(self.scroll_state.clone())
23 .items(example_editor_actions())
24 .placeholder("Execute a command...")
25 .empty_string("No items found.")
26 .default_order(OrderMethod::Ascending),
27 )
28 }
29}