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