Take a first pass at styling the welcome screen (#3601)

This PR is a first pass at styling the welcome screen in Zed2.

Here's the current state:

<img width="1237" alt="Screenshot 2023-12-11 at 7 00 43 PM"
src="https://github.com/zed-industries/zed/assets/1486634/a0cbd5ca-7331-4785-bf46-f83fc4cb3bb6">

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2023-12-11 19:06:33 -05:00 committed by GitHub
parent 149e90c3d9
commit 39a115b264
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,7 +4,7 @@ mod base_keymap_setting;
use client::TelemetrySettings; use client::TelemetrySettings;
use db::kvp::KEY_VALUE_STORE; use db::kvp::KEY_VALUE_STORE;
use gpui::{ use gpui::{
div, svg, AnyElement, AppContext, Div, EventEmitter, FocusHandle, Focusable, FocusableView, svg, AnyElement, AppContext, Div, EventEmitter, FocusHandle, Focusable, FocusableView,
InteractiveElement, ParentElement, Render, Styled, Subscription, View, ViewContext, InteractiveElement, ParentElement, Render, Styled, Subscription, View, ViewContext,
VisualContext, WeakView, WindowContext, VisualContext, WeakView, WindowContext,
}; };
@ -60,139 +60,152 @@ impl Render for WelcomePage {
type Element = Focusable<Div>; type Element = Focusable<Div>;
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> Self::Element { fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> Self::Element {
div() h_stack().full().track_focus(&self.focus_handle).child(
.full() v_stack()
.track_focus(&self.focus_handle) .w_96()
.relative() .gap_4()
.child( .mx_auto()
v_stack() .child(
.w_96() svg()
.mx_auto() .path("icons/logo_96.svg")
.child( .text_color(gpui::white())
svg() .w(px(96.))
.path("icons/logo_96.svg") .h(px(96.))
.text_color(gpui::white()) .mx_auto(),
.w(px(96.)) )
.h(px(96.)) .child(Label::new("Code at the speed of thought"))
.mx_auto(), .child(
) v_stack()
.child(Label::new("Code at the speed of thought")) .gap_2()
.child( .child(
Button::new("choose-theme", "Choose a theme") Button::new("choose-theme", "Choose a theme")
.full_width() .full_width()
.on_click(cx.listener(|this, _, cx| { .on_click(cx.listener(|this, _, cx| {
this.workspace this.workspace
.update(cx, |workspace, cx| { .update(cx, |workspace, cx| {
theme_selector::toggle(workspace, &Default::default(), cx) theme_selector::toggle(
}) workspace,
.ok(); &Default::default(),
})), cx,
) )
.child( })
Button::new("choose-keymap", "Choose a keymap") .ok();
.full_width() })),
.on_click(cx.listener(|this, _, cx| { )
this.workspace .child(
.update(cx, |workspace, cx| { Button::new("choose-keymap", "Choose a keymap")
base_keymap_picker::toggle( .full_width()
workspace, .on_click(cx.listener(|this, _, cx| {
&Default::default(), this.workspace
cx, .update(cx, |workspace, cx| {
base_keymap_picker::toggle(
workspace,
&Default::default(),
cx,
)
})
.ok();
})),
)
.child(
Button::new("install-cli", "Install the CLI")
.full_width()
.on_click(cx.listener(|_, _, cx| {
cx.app_mut()
.spawn(
|cx| async move { install_cli::install_cli(&cx).await },
) )
}) .detach_and_log_err(cx);
.ok(); })),
})), ),
) )
.child( .child(
Button::new("install-cli", "Install the CLI") v_stack()
.full_width() .p_3()
.on_click(cx.listener(|_, _, cx| { .gap_2()
cx.app_mut() .bg(cx.theme().colors().elevated_surface_background)
.spawn(|cx| async move { install_cli::install_cli(&cx).await }) .border_1()
.detach_and_log_err(cx); .border_color(cx.theme().colors().border)
})), .rounded_md()
) .child(
.child( // todo!("vim setting")
v_stack() h_stack()
.bg(cx.theme().colors().elevated_surface_background) .gap_2()
.child( .child(
// todo!("vim setting") Checkbox::new(
h_stack() "enable-vim",
.child( if false
Checkbox::new( /* VimSettings::get_global(cx).enabled */
"enable-vim", {
if false ui::Selection::Selected
/* VimSettings::get_global(cx).enabled */ } else {
{ ui::Selection::Unselected
ui::Selection::Selected },
} else { ),
ui::Selection::Unselected // .on_click(cx.listener(
}, // move |this, selection, cx| {
), // this.update_settings::<VimSettings>(
// .on_click(cx.listener( // selection,
// move |this, selection, cx| { // cx,
// this.update_settings::<VimSettings>( // |settings, value| settings.enabled = value,
// selection, // );
// cx, // },
// |settings, value| settings.enabled = value, // )),
// ); )
// }, .child(Label::new("Enable vim mode")),
// )), )
.child(
h_stack()
.gap_2()
.child(
Checkbox::new(
"enable-telemetry",
if TelemetrySettings::get_global(cx).metrics {
ui::Selection::Selected
} else {
ui::Selection::Unselected
},
) )
.child("Enable vim mode"), .on_click(cx.listener(
) move |this, selection, cx| {
.child( this.update_settings::<TelemetrySettings>(
h_stack() selection,
.child( cx,
Checkbox::new( |settings, value| settings.metrics = Some(value),
"enable-telemetry", );
if TelemetrySettings::get_global(cx).metrics { },
ui::Selection::Selected )),
} else { )
ui::Selection::Unselected .child(Label::new("Send anonymous usage data")),
}, )
) .child(
.on_click( h_stack()
cx.listener(move |this, selection, cx| { .gap_2()
this.update_settings::<TelemetrySettings>( .child(
selection, Checkbox::new(
cx, "enable-crash",
|settings, value| { if TelemetrySettings::get_global(cx).diagnostics {
settings.metrics = Some(value) ui::Selection::Selected
}, } else {
); ui::Selection::Unselected
}), },
),
) )
.child("Send usage data"), .on_click(cx.listener(
) move |this, selection, cx| {
.child( this.update_settings::<TelemetrySettings>(
h_stack() selection,
.child( cx,
Checkbox::new( |settings, value| {
"enable-crash", settings.diagnostics = Some(value)
if TelemetrySettings::get_global(cx).diagnostics { },
ui::Selection::Selected );
} else { },
ui::Selection::Unselected )),
}, )
) .child(Label::new("Send crash reports")),
.on_click( ),
cx.listener(move |this, selection, cx| { ),
this.update_settings::<TelemetrySettings>( )
selection,
cx,
|settings, value| {
settings.diagnostics = Some(value)
},
);
}),
),
)
.child("Send crash reports"),
),
),
)
} }
} }