chore: remove outdated modals code

This commit is contained in:
Tienson Qin
2025-11-24 00:29:04 +08:00
parent af0abe1a6f
commit 2a24c4cc82
3 changed files with 0 additions and 77 deletions

View File

@@ -149,7 +149,6 @@
(ui-component/keep-keyboard-virtual-input)
(ui-component/install-notifications)
(ui-component/install-modals)
(shui-toaster/install-toaster)
(shui-dialog/install-modals)

View File

@@ -3,9 +3,7 @@
(:require [frontend.handler.notification :as notification]
[frontend.rum :as r]
[frontend.state :as state]
[logseq.shui.silkhq :as silkhq]
[logseq.shui.ui :as shui]
[medley.core :as medley]
[mobile.state :as mobile-state]
[react-transition-group :refer [CSSTransition TransitionGroup]]
[rum.core :as rum]))
@@ -111,79 +109,9 @@
items (if clear-all (cons clear-all notifications) notifications)]
(doall items)))))
(defonce *modals (atom []))
(rum/defc x-modal
[{:keys [close! _as-page? type on-action title buttons _inputs modal-props]} content]
(let [{:keys [_class header]} modal-props]
(case type
:action-sheet
(silkhq/bottom-sheet
(merge modal-props
{:presented true
:onPresentedChange (fn [v?] (when (false? v?)
(js/setTimeout #(close!) 200)))})
(let [title (or title header content)
content (for [{:keys [role text] :as item} buttons]
[:a.as-item-btn
{:data-role role
:on-pointer-down (fn []
(some-> on-action (apply [item]))
(close!))}
text])]
(silkhq/bottom-sheet-portal
(silkhq/bottom-sheet-view {:as-child true}
(silkhq/bottom-sheet-backdrop)
(silkhq/bottom-sheet-content
[:div.flex.flex-col.items-center.gap-2.app-silk-action-sheet-modal-content
(silkhq/bottom-sheet-handle {:class "my-2"})
(some-> title (silkhq/bottom-sheet-title))
[:div.as-list-container content]])))))
;; default
(silkhq/bottom-sheet
(merge modal-props
{:presented true
:onPresentedChange (fn [v?] (when (false? v?) (close!)))})
(silkhq/bottom-sheet-portal
(silkhq/bottom-sheet-view {:as-child true}
(silkhq/bottom-sheet-backdrop)
(silkhq/bottom-sheet-content
(if (fn? content)
(content) content))))))))
(defn get-modal
([] (some-> @*modals last))
([id]
(when id
(some->> (medley/indexed @*modals)
(filter #(= id (:id (second %)))) (first)))))
(defn- delete-modal!
[id]
(when-let [[index _] (get-modal id)]
(swap! *modals #(->> % (medley/remove-nth index) (vec)))))
(defn close-modal!
([] (some-> @*modals (last) :id (close-modal!)))
([id] (delete-modal! id)))
(defn open-popup!
[content-fn opts]
(mobile-state/set-popup!
{:open? true
:content-fn content-fn
:opts opts}))
(defn close-popup! []
(some-> mobile-state/*popup-data
(swap! assoc :open? false)))
(rum/defc install-modals []
(let [_ (r/use-atom *modals)]
[:<>
(for [{:keys [id content] :as props} @*modals
:let [close! #(close-modal! id)
props' (assoc props :close! close!)]]
(x-modal props'
(if (fn? content) (content props') content)))]))

View File

@@ -51,10 +51,6 @@
(not-empty (state/get-selection-blocks))
(editor-handler/clear-selection!)
;; TODO: move ui-related code to mobile events
(not-empty (cc-ui/get-modal))
(cc-ui/close-modal!)
(state/editing?)
(editor-handler/escape-editing)