1use crate::prelude::*;
2use crate::{OrderMethod, Palette, PaletteItem};
3
4#[derive(Component)]
5pub struct RecentProjects {
6 id: ElementId,
7}
8
9impl RecentProjects {
10 pub fn new(id: impl Into<ElementId>) -> Self {
11 Self { id: id.into() }
12 }
13
14 fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
15 div().id(self.id.clone()).child(
16 Palette::new("palette")
17 .items(vec![
18 PaletteItem::new("zed").sublabel(SharedString::from("~/projects/zed")),
19 PaletteItem::new("saga").sublabel(SharedString::from("~/projects/saga")),
20 PaletteItem::new("journal").sublabel(SharedString::from("~/journal")),
21 PaletteItem::new("dotfiles").sublabel(SharedString::from("~/dotfiles")),
22 PaletteItem::new("zed.dev").sublabel(SharedString::from("~/projects/zed.dev")),
23 PaletteItem::new("laminar").sublabel(SharedString::from("~/projects/laminar")),
24 ])
25 .placeholder("Recent Projects...")
26 .empty_string("No matches")
27 .default_order(OrderMethod::Ascending),
28 )
29 }
30}
31
32#[cfg(feature = "stories")]
33pub use stories::*;
34
35#[cfg(feature = "stories")]
36mod stories {
37 use super::*;
38 use crate::Story;
39 use gpui2::{Div, Render};
40
41 pub struct RecentProjectsStory;
42
43 impl Render for RecentProjectsStory {
44 type Element = Div<Self>;
45
46 fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
47 Story::container(cx)
48 .child(Story::title_for::<_, RecentProjects>(cx))
49 .child(Story::label(cx, "Default"))
50 .child(RecentProjects::new("recent-projects"))
51 }
52 }
53}