WIP
This commit is contained in:
parent
197f355729
commit
f798b193d0
5 changed files with 79 additions and 47 deletions
|
@ -6,15 +6,15 @@ use db::kvp::KEY_VALUE_STORE;
|
||||||
use editor::{Editor, EditorEvent};
|
use editor::{Editor, EditorEvent};
|
||||||
use futures::AsyncReadExt;
|
use futures::AsyncReadExt;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
div, red, rems, serde_json, AppContext, DismissEvent, Div, EventEmitter, FocusHandle,
|
div, rems, serde_json, AppContext, DismissEvent, Div, EventEmitter, FocusHandle, FocusableView,
|
||||||
FocusableView, Model, PromptLevel, Render, Task, View, ViewContext,
|
Model, PromptLevel, Render, Task, View, ViewContext,
|
||||||
};
|
};
|
||||||
use isahc::Request;
|
use isahc::Request;
|
||||||
use language::Buffer;
|
use language::Buffer;
|
||||||
use project::Project;
|
use project::Project;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use serde_derive::Serialize;
|
use serde_derive::Serialize;
|
||||||
use ui::{prelude::*, Button, ButtonStyle, Label, Tooltip};
|
use ui::{prelude::*, Button, ButtonStyle, IconPosition, Label, Tooltip};
|
||||||
use util::ResultExt;
|
use util::ResultExt;
|
||||||
use workspace::Workspace;
|
use workspace::Workspace;
|
||||||
|
|
||||||
|
@ -285,29 +285,22 @@ impl Render for FeedbackModal {
|
||||||
let open_community_repo =
|
let open_community_repo =
|
||||||
cx.listener(|_, _, cx| cx.dispatch_action(Box::new(OpenZedCommunityRepo)));
|
cx.listener(|_, _, cx| cx.dispatch_action(Box::new(OpenZedCommunityRepo)));
|
||||||
|
|
||||||
// TODO: Nate UI pass
|
|
||||||
v_stack()
|
v_stack()
|
||||||
.elevation_3(cx)
|
.elevation_3(cx)
|
||||||
.key_context("GiveFeedback")
|
.key_context("GiveFeedback")
|
||||||
.on_action(cx.listener(Self::cancel))
|
.on_action(cx.listener(Self::cancel))
|
||||||
.min_w(rems(40.))
|
.min_w(rems(40.))
|
||||||
.max_w(rems(96.))
|
.max_w(rems(96.))
|
||||||
.min_h(rems(24.))
|
.h(rems(32.))
|
||||||
.max_h(rems(42.))
|
|
||||||
.gap_2()
|
|
||||||
.child(
|
.child(
|
||||||
v_stack()
|
v_stack()
|
||||||
.p_4()
|
.px_4()
|
||||||
.child(
|
.pt_4()
|
||||||
div()
|
.pb_2()
|
||||||
.size_full()
|
.child(Label::new("Give Feedback").color(Color::Default))
|
||||||
.child(Label::new("Give Feedback").color(Color::Default))
|
.child(Label::new("This editor supports markdown").color(Color::Muted)),
|
||||||
.child(Label::new("This editor supports markdown").color(Color::Muted)),
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
.child(v_stack()
|
.child(
|
||||||
.p_4()
|
|
||||||
.child(
|
|
||||||
div()
|
div()
|
||||||
.flex_1()
|
.flex_1()
|
||||||
.bg(cx.theme().colors().editor_background)
|
.bg(cx.theme().colors().editor_background)
|
||||||
|
@ -317,37 +310,49 @@ impl Render for FeedbackModal {
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
div().child(
|
div().child(
|
||||||
Label::new(format!(
|
Label::new(
|
||||||
"Characters: {}",
|
if !valid_character_count && characters_remaining < 0 {
|
||||||
characters_remaining
|
"Feedback must be at least 10 characters.".to_string()
|
||||||
))
|
} else if !valid_character_count && characters_remaining > 5000 {
|
||||||
|
"Feedback must be less than 5000 characters.".to_string()
|
||||||
|
} else {
|
||||||
|
format!(
|
||||||
|
"Characters: {}",
|
||||||
|
characters_remaining
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
.map(|this|
|
.map(|this|
|
||||||
if valid_character_count {
|
if valid_character_count {
|
||||||
this.color(Color::Success)
|
this.color(Color::Success)
|
||||||
} else {
|
} else {
|
||||||
this.color(Color::Error)
|
this.color(Color::Error)
|
||||||
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
),
|
)
|
||||||
)
|
.child(
|
||||||
.child(
|
v_stack()
|
||||||
div()
|
.p_4()
|
||||||
|
.child(
|
||||||
|
h_stack()
|
||||||
.bg(cx.theme().colors().editor_background)
|
.bg(cx.theme().colors().editor_background)
|
||||||
.border()
|
.border()
|
||||||
.border_color(cx.theme().colors().border)
|
.border_color(cx.theme().colors().border)
|
||||||
.child(self.email_address_editor.clone())
|
.child(self.email_address_editor.clone()))
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
h_stack()
|
h_stack()
|
||||||
|
.p_4()
|
||||||
.justify_between()
|
.justify_between()
|
||||||
.gap_1()
|
.gap_1()
|
||||||
.child(Button::new("community_repo", "Community Repo")
|
.child(Button::new("community_repo", "Community Repo")
|
||||||
.style(ButtonStyle::Filled)
|
.style(ButtonStyle::Transparent)
|
||||||
.color(Color::Muted)
|
.icon(Icon::ExternalLink)
|
||||||
|
.icon_position(IconPosition::End)
|
||||||
|
.icon_size(IconSize::Small)
|
||||||
.on_click(open_community_repo)
|
.on_click(open_community_repo)
|
||||||
)
|
)
|
||||||
.child(h_stack().justify_between().gap_1()
|
.child(h_stack().gap_1()
|
||||||
.child(
|
.child(
|
||||||
Button::new("cancel_feedback", "Cancel")
|
Button::new("cancel_feedback", "Cancel")
|
||||||
.style(ButtonStyle::Subtle)
|
.style(ButtonStyle::Subtle)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use gpui::{AnyView, DefiniteLength};
|
use gpui::{AnyView, DefiniteLength};
|
||||||
|
|
||||||
use crate::prelude::*;
|
use crate::{prelude::*, IconPosition};
|
||||||
use crate::{
|
use crate::{
|
||||||
ButtonCommon, ButtonLike, ButtonSize, ButtonStyle, Icon, IconSize, Label, LineHeightStyle,
|
ButtonCommon, ButtonLike, ButtonSize, ButtonStyle, Icon, IconSize, Label, LineHeightStyle,
|
||||||
};
|
};
|
||||||
|
@ -14,6 +14,7 @@ pub struct Button {
|
||||||
label_color: Option<Color>,
|
label_color: Option<Color>,
|
||||||
selected_label: Option<SharedString>,
|
selected_label: Option<SharedString>,
|
||||||
icon: Option<Icon>,
|
icon: Option<Icon>,
|
||||||
|
icon_position: Option<IconPosition>,
|
||||||
icon_size: Option<IconSize>,
|
icon_size: Option<IconSize>,
|
||||||
icon_color: Option<Color>,
|
icon_color: Option<Color>,
|
||||||
selected_icon: Option<Icon>,
|
selected_icon: Option<Icon>,
|
||||||
|
@ -27,6 +28,7 @@ impl Button {
|
||||||
label_color: None,
|
label_color: None,
|
||||||
selected_label: None,
|
selected_label: None,
|
||||||
icon: None,
|
icon: None,
|
||||||
|
icon_position: None,
|
||||||
icon_size: None,
|
icon_size: None,
|
||||||
icon_color: None,
|
icon_color: None,
|
||||||
selected_icon: None,
|
selected_icon: None,
|
||||||
|
@ -48,6 +50,11 @@ impl Button {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn icon_position(mut self, icon_position: impl Into<Option<IconPosition>>) -> Self {
|
||||||
|
self.icon_position = icon_position.into();
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
pub fn icon_size(mut self, icon_size: impl Into<Option<IconSize>>) -> Self {
|
pub fn icon_size(mut self, icon_size: impl Into<Option<IconSize>>) -> Self {
|
||||||
self.icon_size = icon_size.into();
|
self.icon_size = icon_size.into();
|
||||||
self
|
self
|
||||||
|
@ -141,19 +148,30 @@ impl RenderOnce for Button {
|
||||||
self.label_color.unwrap_or_default()
|
self.label_color.unwrap_or_default()
|
||||||
};
|
};
|
||||||
|
|
||||||
self.base
|
self.base.child(
|
||||||
.children(self.icon.map(|icon| {
|
h_stack()
|
||||||
ButtonIcon::new(icon)
|
.gap_1()
|
||||||
.disabled(is_disabled)
|
.map(|this| {
|
||||||
.selected(is_selected)
|
if self.icon_position == Some(IconPosition::End) {
|
||||||
.selected_icon(self.selected_icon)
|
this.flex_row_reverse()
|
||||||
.size(self.icon_size)
|
} else {
|
||||||
.color(self.icon_color)
|
this
|
||||||
}))
|
}
|
||||||
.child(
|
})
|
||||||
Label::new(label)
|
.flex_row_reverse()
|
||||||
.color(label_color)
|
.child(
|
||||||
.line_height_style(LineHeightStyle::UILabel),
|
Label::new(label)
|
||||||
)
|
.color(label_color)
|
||||||
|
.line_height_style(LineHeightStyle::UILabel),
|
||||||
|
)
|
||||||
|
.children(self.icon.map(|icon| {
|
||||||
|
ButtonIcon::new(icon)
|
||||||
|
.disabled(is_disabled)
|
||||||
|
.selected(is_selected)
|
||||||
|
.selected_icon(self.selected_icon)
|
||||||
|
.size(self.icon_size)
|
||||||
|
.color(self.icon_color)
|
||||||
|
})),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,13 @@ pub trait ButtonCommon: Clickable + Disableable {
|
||||||
fn tooltip(self, tooltip: impl Fn(&mut WindowContext) -> AnyView + 'static) -> Self;
|
fn tooltip(self, tooltip: impl Fn(&mut WindowContext) -> AnyView + 'static) -> Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy, Default)]
|
||||||
|
pub enum IconPosition {
|
||||||
|
#[default]
|
||||||
|
Start,
|
||||||
|
End,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy, Default)]
|
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy, Default)]
|
||||||
pub enum ButtonStyle {
|
pub enum ButtonStyle {
|
||||||
/// A filled button with a solid background color. Provides emphasis versus
|
/// A filled button with a solid background color. Provides emphasis versus
|
||||||
|
@ -344,6 +351,7 @@ impl RenderOnce for ButtonLike {
|
||||||
.gap_1()
|
.gap_1()
|
||||||
.px_1()
|
.px_1()
|
||||||
.bg(self.style.enabled(cx).background)
|
.bg(self.style.enabled(cx).background)
|
||||||
|
.when(self.disabled, |this| this.cursor_not_allowed())
|
||||||
.when(!self.disabled, |this| {
|
.when(!self.disabled, |this| {
|
||||||
this.cursor_pointer()
|
this.cursor_pointer()
|
||||||
.hover(|hover| hover.bg(self.style.hovered(cx).background))
|
.hover(|hover| hover.bg(self.style.hovered(cx).background))
|
||||||
|
|
|
@ -51,6 +51,7 @@ pub enum Icon {
|
||||||
CopilotDisabled,
|
CopilotDisabled,
|
||||||
Dash,
|
Dash,
|
||||||
Envelope,
|
Envelope,
|
||||||
|
ExternalLink,
|
||||||
ExclamationTriangle,
|
ExclamationTriangle,
|
||||||
Exit,
|
Exit,
|
||||||
File,
|
File,
|
||||||
|
@ -122,13 +123,13 @@ impl Icon {
|
||||||
Icon::Close => "icons/x.svg",
|
Icon::Close => "icons/x.svg",
|
||||||
Icon::Collab => "icons/user_group_16.svg",
|
Icon::Collab => "icons/user_group_16.svg",
|
||||||
Icon::Copilot => "icons/copilot.svg",
|
Icon::Copilot => "icons/copilot.svg",
|
||||||
|
|
||||||
Icon::CopilotInit => "icons/copilot_init.svg",
|
Icon::CopilotInit => "icons/copilot_init.svg",
|
||||||
Icon::CopilotError => "icons/copilot_error.svg",
|
Icon::CopilotError => "icons/copilot_error.svg",
|
||||||
Icon::CopilotDisabled => "icons/copilot_disabled.svg",
|
Icon::CopilotDisabled => "icons/copilot_disabled.svg",
|
||||||
Icon::Dash => "icons/dash.svg",
|
Icon::Dash => "icons/dash.svg",
|
||||||
Icon::Envelope => "icons/feedback.svg",
|
Icon::Envelope => "icons/feedback.svg",
|
||||||
Icon::ExclamationTriangle => "icons/warning.svg",
|
Icon::ExclamationTriangle => "icons/warning.svg",
|
||||||
|
Icon::ExternalLink => "icons/external_link.svg",
|
||||||
Icon::Exit => "icons/exit.svg",
|
Icon::Exit => "icons/exit.svg",
|
||||||
Icon::File => "icons/file.svg",
|
Icon::File => "icons/file.svg",
|
||||||
Icon::FileDoc => "icons/file_icons/book.svg",
|
Icon::FileDoc => "icons/file_icons/book.svg",
|
||||||
|
|
|
@ -12,6 +12,6 @@ pub use crate::selectable::*;
|
||||||
pub use crate::{h_stack, v_stack};
|
pub use crate::{h_stack, v_stack};
|
||||||
pub use crate::{Button, ButtonSize, ButtonStyle, IconButton};
|
pub use crate::{Button, ButtonSize, ButtonStyle, IconButton};
|
||||||
pub use crate::{ButtonCommon, Color, StyledExt};
|
pub use crate::{ButtonCommon, Color, StyledExt};
|
||||||
pub use crate::{Icon, IconElement, IconSize};
|
pub use crate::{Icon, IconElement, IconPosition, IconSize};
|
||||||
pub use crate::{Label, LabelCommon, LabelSize, LineHeightStyle};
|
pub use crate::{Label, LabelCommon, LabelSize, LineHeightStyle};
|
||||||
pub use theme::ActiveTheme;
|
pub use theme::ActiveTheme;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue