copilot.rs

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