瀏覽代碼

enhance(ui): support hide close button option for the shui dialog

charlie 1 年之前
父節點
當前提交
d278067f8c

+ 5 - 3
deps/shui/src/logseq/shui/dialog/core.cljs

@@ -113,9 +113,10 @@
 ;; components
 (rum/defc modal-inner
   [config]
-  (let [{:keys [id title description content footer on-open-change align open? auto-width? root-props content-props]} config
+  (let [{:keys [id title description content footer on-open-change align open?
+                auto-width? close-btn? root-props content-props]} config
         props (dissoc config
-                :id :title :description :content :footer auto-width?
+                :id :title :description :content :footer :auto-width? :close-btn?
                 :align :on-open-change :open? :root-props :content-props)
         props (assoc-in props [:overlay-props :data-align] (name (or align :center)))]
 
@@ -144,7 +145,8 @@
                                 (.preventDefault e))))]
         (dialog-content
           (cond-> (merge props content-props)
-            auto-width? (assoc :data-auto-width true))
+            auto-width? (assoc :data-auto-width true)
+            (false? close-btn?) (assoc :data-close-btn false))
           (when title
             (dialog-header
               (when title (dialog-title title))

+ 6 - 0
resources/css/shui.css

@@ -242,6 +242,12 @@ html[data-theme=dark] {
   &[data-auto-width] {
     @apply max-w-[90vw] w-max sm:max-w-[960px];
   }
+
+  &[data-close-btn=false] {
+    .ui__dialog-close {
+      @apply hidden;
+    }
+  }
 }
 
 .ui__button-shortcut-key {

+ 2 - 1
src/main/frontend/components/assets.cljs

@@ -2,6 +2,7 @@
   (:require
    [clojure.set :refer [difference]]
    [clojure.string :as string]
+   [logseq.shui.ui :as shui]
    [rum.core :as rum]
    [frontend.state :as state]
    [frontend.context.i18n :refer [t]]
@@ -129,7 +130,7 @@
                                (set-dir! name dir exts))))
 
         confirm-dir      (fn [dir set-dir!]
-                           (state/set-sub-modal!
+                           (shui/dialog-open!
                             #(confirm-dir-with-alias-name dir set-dir!)))]
 
     [:div.cp__assets-alias-directories

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

@@ -815,10 +815,10 @@
   ([] (open-icloud-graph-clone-picker (state/get-current-repo)))
   ([repo]
    (when (and repo (mobile-util/in-iCloud-container-path? repo))
-     (state/set-modal!
+     (shui/dialog-open!
       (fn [close-fn]
         (clone-local-icloud-graph-panel repo (util/node-path.basename repo) close-fn))
-      {:close-btn? false :center? true}))))
+      {:close-btn? false}))))
 
 (defn make-onboarding-panel
   [type]

+ 4 - 5
src/main/frontend/components/plugins.cljs

@@ -981,7 +981,7 @@
        (ui/button [:span (t :plugin/install)]
                   :on-click #(do
                                (plugin-config-handler/replace-plugins plugins)
-                               (state/close-sub-modal! "ls-plugins-from-file-modal")))]]
+                               (shui/dialog-close! "ls-plugins-from-file-modal")))]]
      ;; all done
      [:div.py-4 [:strong.text-xl (str "\uD83C\uDF89 " (t :plugin.install-from-file/success))]])])
 
@@ -1414,11 +1414,10 @@
 
 (defn open-plugins-from-file-modal!
   [plugins]
-  (state/set-sub-modal!
-    (fn [_close!]
+  (shui/dialog-open!
+    (fn []
       (plugins-from-file plugins))
-    {:center? true
-     :id      "ls-plugins-from-file-modal"}))
+    {:id "ls-plugins-from-file-modal"}))
 
 (defn open-focused-settings-modal!
   [title]