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