Added CTA buttons to welcome experience
Co-authored-by: Nathan <nathan@zed.dev>
This commit is contained in:
parent
9dee2ca2be
commit
f89f33347d
5 changed files with 102 additions and 48 deletions
|
@ -854,6 +854,7 @@ pub struct FeedbackStyle {
|
|||
#[derive(Clone, Deserialize, Default)]
|
||||
pub struct WelcomeStyle {
|
||||
pub checkbox: CheckboxStyle,
|
||||
pub button: Interactive<ContainedText>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, Default)]
|
||||
|
|
|
@ -18,5 +18,6 @@ gpui = { path = "../gpui" }
|
|||
project = { path = "../project" }
|
||||
settings = { path = "../settings" }
|
||||
theme = { path = "../theme" }
|
||||
theme_selector = { path = "../theme_selector" }
|
||||
util = { path = "../util" }
|
||||
workspace = { path = "../workspace" }
|
|
@ -1,12 +1,14 @@
|
|||
use std::borrow::Cow;
|
||||
|
||||
use gpui::{
|
||||
color::Color,
|
||||
elements::{Canvas, Empty, Flex, Label, MouseEventHandler, ParentElement, Stack, Svg},
|
||||
geometry::rect::RectF,
|
||||
Element, ElementBox, Entity, MouseRegion, MutableAppContext, RenderContext, Subscription, View,
|
||||
ViewContext,
|
||||
Action, Element, ElementBox, Entity, MouseButton, MouseRegion, MutableAppContext,
|
||||
RenderContext, Subscription, View, ViewContext,
|
||||
};
|
||||
use settings::{settings_file::SettingsFile, Settings, SettingsFileContent};
|
||||
use theme::CheckboxStyle;
|
||||
use theme::{CheckboxStyle, ContainedText, Interactive};
|
||||
use workspace::{item::Item, Welcome, Workspace};
|
||||
|
||||
pub fn init(cx: &mut MutableAppContext) {
|
||||
|
@ -86,6 +88,8 @@ impl View for WelcomePage {
|
|||
theme.editor.hover_popover.prose.clone(),
|
||||
)
|
||||
.boxed(),
|
||||
self.render_cta_button(2, "Choose a theme", theme_selector::Toggle, cx),
|
||||
self.render_cta_button(3, "Choose a keymap", theme_selector::Toggle, cx),
|
||||
Flex::row()
|
||||
.with_children([
|
||||
self.render_settings_checkbox::<Metrics>(
|
||||
|
@ -141,6 +145,32 @@ impl WelcomePage {
|
|||
}
|
||||
}
|
||||
|
||||
fn render_cta_button<L, A>(
|
||||
&self,
|
||||
region_id: usize,
|
||||
label: L,
|
||||
action: A,
|
||||
cx: &mut RenderContext<Self>,
|
||||
) -> ElementBox
|
||||
where
|
||||
L: Into<Cow<'static, str>>,
|
||||
A: 'static + Action + Clone,
|
||||
{
|
||||
let theme = cx.global::<Settings>().theme.clone();
|
||||
MouseEventHandler::<A>::new(region_id, cx, |state, _| {
|
||||
let style = theme.welcome.button.style_for(state, false);
|
||||
Label::new(label, style.text.clone())
|
||||
.contained()
|
||||
.with_style(style.container)
|
||||
.boxed()
|
||||
})
|
||||
.on_click(MouseButton::Left, move |_, cx| {
|
||||
cx.dispatch_action(action.clone())
|
||||
})
|
||||
.aligned()
|
||||
.boxed()
|
||||
}
|
||||
|
||||
fn render_settings_checkbox<T: 'static>(
|
||||
&self,
|
||||
style: &CheckboxStyle,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue