Remove welcome experience action

Mikayla Maki and Nathan created

Make logo switch between light and dark

co-authored-by: Nathan <nathan@zed.dev>

Change summary

Cargo.lock                                |  1 
assets/images/zed-logo-90x90.png          |  0 
crates/project_panel/src/project_panel.rs |  2 
crates/welcome/Cargo.toml                 |  1 
crates/welcome/src/welcome.rs             | 25 ++++++++++++++-
crates/zed/src/main.rs                    | 21 ++++++-------
crates/zed/src/zed.rs                     | 29 -----------------
styles/src/styleTree/projectPanel.ts      | 39 ++++++++----------------
8 files changed, 51 insertions(+), 67 deletions(-)

Detailed changes

Cargo.lock 🔗

@@ -8029,6 +8029,7 @@ name = "welcome"
 version = "0.1.0"
 dependencies = [
  "anyhow",
+ "db",
  "editor",
  "fuzzy",
  "gpui",

crates/project_panel/src/project_panel.rs 🔗

@@ -1329,7 +1329,7 @@ impl View for ProjectPanel {
 
                             keystroke_label(
                                 parent_view_id,
-                                "Open project",
+                                "Open a project",
                                 &button_style,
                                 context_menu_item.keystroke,
                                 workspace::Open,

crates/welcome/Cargo.toml 🔗

@@ -16,6 +16,7 @@ log = "0.4"
 editor = { path = "../editor" }
 fuzzy = { path = "../fuzzy" }
 gpui = { path = "../gpui" }
+db = { path = "../db" }
 install_cli = { path = "../install_cli" }
 project = { path = "../project" }
 settings = { path = "../settings" }

crates/welcome/src/welcome.rs 🔗

@@ -1,7 +1,8 @@
 mod base_keymap_picker;
 
-use std::borrow::Cow;
+use std::{borrow::Cow, sync::Arc};
 
+use db::kvp::KEY_VALUE_STORE;
 use gpui::{
     elements::{Empty, Flex, Label, MouseEventHandler, ParentElement, Svg},
     Action, Element, ElementBox, Entity, MouseButton, MutableAppContext, RenderContext,
@@ -9,10 +10,15 @@ use gpui::{
 };
 use settings::{settings_file::SettingsFile, Settings, SettingsFileContent};
 use theme::CheckboxStyle;
-use workspace::{item::Item, PaneBackdrop, Welcome, Workspace, WorkspaceId};
+use workspace::{
+    item::Item, open_new, sidebar::SidebarSide, AppState, PaneBackdrop, Welcome, Workspace,
+    WorkspaceId,
+};
 
 use crate::base_keymap_picker::ToggleBaseKeymapSelector;
 
+pub const FIRST_OPEN: &str = "first_open";
+
 pub fn init(cx: &mut MutableAppContext) {
     cx.add_action(|workspace: &mut Workspace, _: &Welcome, cx| {
         let welcome_page = cx.add_view(WelcomePage::new);
@@ -22,6 +28,21 @@ pub fn init(cx: &mut MutableAppContext) {
     base_keymap_picker::init(cx);
 }
 
+pub fn show_welcome_experience(app_state: &Arc<AppState>, cx: &mut MutableAppContext) {
+    open_new(&app_state, cx, |workspace, cx| {
+        workspace.toggle_sidebar(SidebarSide::Left, cx);
+        let welcome_page = cx.add_view(|cx| WelcomePage::new(cx));
+        workspace.add_item_to_center(Box::new(welcome_page.clone()), cx);
+        cx.focus(welcome_page);
+        cx.notify();
+    })
+    .detach();
+
+    db::write_and_log(cx, || {
+        KEY_VALUE_STORE.write_kvp(FIRST_OPEN.to_string(), "false".to_string())
+    });
+}
+
 pub struct WelcomePage {
     _settings_subscription: Subscription,
 }

crates/zed/src/main.rs 🔗

@@ -36,6 +36,7 @@ use std::{
     path::PathBuf, sync::Arc, thread, time::Duration,
 };
 use terminal_view::{get_working_directory, TerminalView};
+use welcome::{show_welcome_experience, FIRST_OPEN};
 
 use fs::RealFs;
 use settings::watched_json::WatchedJsonFile;
@@ -46,10 +47,7 @@ use util::{channel::RELEASE_CHANNEL, paths, ResultExt, TryFutureExt};
 use workspace::{
     self, item::ItemHandle, notifications::NotifyResultExt, AppState, NewFile, OpenPaths, Workspace,
 };
-use zed::{
-    self, build_window_options, initialize_workspace, languages, menus, WelcomeExperience,
-    FIRST_OPEN,
-};
+use zed::{self, build_window_options, initialize_workspace, languages, menus};
 
 fn main() {
     let http = http::client();
@@ -206,7 +204,7 @@ fn main() {
             cx.platform().activate(true);
             let paths = collect_path_args();
             if paths.is_empty() {
-                cx.spawn(|cx| async move { restore_or_create_workspace(cx).await })
+                cx.spawn(|cx| async move { restore_or_create_workspace(&app_state, cx).await })
                     .detach()
             } else {
                 cx.dispatch_global_action(OpenPaths { paths });
@@ -219,8 +217,11 @@ fn main() {
                 cx.update(|cx| workspace::open_paths(&paths, &app_state, None, cx))
                     .detach();
             } else {
-                cx.spawn(|cx| async move { restore_or_create_workspace(cx).await })
-                    .detach()
+                cx.spawn({
+                    let app_state = app_state.clone();
+                    |cx| async move { restore_or_create_workspace(&app_state, cx).await }
+                })
+                .detach()
             }
 
             cx.spawn(|cx| {
@@ -259,7 +260,7 @@ fn main() {
     });
 }
 
-async fn restore_or_create_workspace(mut cx: AsyncAppContext) {
+async fn restore_or_create_workspace(app_state: &Arc<AppState>, mut cx: AsyncAppContext) {
     if let Some(location) = workspace::last_opened_workspace_paths().await {
         cx.update(|cx| {
             cx.dispatch_global_action(OpenPaths {
@@ -267,9 +268,7 @@ async fn restore_or_create_workspace(mut cx: AsyncAppContext) {
             })
         });
     } else if matches!(KEY_VALUE_STORE.read_kvp(FIRST_OPEN), Ok(None)) {
-        cx.update(|cx| {
-            cx.dispatch_global_action(WelcomeExperience);
-        });
+        cx.update(|cx| show_welcome_experience(app_state, cx));
     } else {
         cx.update(|cx| {
             cx.dispatch_global_action(NewFile);

crates/zed/src/zed.rs 🔗

@@ -8,7 +8,6 @@ use breadcrumbs::Breadcrumbs;
 pub use client;
 use collab_ui::{CollabTitlebarItem, ToggleContactsMenu};
 use collections::VecDeque;
-use db::kvp::KEY_VALUE_STORE;
 pub use editor;
 use editor::{Editor, MultiBuffer};
 
@@ -35,9 +34,7 @@ use std::{borrow::Cow, env, path::Path, str, sync::Arc};
 use util::{channel::ReleaseChannel, paths, ResultExt, StaffMode};
 use uuid::Uuid;
 pub use workspace;
-use workspace::{open_new, sidebar::SidebarSide, AppState, Restart, Workspace};
-
-pub const FIRST_OPEN: &str = "first_open";
+use workspace::{sidebar::SidebarSide, AppState, Restart, Workspace};
 
 #[derive(Deserialize, Clone, PartialEq)]
 pub struct OpenBrowser {
@@ -69,7 +66,6 @@ actions!(
         DecreaseBufferFontSize,
         ResetBufferFontSize,
         ResetDatabase,
-        WelcomeExperience
     ]
 );
 
@@ -258,29 +254,6 @@ pub fn init(app_state: &Arc<AppState>, cx: &mut gpui::MutableAppContext) {
             workspace.toggle_sidebar_item_focus(SidebarSide::Left, 0, cx);
         },
     );
-
-    cx.add_global_action({
-        let app_state = app_state.clone();
-        move |_: &WelcomeExperience, cx| {
-            if !matches!(KEY_VALUE_STORE.read_kvp(FIRST_OPEN), Ok(None)) {
-                return; //noop, in case someone fires this from the command palette
-            }
-
-            open_new(&app_state, cx, |workspace, cx| {
-                workspace.toggle_sidebar(SidebarSide::Left, cx);
-                let welcome_page = cx.add_view(|cx| welcome::WelcomePage::new(cx));
-                workspace.add_item_to_center(Box::new(welcome_page.clone()), cx);
-                cx.focus(welcome_page);
-                cx.notify();
-            })
-            .detach();
-
-            db::write_and_log(cx, || {
-                KEY_VALUE_STORE.write_kvp(FIRST_OPEN.to_string(), "false".to_string())
-            });
-        }
-    });
-
     activity_indicator::init(cx);
     call::init(app_state.client.clone(), app_state.user_store.clone(), cx);
     settings::KeymapFileContent::load_defaults(cx);

styles/src/styleTree/projectPanel.ts 🔗

@@ -30,37 +30,26 @@ export default function projectPanel(colorScheme: ColorScheme) {
 
     return {
         openProjectButton: {
-            ...text(layer, "mono", "active", { size: "sm" }),
-            background: background(layer, "on"),
-            cornerRadius: 6,
-            border: border(layer, "on"),
+            background: background(layer),
+            border: border(layer, "active"),
+            cornerRadius: 4,
             margin: {
-                top: 20,
-                left: 10,
-                right: 10
+                top: 16,
+                left: 16,
+                right: 16,
             },
             padding: {
-                bottom: 2,
-                left: 10,
-                right: 10,
-                top: 2,
-            },
-            active: {
-                ...text(layer, "mono", "on", "inverted"),
-                background: background(layer, "on", "inverted"),
-                border: border(layer, "on", "inverted"),
-            },
-            clicked: {
-                ...text(layer, "mono", "on", "pressed"),
-                background: background(layer, "on", "pressed"),
-                border: border(layer, "on", "pressed"),
+                top: 3,
+                bottom: 3,
+                left: 7,
+                right: 7,
             },
+            ...text(layer, "sans", "default", { size: "sm" }),
             hover: {
-                ...text(layer, "mono", "on", "hovered"),
-                background: background(layer, "on", "hovered"),
-                border: border(layer, "on", "hovered"),
+                ...text(layer, "sans", "default", { size: "sm" }),
+                background: background(layer, "hovered"),
+                border: border(layer, "active"),
             },
-
         },
         background: background(layer),
         padding: { left: 12, right: 12, top: 6, bottom: 6 },