Finish shape of copilot auth UI
This commit is contained in:
@@ -9,7 +9,7 @@ use gpui::{
|
||||
use serde::{de::DeserializeOwned, Deserialize};
|
||||
use serde_json::Value;
|
||||
use std::{collections::HashMap, sync::Arc};
|
||||
use ui::{ButtonStyle, CheckboxStyle, Dimensions, IconStyle, SvgStyle};
|
||||
use ui::{ButtonStyle, CheckboxStyle, ModalStyle, SvgStyle};
|
||||
|
||||
pub mod ui;
|
||||
|
||||
@@ -118,19 +118,29 @@ pub struct AvatarStyle {
|
||||
|
||||
#[derive(Deserialize, Default, Clone)]
|
||||
pub struct Copilot {
|
||||
pub modal: ModalStyle,
|
||||
pub auth: CopilotAuth,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Default, Clone)]
|
||||
pub struct CopilotAuth {
|
||||
pub popup_container: ContainerStyle,
|
||||
pub popup_dimensions: Dimensions,
|
||||
pub instruction_text: TextStyle,
|
||||
pub user_code: TextStyle,
|
||||
pub button: ButtonStyle,
|
||||
pub button_width: f32,
|
||||
pub cta_button: ButtonStyle,
|
||||
pub content_width: f32,
|
||||
pub copilot_icon: SvgStyle,
|
||||
pub close_icon: Interactive<IconStyle>,
|
||||
pub plus_icon: SvgStyle,
|
||||
pub zed_icon: SvgStyle,
|
||||
pub header_text: TextStyle,
|
||||
pub device_code_group: ContainerStyle,
|
||||
pub github_group: ContainerStyle,
|
||||
pub header_group: ContainerStyle,
|
||||
pub device_code: TextStyle,
|
||||
pub device_code_cta: ButtonStyle,
|
||||
pub device_code_left: f32,
|
||||
pub device_code_left_container: ContainerStyle,
|
||||
pub device_code_right: f32,
|
||||
pub device_code_right_container: ContainerStyle,
|
||||
pub device_code_seperator_height: f32,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Default)]
|
||||
|
||||
+60
-2
@@ -4,11 +4,12 @@ use gpui::{
|
||||
color::Color,
|
||||
elements::{
|
||||
ConstrainedBox, Container, ContainerStyle, Empty, Flex, KeystrokeLabel, Label,
|
||||
MouseEventHandler, ParentElement, Svg,
|
||||
MouseEventHandler, ParentElement, Stack, Svg,
|
||||
},
|
||||
fonts::TextStyle,
|
||||
geometry::vector::{vec2f, Vector2F},
|
||||
scene::MouseClick,
|
||||
Action, Element, ElementBox, EventContext, MouseButton, MouseState, RenderContext, View,
|
||||
Action, Element, ElementBox, EventContext, MouseButton, RenderContext, View,
|
||||
};
|
||||
use serde::Deserialize;
|
||||
|
||||
@@ -213,3 +214,60 @@ where
|
||||
.with_cursor_style(gpui::CursorStyle::PointingHand)
|
||||
.boxed()
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, Default)]
|
||||
pub struct ModalStyle {
|
||||
close_icon: Interactive<IconStyle>,
|
||||
container: ContainerStyle,
|
||||
titlebar: ContainerStyle,
|
||||
title_text: TextStyle,
|
||||
dimensions: Dimensions,
|
||||
}
|
||||
|
||||
impl ModalStyle {
|
||||
pub fn dimensions(&self) -> Vector2F {
|
||||
self.dimensions.to_vec()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn modal<V, I, F>(
|
||||
title: I,
|
||||
style: &ModalStyle,
|
||||
cx: &mut RenderContext<V>,
|
||||
build_modal: F,
|
||||
) -> ElementBox
|
||||
where
|
||||
V: View,
|
||||
I: Into<Cow<'static, str>>,
|
||||
F: FnOnce(&mut gpui::RenderContext<V>) -> ElementBox,
|
||||
{
|
||||
Flex::column()
|
||||
.with_child(
|
||||
Stack::new()
|
||||
.with_children([
|
||||
Label::new(title, style.title_text.clone()).boxed(),
|
||||
// FIXME: Get a better tag type
|
||||
MouseEventHandler::<V>::new(999999, cx, |state, _cx| {
|
||||
let style = style.close_icon.style_for(state, false);
|
||||
icon(style).boxed()
|
||||
})
|
||||
.on_click(gpui::MouseButton::Left, move |_, cx| {
|
||||
let window_id = cx.window_id();
|
||||
cx.remove_window(window_id);
|
||||
})
|
||||
.with_cursor_style(gpui::CursorStyle::PointingHand)
|
||||
.aligned()
|
||||
.right()
|
||||
.boxed(),
|
||||
])
|
||||
.contained()
|
||||
.with_style(style.titlebar)
|
||||
.boxed(),
|
||||
)
|
||||
.with_child(build_modal(cx))
|
||||
.contained()
|
||||
.with_style(style.container)
|
||||
.constrained()
|
||||
.with_height(style.dimensions().y())
|
||||
.boxed()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user