Pārlūkot izejas kodu

enhance(shortcuts): plugins shortcuts tables

charlie 2 gadi atpakaļ
vecāks
revīzija
82c36b7dea

+ 23 - 20
src/main/frontend/components/shortcut.cljs

@@ -72,26 +72,28 @@
                        (customize-shortcut-dialog k action-name displayed-binding)
                        {:center? true})))])))
 
-(rum/defc shortcut-table < rum/reactive
-  ([name]
-   (shortcut-table name false))
-  ([name configurable?]
-   (let [shortcut-config (rum/cursor-in
-                          state/state
-                          [:config (state/get-current-repo) :shortcuts])
-         _ (rum/react shortcut-config)]
-     [:div
-      [:table
-       [:thead
-        [:tr
-         [:th.text-left [:b (t name)]]
-         [:th.text-right]]]
-       [:tbody
-        (map (fn [[k {:keys [binding]}]]
-               [:tr {:key (str k)}
-                [:td.text-left (t (dh/decorate-namespace k))]
-                (shortcut-col k binding configurable? (t (dh/decorate-namespace k)))])
-          (dh/binding-by-category name))]]])))
+(rum/defcs shortcut-table
+  < rum/reactive
+    (rum/local true ::folded?)
+  [state name configurable?]
+  (let [*folded? (::folded? state)
+        _        (state/sub [:config (state/get-current-repo) :shortcuts])]
+    [:div.cp__shortcut-table-wrap
+     [:a.fold
+      {:on-click #(reset! *folded? (not @*folded?))}
+      (ui/icon (if @*folded? "chevron-left" "chevron-down"))]
+     [:table
+      [:thead
+       [:tr
+        [:th.text-left [:b (t name)]]
+        [:th.text-right]]]
+      (when-not @*folded?
+        [:tbody
+         (map (fn [[k {:keys [binding]}]]
+                [:tr {:key (str k)}
+                 [:td.text-left (t (dh/decorate-namespace k))]
+                 (shortcut-col k binding configurable? (t (dh/decorate-namespace k)))])
+              (dh/binding-by-category name))])]]))
 
 (rum/defc trigger-table []
   [:table
@@ -187,6 +189,7 @@
    (shortcut-table :shortcut.category/formatting true)
    (shortcut-table :shortcut.category/toggle true)
    (when (state/enable-whiteboards?) (shortcut-table :shortcut.category/whiteboard true))
+   (shortcut-table :shortcut.category/plugins true)
    (shortcut-table :shortcut.category/others true)])
 
 (rum/defc keymap-pane

+ 11 - 0
src/main/frontend/components/shortcut.css

@@ -10,4 +10,15 @@
       }
     }
   }
+}
+
+.cp__shortcut {
+  &-table-wrap {
+    @apply relative;
+
+    a.fold {
+      @apply absolute right-0 top-0 w-full pt-3 pr-3
+      flex items-center justify-end select-none;
+    }
+  }
 }

+ 4 - 1
src/main/frontend/modules/shortcut/config.cljs

@@ -926,7 +926,10 @@
     :dev/show-block-ast
     :dev/show-page-data
     :dev/show-page-ast
-    :ui/clear-all-notifications]})
+    :ui/clear-all-notifications]
+
+   :shortcut.category/plugins
+   []})
 
 (let [category-maps {::category (set (keys category*))
                      ::dicts/category (set (keys dicts/category))}]

+ 1 - 0
src/main/frontend/modules/shortcut/dicts.cljc

@@ -171,6 +171,7 @@
    :shortcut.category/block-selection "Block selection (press Esc to quit selection)"
    :shortcut.category/toggle "Toggle"
    :shortcut.category/whiteboard "Whiteboard"
+   :shortcut.category/plugins "Plugins"
    :shortcut.category/others "Others"})
 
 (def ^:large-vars/data-var dicts