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

experiment/tanstack-table
charlie 2024-06-26 10:01:54 +08:00
parent 0c2dd53c2f
commit d278067f8c
5 changed files with 19 additions and 11 deletions

View File

@ -113,9 +113,10 @@
;; components ;; components
(rum/defc modal-inner (rum/defc modal-inner
[config] [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 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) :align :on-open-change :open? :root-props :content-props)
props (assoc-in props [:overlay-props :data-align] (name (or align :center)))] props (assoc-in props [:overlay-props :data-align] (name (or align :center)))]
@ -144,7 +145,8 @@
(.preventDefault e))))] (.preventDefault e))))]
(dialog-content (dialog-content
(cond-> (merge props content-props) (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 (when title
(dialog-header (dialog-header
(when title (dialog-title title)) (when title (dialog-title title))

View File

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

View File

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

View File

@ -815,10 +815,10 @@
([] (open-icloud-graph-clone-picker (state/get-current-repo))) ([] (open-icloud-graph-clone-picker (state/get-current-repo)))
([repo] ([repo]
(when (and repo (mobile-util/in-iCloud-container-path? repo)) (when (and repo (mobile-util/in-iCloud-container-path? repo))
(state/set-modal! (shui/dialog-open!
(fn [close-fn] (fn [close-fn]
(clone-local-icloud-graph-panel repo (util/node-path.basename repo) 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 (defn make-onboarding-panel
[type] [type]

View File

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