Restructure ui
into just elements
and components
(#3023)
This PR restructures the `ui` crate into just `elements` and `components`. This was already done on the `gpui2-ui` branch, just getting it onto `main`. Release Notes: - N/A --------- Co-authored-by: Nate Butler <nate@zed.dev>
This commit is contained in:
parent
895386cfaf
commit
0697d08e54
16 changed files with 22 additions and 28 deletions
31
crates/ui/src/components/command_palette.rs
Normal file
31
crates/ui/src/components/command_palette.rs
Normal file
|
@ -0,0 +1,31 @@
|
|||
use gpui2::elements::div;
|
||||
use gpui2::{elements::div::ScrollState, ViewContext};
|
||||
use gpui2::{Element, IntoElement, ParentElement};
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use crate::{example_editor_actions, palette, OrderMethod};
|
||||
|
||||
#[derive(Element)]
|
||||
pub struct CommandPalette<V: 'static> {
|
||||
view_type: PhantomData<V>,
|
||||
scroll_state: ScrollState,
|
||||
}
|
||||
|
||||
pub fn command_palette<V: 'static>(scroll_state: ScrollState) -> CommandPalette<V> {
|
||||
CommandPalette {
|
||||
view_type: PhantomData,
|
||||
scroll_state,
|
||||
}
|
||||
}
|
||||
|
||||
impl<V: 'static> CommandPalette<V> {
|
||||
fn render(&mut self, _: &mut V, cx: &mut ViewContext<V>) -> impl IntoElement<V> {
|
||||
div().child(
|
||||
palette(self.scroll_state.clone())
|
||||
.items(example_editor_actions())
|
||||
.placeholder("Execute a command...")
|
||||
.empty_string("No items found.")
|
||||
.default_order(OrderMethod::Ascending),
|
||||
)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue