Browse Source

refactor(dev): names for the shui popup options

charlie 1 year ago
parent
commit
7f5ae850d5

+ 2 - 2
deps/shui/src/logseq/shui/demo2.cljs

@@ -290,7 +290,7 @@
                          (set-emoji! t)
                          (ui/popup-hide-all!))})])
                  {:content-props {:class "w-72 p-0"}
-                  :as-menu? true})}
+                  :as-dropdown? true})}
              (if emoji [:strong.px-1.text-6xl [:em-emoji emoji]] "emoji :O")] "."])]
      [:<>
       (emoji-picker nil)
@@ -362,7 +362,7 @@
                                               (ui/toast! it)
                                               (ui/popup-hide-all!))}
                                 [:strong it]))))
-                     {:as-menu? true
+                     {:as-dropdown? true
                       :content-props {:class "w-48"}})
         :on-context-menu #(ui/popup-show! %
                             [:h1.text-3xl.font-bold "hi x popup for custom context menu!"])}]])])

+ 6 - 6
deps/shui/src/logseq/shui/popup/core.cljs

@@ -60,7 +60,7 @@
     (swap! *popups #(->> % (medley/remove-nth index) (vec)))))
 
 (defn show!
-  [^js event content & {:keys [id as-menu? as-content? align root-props content-props] :as opts}]
+  [^js event content & {:keys [id as-dropdown? as-content? align root-props content-props] :as opts}]
   (let [position (cond
                    (vector? event) event
 
@@ -83,7 +83,7 @@
       (merge opts
         {:id (or id (gen-id))
          :open? true :content content :position position
-         :as-menu? as-menu?
+         :as-dropdown? as-dropdown?
          :as-content? as-content?
          :root-props root-props
          :content-props (cond-> content-props
@@ -101,7 +101,7 @@
     (hide! id)))
 
 (rum/defc x-popup
-  [{:keys [id open? content position as-menu? as-content? auto-side? root-props content-props]
+  [{:keys [id open? content position as-dropdown? as-content? auto-side? root-props content-props]
     :as _props}]
   (rum/use-effect!
     (fn []
@@ -110,9 +110,9 @@
     [open?])
 
   (when-let [[x y _ height] position]
-    (let [popup-root (if as-menu? dropdown-menu popover)
-          popup-trigger (if as-menu? dropdown-menu-trigger popover-trigger)
-          popup-content (if as-menu? dropdown-menu-content popover-content)
+    (let [popup-root (if as-dropdown? dropdown-menu popover)
+          popup-trigger (if as-dropdown? dropdown-menu-trigger popover-trigger)
+          popup-content (if as-dropdown? dropdown-menu-content popover-content)
           auto-side-fn (fn []
                          (let [vh js/window.innerHeight
                                [th bh] [y (- vh (+ y height))]]

+ 1 - 1
src/main/frontend/components/icon.cljs

@@ -340,7 +340,7 @@
          :class (if has-icon? "px-1 leading-none" "font-normal text-sm px-[0.5px] opacity-50")
          :on-click #(when-not disabled?
                       (shui/popup-show! (.-target %) content-fn
-                        {:as-menu? true
+                        {:as-dropdown? true
                          :content-props {:class "w-auto"}}))}
         (if has-icon?
           (icon icon-value (merge {:size 18} icon-props))

+ 4 - 4
src/main/frontend/components/property.cljs

@@ -95,7 +95,7 @@
              (select/select opts)))]
 
     [:div.flex.flex-1.cursor-pointer
-     {:on-click #(shui/popup-show! (.-target %) content-fn {:as-menu? true})}
+     {:on-click #(shui/popup-show! (.-target %) content-fn {:as-dropdown? true})}
      (if (seq schema-classes)
        [:div.flex.flex-1.flex-row.items-center.flex-wrap.gap-2
         (for [class schema-classes]
@@ -567,7 +567,7 @@
                                                             (shui/popup-hide!))}
                                                [:span.w-full.text-red-rx-07.hover:text-red-rx-09
                                                 "Delete property"]))]
-                                           {:as-menu? true
+                                           {:as-dropdown? true
                                             :content-props {:class "w-48"}}))}
      (when block?
        [:a.block-control
@@ -594,7 +594,7 @@
                                   (shui/popup-hide! id)))))}))]
        [:button.flex
         (when-not config/publishing?
-          {:on-click #(shui/popup-show! (.-target %) content-fn {:as-menu? true})})
+          {:on-click #(shui/popup-show! (.-target %) content-fn {:as-dropdown? true})})
         (if icon
           (icon-component/icon icon)
           [:span.bullet-container.cursor (when collapsed? {:class "bullet-closed"})
@@ -628,7 +628,7 @@
                                             :avoidCollisions true
                                             :align "start"}
                             :auto-side? true
-                            :as-menu? true}))}
+                            :as-dropdown? true}))}
         [:div {:style {:padding-left 6}} (:block/original-name property)]])]))
 
 (defn- resolve-linked-block-if-exists

+ 2 - 2
src/main/frontend/components/property/closed_value.cljs

@@ -148,7 +148,7 @@
                                                             :value       value
                                                             :description description
                                                             :icon        icon}))))))))
-          opts {:toggle-fn #(shui/popup-show! % content-fn {:as-menu? true})}]
+          opts {:toggle-fn #(shui/popup-show! % content-fn {:as-dropdown? true})}]
 
       (choice-with-close
        block
@@ -232,6 +232,6 @@
                                                                                                         :description description
                                                                                                         :icon        icon})]
                                                     (swap! *property-schema update :values (fnil conj []) closed-value))))))))))
-                              {:as-menu? true})))}
+                              {:as-dropdown? true})))}
         (ui/icon "plus" {:size 16})
         "Add choice"])]))

+ 1 - 1
src/main/frontend/components/property/value.cljs

@@ -769,7 +769,7 @@
                         (if config/publishing?
                           nil
                           (shui/popup-show! (rum/deref *el) content-fn
-                            {:as-menu? true :as-content? false :align "start"}))))
+                            {:as-dropdown? true :as-content? false :align "start"}))))
           :on-key-up (fn [^js e]
                        (case (.-key e)
                          (" " "Enter")