copilot.rs

 1use std::marker::PhantomData;
 2
 3use crate::{prelude::*, Button, Label, LabelColor, Modal};
 4
 5#[derive(Element)]
 6pub struct CopilotModal<S: 'static + Send + Sync + Clone> {
 7    id: ElementId,
 8    state_type: PhantomData<S>,
 9}
10
11impl<S: 'static + Send + Sync + Clone> CopilotModal<S> {
12    pub fn new(id: impl Into<ElementId>) -> Self {
13        Self {
14            id: id.into(),
15            state_type: PhantomData,
16        }
17    }
18
19    fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
20        let color = ThemeColor::new(cx);
21
22        div().id(self.id.clone()).child(
23            Modal::new("some-id")
24                .title("Connect Copilot to Zed")
25                .child(Label::new("You can update your settings or sign out from the Copilot menu in the status bar.").color(LabelColor::Muted))
26                .primary_action(Button::new("Connect to Github").variant(ButtonVariant::Filled)),
27        )
28    }
29}
30
31#[cfg(feature = "stories")]
32pub use stories::*;
33
34#[cfg(feature = "stories")]
35mod stories {
36    use crate::Story;
37
38    use super::*;
39
40    #[derive(Element)]
41    pub struct CopilotModalStory<S: 'static + Send + Sync + Clone> {
42        state_type: PhantomData<S>,
43    }
44
45    impl<S: 'static + Send + Sync + Clone> CopilotModalStory<S> {
46        pub fn new() -> Self {
47            Self {
48                state_type: PhantomData,
49            }
50        }
51
52        fn render(
53            &mut self,
54            _view: &mut S,
55            cx: &mut ViewContext<S>,
56        ) -> impl Element<ViewState = S> {
57            Story::container(cx)
58                .child(Story::title_for::<_, CopilotModal<S>>(cx))
59                .child(Story::label(cx, "Default"))
60                .child(CopilotModal::new("copilot-modal"))
61        }
62    }
63}