From 2403aa86ceebe7bd546f0cbe17fa8015f6814b8f Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Thu, 14 Aug 2025 22:36:43 +0800 Subject: [PATCH] fix: lint --- src/main/frontend/components/quick_add.cljs | 23 ++-- src/main/frontend/util.cljc | 4 +- src/main/mobile/components/demos.cljs | 144 -------------------- src/main/mobile/components/ui.cljs | 20 +-- 4 files changed, 15 insertions(+), 176 deletions(-) delete mode 100644 src/main/mobile/components/demos.cljs diff --git a/src/main/frontend/components/quick_add.cljs b/src/main/frontend/components/quick_add.cljs index 9792db9a83..ee2ede2b7b 100644 --- a/src/main/frontend/components/quick_add.cljs +++ b/src/main/frontend/components/quick_add.cljs @@ -7,19 +7,20 @@ [frontend.handler.editor :as editor-handler] [frontend.state :as state] [frontend.util :as util] - [mobile.components.ui :as mobile-ui] [logseq.common.config :as common-config] [logseq.db :as ldb] + [logseq.shui.hooks :as hooks] [logseq.shui.ui :as shui] + [mobile.components.ui :as mobile-ui] [rum.core :as rum])) (rum/defc page-blocks [page] (let [[scroll-container set-scroll-container] (rum/use-state nil) *ref (rum/use-ref nil)] - (rum/use-effect! - #(set-scroll-container (rum/deref *ref)) - []) + (hooks/use-effect! + #(set-scroll-container (rum/deref *ref)) + []) [:div.content-inner {:ref *ref} (when scroll-container @@ -43,12 +44,12 @@ (let [mobile? (util/mobile?) add-button [:div (shui/button - {:variant :default - :size :sm - :on-click (fn [_e] - (editor-handler/quick-add-blocks!))} - (when-not mobile? (shui/shortcut ["mod" "e"])) - "Add to today")]] + {:variant :default + :size :sm + :on-click (fn [_e] + (editor-handler/quick-add-blocks!))} + (when-not mobile? (shui/shortcut ["mod" "e"])) + "Add to today")]] [:div.ls-quick-add.flex.flex-1.flex-col.w-full.gap-4 [:div.border-b.pb-4.flex.flex-row.justify-between.gap-4.items-center [:div.font-medium @@ -56,7 +57,7 @@ (when mobile? add-button)] (if mobile? (mobile-ui/classic-app-container-wrap - (page-blocks add-page)) + (page-blocks add-page)) [:div.content {:class "block -ml-6"} (page-blocks add-page)]) (when-not mobile? add-button)])))) diff --git a/src/main/frontend/util.cljc b/src/main/frontend/util.cljc index 5fe2321ee2..93da08f480 100644 --- a/src/main/frontend/util.cljc +++ b/src/main/frontend/util.cljc @@ -1237,7 +1237,7 @@ ;; start? selection (or (not start?) (zero? (get-selection-start el)))) (when-let [scroll-node (app-scroll-container-node el)] - (let [scroll-top (.-scrollTop scroll-node) + (let [scroll-top' (.-scrollTop scroll-node) vw-height (if (mobile-util/native-platform?) (- (.-height js/window.screen) (or @keyboard-height 312)) (or (.-height js/window.visualViewport) @@ -1249,7 +1249,7 @@ (when (> inset 0) (js/setTimeout #(set! (.-scrollTop scroll-node) - (+ scroll-top inset (if (false? start?) 96 64))) 16)))))))) + (+ scroll-top' inset (if (false? start?) 96 64))) 16)))))))) #?(:cljs (do diff --git a/src/main/mobile/components/demos.cljs b/src/main/mobile/components/demos.cljs deleted file mode 100644 index 38d0f49662..0000000000 --- a/src/main/mobile/components/demos.cljs +++ /dev/null @@ -1,144 +0,0 @@ -(ns mobile.components.demos - (:require [logseq.shui.ui :as shui] - [rum.core :as rum] - [mobile.components.ui-silk :as ui-silk] - [logseq.shui.silkhq :as silkhq])) - -(rum/defc depth-view-example - [{:keys [nested?]}] - (silkhq/depth-sheet-view - (silkhq/depth-sheet-backdrop) - (silkhq/depth-sheet-content - {:class "flex flex-col items-center"} - (silkhq/scroll {:as-child true} - (silkhq/scroll-view - {:class "app-silk-scroll-view" - :scrollGestureTrap {:yEnd true}} - (silkhq/scroll-content - {:class "app-silk-scroll-content"} - [:div.app-silk-scroll-content-inner - [:h1.my-4.text-3xl.font-semibold "hello silk depth view"] - (shui/input) - (when (not nested?) - (silkhq/depth-sheet - (silkhq/depth-sheet-trigger - (shui/button {:class "primary-green text-lg"} "Open: nested depth sheet view") - (silkhq/depth-sheet-portal - (depth-view-example {:nested? true}))))) - [:ul - (for [_ (range 60)] - [:li "hello world list item!"])] - ])))))) - -(rum/defc stacking-view-example - [{:keys [nested?]}] - (silkhq/stacking-sheet-view - (silkhq/stacking-sheet-backdrop) - (silkhq/stacking-sheet-content - (silkhq/stacking-sheet-handle) - [:div.flex.justify-center.py-10.flex-col.gap-3.items-center - [:h2.text-2xl.text-semibold.py-40 "Hello stacking bottom sheet..."] - (when (not nested?) - (silkhq/stacking-sheet - (silkhq/stacking-sheet-trigger - (shui/button "open: nested stacking sheet")) - (silkhq/stacking-sheet-portal - (stacking-view-example {:nested? false}))))]))) - -(rum/defc page-view-example - [] - (silkhq/page-portal - (silkhq/page-view - (silkhq/page-backdrop) - (silkhq/page-content - (silkhq/scroll {:as-child true} - (silkhq/scroll-view - {:class "h-full"} - (silkhq/scroll-content {:as-child true} - [:article.p-6 - (for [_ (range 80)] - [:h2.text-lg.font-medium.my-4.bg-green-100 - "inner page"])]))))))) - -(rum/defc demos-inner [] - [:div.app-silk-index-container - [:h2.text-xl.font-semibold.pt-2 "Silk sheets demos"] - ;; Bottom Sheet case - (silkhq/bottom-sheet - (silkhq/bottom-sheet-trigger - {:class "w-full"} - (shui/button {:variant :secondary :class "w-full"} "0. Static Bottom Sheet")) - (silkhq/bottom-sheet-portal - (silkhq/bottom-sheet-view - (silkhq/bottom-sheet-backdrop) - (silkhq/bottom-sheet-content - {:class "flex flex-col items-center p-2"} - (silkhq/bottom-sheet-handle) - [:div.py-60.flex - [:h1.my-4.text-2xl "hello silkhq"]])))) - - ;; Detent Sheet case - (silkhq/detent-sheet - (silkhq/detent-sheet-trigger - {:class "w-full"} - (shui/button {:variant :secondary :class "w-full"} "1. Detent Bottom Sheet")) - (silkhq/detent-sheet-portal - (silkhq/detent-sheet-view - (silkhq/detent-sheet-backdrop) - (silkhq/detent-sheet-content - {:class "flex flex-col items-center p-2"} - (silkhq/detent-sheet-handle) - [:div.py-60.flex - [:h1.my-4.text-2xl "hello silkhq"]])))) - - ;; Depth Sheet case - (silkhq/depth-sheet - (silkhq/depth-sheet-trigger - {:class "w-full"} - (shui/button {:variant :secondary :class "w-full"} "2. Depth Bottom Sheet")) - (silkhq/depth-sheet-portal - (depth-view-example {:nested? false}))) - - ;; Stacking depth sheet case - (silkhq/stacking-sheet-stack - {:as-child true} - (silkhq/stacking-sheet - (silkhq/stacking-sheet-trigger - {:class "w-full"} - (shui/button {:variant :secondary :class "w-full"} "3. Stacking Bottom Sheet")) - - (silkhq/stacking-sheet-portal - (stacking-view-example {:nested? false})))) - - ;; parallax page - (silkhq/page - (silkhq/page-trigger - {:class "w-full"} - (shui/button {:variant :secondary :class "w-full"} "4. Single page")) - (page-view-example))]) - -(rum/defc silkhq-demos-page - [] - (silkhq/depth-sheet-stack {:as-child true} - (silkhq/depth-sheet-scenery-outlets - (silkhq/scroll {:as-child true} - (silkhq/scroll-view - {:safeArea "none" - :pageScroll true - :nativePageScrollReplacement true} - (silkhq/scroll-content {:class "app-silk-index-scroll-content"} - (demos-inner)))) - - ;; app topbar - (ui-silk/app-silk-topbar - {:title "Silk Demos " - :left-render (shui/button {:variant :icon :size :sm} - (shui/tabler-icon "chevron-left" {:size 22})) - :right-render [:<> - (shui/button {:variant :icon :size :sm} - (shui/tabler-icon "plus" {:size 22})) - (shui/button {:variant :icon :size :sm} - (shui/tabler-icon "dots" {:size 22}))]}) - ;; app tabs - (ui-silk/app-silk-tabs) - ))) \ No newline at end of file diff --git a/src/main/mobile/components/ui.cljs b/src/main/mobile/components/ui.cljs index 18c6ee490c..c33bedb209 100644 --- a/src/main/mobile/components/ui.cljs +++ b/src/main/mobile/components/ui.cljs @@ -104,12 +104,10 @@ (doall items))))) (defonce *modals (atom [])) -(defonce ^:private *id (atom 0)) -(defonce ^:private gen-id #(reset! *id (inc @*id))) (rum/defc x-modal [{:keys [close! _as-page? type on-action title buttons _inputs modal-props]} content] - (let [{:keys [class header]} modal-props] + (let [{:keys [_class header]} modal-props] (case type :action-sheet (silkhq/bottom-sheet @@ -153,27 +151,11 @@ (some->> (medley/indexed @*modals) (filter #(= id (:id (second %)))) (first))))) -(defn- upsert-modal! - [config] - (when-let [id (:id config)] - (if-let [[index config'] (get-modal id)] - (swap! *modals assoc index (merge config' config)) - (swap! *modals conj config)) id)) - (defn- delete-modal! [id] (when-let [[index _] (get-modal id)] (swap! *modals #(->> % (medley/remove-nth index) (vec))))) -(defn open-modal! - [content & {:keys [id type] :as props}] - (upsert-modal! - (merge props - {:id (or id (gen-id)) - :type (or type :default) ;; :alert :confirm :page - :as-page? (= type :page) - :content content}))) - (defn close-modal! ([] (some-> @*modals (last) :id (close-modal!))) ([id] (delete-modal! id)))