copilot.rs

 1use crate::{prelude::*, Button, Label, Modal, TextColor};
 2
 3#[derive(RenderOnce)]
 4pub struct CopilotModal {
 5    id: ElementId,
 6}
 7
 8impl<V: 'static> Component<V> for CopilotModal {
 9    type Rendered = Stateful<V, Div<V>>;
10
11    fn render(self, view: &mut V, cx: &mut ViewContext<V>) -> Self::Rendered {
12        div().id(self.id.clone()).child(
13                Modal::new("some-id")
14                    .title("Connect Copilot to Zed")
15                    .child(Label::new("You can update your settings or sign out from the Copilot menu in the status bar.").color(TextColor::Muted))
16                    .primary_action(Button::new("Connect to Github").variant(ButtonVariant::Filled)),
17            )
18    }
19}
20
21impl CopilotModal {
22    pub fn new(id: impl Into<ElementId>) -> Self {
23        Self { id: id.into() }
24    }
25}
26
27use gpui::{Div, RenderOnce, Stateful};
28#[cfg(feature = "stories")]
29pub use stories::*;
30
31#[cfg(feature = "stories")]
32mod stories {
33    use super::*;
34    use crate::Story;
35    use gpui::{Div, Render};
36
37    pub struct CopilotModalStory;
38
39    impl Render<Self> for CopilotModalStory {
40        type Element = Div<Self>;
41
42        fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
43            Story::container(cx)
44                .child(Story::title_for::<_, CopilotModal>(cx))
45                .child(Story::label(cx, "Default"))
46                .child(CopilotModal::new("copilot-modal"))
47        }
48    }
49}