1use ui::prelude::*;
2use ui::{Keybinding, ModifierKeys, Palette, PaletteItem};
3
4use crate::story::Story;
5
6#[derive(Element, Default)]
7pub struct PaletteStory {}
8
9impl PaletteStory {
10 fn render<V: 'static>(&mut self, _: &mut V, cx: &mut ViewContext<V>) -> impl IntoElement<V> {
11 Story::container(cx)
12 .child(Story::title_for::<_, Palette<V>>(cx))
13 .child(Story::label(cx, "Default"))
14 .child(Palette::new(ScrollState::default()))
15 .child(Story::label(cx, "With Items"))
16 .child(
17 Palette::new(ScrollState::default())
18 .placeholder("Execute a command...")
19 .items(vec![
20 PaletteItem::new("theme selector: toggle").keybinding(
21 Keybinding::new_chord(
22 ("k".to_string(), ModifierKeys::new().command(true)),
23 ("t".to_string(), ModifierKeys::new().command(true)),
24 ),
25 ),
26 PaletteItem::new("assistant: inline assist").keybinding(Keybinding::new(
27 "enter".to_string(),
28 ModifierKeys::new().command(true),
29 )),
30 PaletteItem::new("assistant: quote selection").keybinding(Keybinding::new(
31 ">".to_string(),
32 ModifierKeys::new().command(true),
33 )),
34 PaletteItem::new("assistant: toggle focus").keybinding(Keybinding::new(
35 "?".to_string(),
36 ModifierKeys::new().command(true),
37 )),
38 PaletteItem::new("auto update: check"),
39 PaletteItem::new("auto update: view release notes"),
40 PaletteItem::new("branches: open recent").keybinding(Keybinding::new(
41 "b".to_string(),
42 ModifierKeys::new().command(true).alt(true),
43 )),
44 PaletteItem::new("chat panel: toggle focus"),
45 PaletteItem::new("cli: install"),
46 PaletteItem::new("client: sign in"),
47 PaletteItem::new("client: sign out"),
48 PaletteItem::new("editor: cancel")
49 .keybinding(Keybinding::new("escape".to_string(), ModifierKeys::new())),
50 ]),
51 )
52 }
53}