From 37f910949d343ea48f16fecd97d4eb77cf4bc6c2 Mon Sep 17 00:00:00 2001 From: Joseph Lyons Date: Thu, 23 Feb 2023 16:30:00 -0500 Subject: [PATCH 1/3] Add link to community repo in feedback editor --- crates/feedback/src/feedback.rs | 14 ++++++- crates/feedback/src/feedback_info_text.rs | 47 ++++++++++++++++++++--- crates/theme/src/theme.rs | 2 + styles/src/styleTree/feedback.ts | 2 + 4 files changed, 59 insertions(+), 6 deletions(-) diff --git a/crates/feedback/src/feedback.rs b/crates/feedback/src/feedback.rs index f95f24f557485211a854e5de680310f5fac50784..cd72cdf9508951c0ddfd4e8f68b0ce7f55c026de 100644 --- a/crates/feedback/src/feedback.rs +++ b/crates/feedback/src/feedback.rs @@ -20,7 +20,12 @@ impl_actions!(zed, [OpenBrowser]); actions!( zed, - [CopySystemSpecsIntoClipboard, FileBugReport, RequestFeature] + [ + CopySystemSpecsIntoClipboard, + FileBugReport, + RequestFeature, + OpenZedCommunityRepo + ] ); pub fn init(app_state: Arc, cx: &mut MutableAppContext) { @@ -66,4 +71,11 @@ pub fn init(app_state: Arc, cx: &mut MutableAppContext) { }); }, ); + + cx.add_action( + |_: &mut Workspace, _: &OpenZedCommunityRepo, cx: &mut ViewContext| { + let url = "https://github.com/zed-industries/community"; + cx.dispatch_action(OpenBrowser { url: url.into() }); + }, + ); } diff --git a/crates/feedback/src/feedback_info_text.rs b/crates/feedback/src/feedback_info_text.rs index 6693a7cb44f9c1ff9005cdf169f20b90c82ec625..5e0378b95ee80080b0e60173b438b963a63fc6c2 100644 --- a/crates/feedback/src/feedback_info_text.rs +++ b/crates/feedback/src/feedback_info_text.rs @@ -1,10 +1,12 @@ use gpui::{ - elements::Label, Element, ElementBox, Entity, RenderContext, View, ViewContext, ViewHandle, + elements::{Flex, Label, MouseEventHandler, ParentElement, Text}, + CursorStyle, Element, ElementBox, Entity, MouseButton, RenderContext, View, ViewContext, + ViewHandle, }; use settings::Settings; use workspace::{item::ItemHandle, ToolbarItemLocation, ToolbarItemView}; -use crate::feedback_editor::FeedbackEditor; +use crate::{feedback_editor::FeedbackEditor, OpenZedCommunityRepo}; pub struct FeedbackInfoText { active_item: Option>, @@ -29,9 +31,44 @@ impl View for FeedbackInfoText { fn render(&mut self, cx: &mut RenderContext) -> ElementBox { let theme = cx.global::().theme.clone(); - let text = "We read whatever you submit here. For issues and discussions, visit the community repo on GitHub."; - Label::new(text, theme.feedback.info_text.text.clone()) - .contained() + + Flex::row() + .with_child( + Text::new( + "We read whatever you submit here. For issues and discussions, visit the ", + theme.feedback.info_text.text.clone(), + ) + .with_soft_wrap(false) + .aligned() + .boxed(), + ) + .with_child( + MouseEventHandler::::new(0, cx, |state, _| { + let text = if state.hovered() { + theme.feedback.link_hover_text.clone() + } else { + theme.feedback.link_text.clone() + }; + + Label::new("community repo", text.text) + .contained() + .aligned() + .left() + .clipped() + .boxed() + }) + .with_cursor_style(CursorStyle::PointingHand) + .on_click(MouseButton::Left, |_, cx| { + cx.dispatch_action(OpenZedCommunityRepo) + }) + .boxed(), + ) + .with_child( + Text::new(" on GitHub.", theme.feedback.info_text.text.clone()) + .with_soft_wrap(false) + .aligned() + .boxed(), + ) .aligned() .left() .clipped() diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index bc338bbe269369f29fdea1d5794d30c172d2e316..bc3b048010b1b4c595c74a5127ce550ebb4014c6 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -812,6 +812,8 @@ pub struct FeedbackStyle { pub submit_button: Interactive, pub button_margin: f32, pub info_text: ContainedText, + pub link_text: ContainedText, + pub link_hover_text: ContainedText, } #[derive(Clone, Deserialize, Default)] diff --git a/styles/src/styleTree/feedback.ts b/styles/src/styleTree/feedback.ts index 46cb867ad90613325ea2cfa76800d7761a64f080..34922b4d00b314d07b7717095026320f27b9ba98 100644 --- a/styles/src/styleTree/feedback.ts +++ b/styles/src/styleTree/feedback.ts @@ -33,5 +33,7 @@ export default function feedback(colorScheme: ColorScheme) { }, button_margin: 8, info_text: text(layer, "sans", "default", { size: "xs" }), + link_text: text(layer, "sans", "default", { size: "xs", underline: true }), + link_hover_text: text(layer, "sans", "hovered", { size: "xs", underline: true }) }; } From f8f1a3f86ea361726c6c3a0d2c6c6bfd3c0debb9 Mon Sep 17 00:00:00 2001 From: Joseph Lyons Date: Fri, 24 Feb 2023 08:46:28 -0500 Subject: [PATCH 2/3] Unify text style names --- crates/feedback/src/feedback_info_text.rs | 8 ++++---- crates/theme/src/theme.rs | 6 +++--- styles/src/styleTree/feedback.ts | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/feedback/src/feedback_info_text.rs b/crates/feedback/src/feedback_info_text.rs index 5e0378b95ee80080b0e60173b438b963a63fc6c2..0ba5ef49f71a3f0e97a8c1aa55ee2efe85498939 100644 --- a/crates/feedback/src/feedback_info_text.rs +++ b/crates/feedback/src/feedback_info_text.rs @@ -36,7 +36,7 @@ impl View for FeedbackInfoText { .with_child( Text::new( "We read whatever you submit here. For issues and discussions, visit the ", - theme.feedback.info_text.text.clone(), + theme.feedback.info_text_default.text.clone(), ) .with_soft_wrap(false) .aligned() @@ -45,9 +45,9 @@ impl View for FeedbackInfoText { .with_child( MouseEventHandler::::new(0, cx, |state, _| { let text = if state.hovered() { - theme.feedback.link_hover_text.clone() + theme.feedback.link_text_hover.clone() } else { - theme.feedback.link_text.clone() + theme.feedback.link_text_default.clone() }; Label::new("community repo", text.text) @@ -64,7 +64,7 @@ impl View for FeedbackInfoText { .boxed(), ) .with_child( - Text::new(" on GitHub.", theme.feedback.info_text.text.clone()) + Text::new(" on GitHub.", theme.feedback.info_text_default.text.clone()) .with_soft_wrap(false) .aligned() .boxed(), diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index bc3b048010b1b4c595c74a5127ce550ebb4014c6..ba66ea2d86c79791d7aeceac5f8d4c8655e79f5b 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -811,9 +811,9 @@ pub struct TerminalStyle { pub struct FeedbackStyle { pub submit_button: Interactive, pub button_margin: f32, - pub info_text: ContainedText, - pub link_text: ContainedText, - pub link_hover_text: ContainedText, + pub info_text_default: ContainedText, + pub link_text_default: ContainedText, + pub link_text_hover: ContainedText, } #[derive(Clone, Deserialize, Default)] diff --git a/styles/src/styleTree/feedback.ts b/styles/src/styleTree/feedback.ts index 34922b4d00b314d07b7717095026320f27b9ba98..8e3c6cda97501a5fbb220a39ff13cc70b1bd3763 100644 --- a/styles/src/styleTree/feedback.ts +++ b/styles/src/styleTree/feedback.ts @@ -32,8 +32,8 @@ export default function feedback(colorScheme: ColorScheme) { }, }, button_margin: 8, - info_text: text(layer, "sans", "default", { size: "xs" }), - link_text: text(layer, "sans", "default", { size: "xs", underline: true }), - link_hover_text: text(layer, "sans", "hovered", { size: "xs", underline: true }) + info_text_default: text(layer, "sans", "default", { size: "xs" }), + link_text_default: text(layer, "sans", "default", { size: "xs", underline: true }), + link_text_hover: text(layer, "sans", "hovered", { size: "xs", underline: true }) }; } From 72197802a2ed966fa6619abff0c82d6f663166da Mon Sep 17 00:00:00 2001 From: Joseph Lyons Date: Fri, 24 Feb 2023 08:53:58 -0500 Subject: [PATCH 3/3] Tweak code to remove duplication --- crates/feedback/src/feedback_info_text.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/feedback/src/feedback_info_text.rs b/crates/feedback/src/feedback_info_text.rs index 0ba5ef49f71a3f0e97a8c1aa55ee2efe85498939..8c3105010983d7a18bf9fefc71c92402a54faa33 100644 --- a/crates/feedback/src/feedback_info_text.rs +++ b/crates/feedback/src/feedback_info_text.rs @@ -44,13 +44,13 @@ impl View for FeedbackInfoText { ) .with_child( MouseEventHandler::::new(0, cx, |state, _| { - let text = if state.hovered() { - theme.feedback.link_text_hover.clone() + let contained_text = if state.hovered() { + &theme.feedback.link_text_hover } else { - theme.feedback.link_text_default.clone() + &theme.feedback.link_text_default }; - Label::new("community repo", text.text) + Label::new("community repo", contained_text.text.clone()) .contained() .aligned() .left()