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 crate::Story;
38
39 use super::*;
40
41 #[derive(Component)]
42 pub struct RecentProjectsStory;
43
44 impl RecentProjectsStory {
45 fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
46 Story::container(cx)
47 .child(Story::title_for::<_, RecentProjects>(cx))
48 .child(Story::label(cx, "Default"))
49 .child(RecentProjects::new("recent-projects"))
50 }
51 }
52}