Просмотр исходного кода

enhance(ui): toggle accent colors picker modal

charlie 2 лет назад
Родитель
Сommit
5d6891b456

+ 10 - 5
src/main/frontend/handler/events.cljs

@@ -338,11 +338,16 @@
 (defmethod handle :modal/show-themes-modal [_]
   (plugin/open-select-theme!))
 
-(defmethod handle :modal/show-accent-colors-modal [_]
-  (state/set-sub-modal!
-    #(settings/modal-accent-colors-inner)
-    {:center? true
-     :label "accent-colors-picker"}))
+(defmethod handle :modal/toggle-accent-colors-modal [_]
+  (let [label "accent-colors-picker"]
+    (if (or (= label (state/get-modal-id))
+          (= label (some-> (state/get-sub-modals) (first) :modal/id)))
+      (state/close-sub-modal! label)
+      (state/set-sub-modal!
+        #(settings/modal-accent-colors-inner)
+        {:center? true
+         :id      label
+         :label   label}))))
 
 (rum/defc modal-output
   [content]

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

@@ -534,7 +534,7 @@
                                              :fn      state/unset-color-accent!}
 
    :ui/accent-colors-picker                 {:binding "c c"
-                                             :fn      #(state/pub-event! [:modal/show-accent-colors-modal])}
+                                             :fn      #(state/pub-event! [:modal/toggle-accent-colors-modal])}
 
    :git/commit                              {:binding  "mod+g c"
                                              :inactive (not (util/electron?))