ui2: Reorganize components (#3228)
This PR reorganizes the components in the `ui2` crate. The distinction between "elements" and "components" is now gone, with all of the reusable components living under `components/`. The components that we built while prototyping but will eventually live in other crates currently reside in the `to_extract/` module. Release Notes: - N/A
This commit is contained in:
parent
287ea0a6e4
commit
76db100d11
39 changed files with 99 additions and 130 deletions
46
crates/ui2/src/to_extract/copilot.rs
Normal file
46
crates/ui2/src/to_extract/copilot.rs
Normal file
|
@ -0,0 +1,46 @@
|
|||
use crate::{prelude::*, Button, Label, LabelColor, Modal};
|
||||
|
||||
#[derive(Component)]
|
||||
pub struct CopilotModal {
|
||||
id: ElementId,
|
||||
}
|
||||
|
||||
impl CopilotModal {
|
||||
pub fn new(id: impl Into<ElementId>) -> Self {
|
||||
Self { id: id.into() }
|
||||
}
|
||||
|
||||
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
div().id(self.id.clone()).child(
|
||||
Modal::new("some-id")
|
||||
.title("Connect Copilot to Zed")
|
||||
.child(Label::new("You can update your settings or sign out from the Copilot menu in the status bar.").color(LabelColor::Muted))
|
||||
.primary_action(Button::new("Connect to Github").variant(ButtonVariant::Filled)),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "stories")]
|
||||
pub use stories::*;
|
||||
|
||||
#[cfg(feature = "stories")]
|
||||
mod stories {
|
||||
use gpui2::{Div, Render};
|
||||
|
||||
use crate::Story;
|
||||
|
||||
use super::*;
|
||||
|
||||
pub struct CopilotModalStory;
|
||||
|
||||
impl Render for CopilotModalStory {
|
||||
type Element = Div<Self>;
|
||||
|
||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, CopilotModal>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
.child(CopilotModal::new("copilot-modal"))
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue