Browse Source

feat: open right side bar helping page shortcut settings on right side

Junyi Du 2 years ago
parent
commit
039c666062

+ 2 - 2
src/main/frontend/components/onboarding.cljs

@@ -1,8 +1,8 @@
 (ns frontend.components.onboarding
   (:require [frontend.context.i18n :refer [t]]
-            [frontend.handler.route :as route-handler]
             [rum.core :as rum]
             [frontend.ui :as ui]
+            [frontend.state :as state]
             [frontend.components.onboarding.setups :as setups]))
 
 (rum/defc intro
@@ -18,7 +18,7 @@
          list
          [{:title "Usage"
            :children [[[:a
-                        {:on-click (fn [] (route-handler/redirect! {:to :shortcut-setting}))}
+                        {:on-click (fn [] (state/sidebar-add-block! (state/get-current-repo) "shortcut-settings" :shortcut-settings))}
                         [:div.flex-row.inline-flex.items-center
                          [:span.mr-1 (t :help/shortcuts)]
                          (ui/icon "command" {:style {:font-size 20}})]]]

+ 9 - 0
src/main/frontend/components/right_sidebar.cljs

@@ -5,6 +5,7 @@
             [frontend.components.onboarding :as onboarding]
             [frontend.components.page :as page]
             [frontend.components.svg :as svg]
+            [frontend.components.shortcut :as shortcut]
             [frontend.context.i18n :refer [t]]
             [frontend.date :as date]
             [frontend.db :as db]
@@ -49,6 +50,11 @@
    (when-let [contents (db/entity [:block/name "contents"])]
      (page/contents-page contents))])
 
+(rum/defc shortcut-settings
+  []
+  [:div.contents.flex-col.flex.ml-3
+   (shortcut/shortcut {:show-title? false})])
+
 (defn- block-with-breadcrumb
   [repo block idx sidebar-key ref?]
   (let [block-id (:block/uuid block)]
@@ -106,6 +112,9 @@
         (db-model/get-page-original-name page-name)]
        [:div.ml-2.slide.mt-2
         (slide/slide page-name)]])
+    
+    :shortcut-settings
+    [(t :help/shortcuts) (shortcut-settings)]
 
     ["" [:span]]))
 

+ 3 - 2
src/main/frontend/components/shortcut.cljs

@@ -168,9 +168,10 @@
         list)]]))
 
 (rum/defc shortcut
-  []
+  [{:keys [show-title?]
+    :or {show-title? true}}]
   [:div
-   [:h1.title (t :help/shortcut-page-title)]
+   (when show-title? [:h1.title (t :help/shortcut-page-title)])
    (trigger-table)
    (markdown-and-orgmode-syntax)
    (shortcut-table :shortcut.category/basics true)