From ed0860fcc32cf3c92dcbb5e15a6261d8ba886e07 Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Thu, 22 May 2025 02:08:04 +0800 Subject: [PATCH] enhance(ux): set different hovering actions for tag, property and page --- src/main/frontend/components/page.cljs | 24 ++++++++++++++++++---- src/main/frontend/components/property.cljs | 9 +++++--- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/main/frontend/components/page.cljs b/src/main/frontend/components/page.cljs index bd6dfba145..ac39ce849f 100644 --- a/src/main/frontend/components/page.cljs +++ b/src/main/frontend/components/page.cljs @@ -10,6 +10,7 @@ [frontend.components.file-based.hierarchy :as hierarchy] [frontend.components.objects :as objects] [frontend.components.plugins :as plugins] + [frontend.components.property.config :as property-config] [frontend.components.query :as query] [frontend.components.reference :as reference] [frontend.components.scheduled-deadlines :as scheduled] @@ -438,9 +439,24 @@ :size :sm :class "px-2 py-0 h-6 text-xs text-muted-foreground" :on-click (fn [e] - (state/pub-event! [:editor/new-property {:block page - :target (.-target e)}]))} - "Set property")]]) + (if (ldb/property? page) + (shui/popup-show! + (.-target e) + (fn [] + [:div.ls-property-dropdown + (property-config/property-dropdown page nil {})]) + {:align :center}) + (let [opts (cond-> {:block page :target (.-target e)} + (ldb/class? page) + (assoc :class-schema? true))] + (state/pub-event! [:editor/new-property opts]))))} + (cond + (ldb/class? page) + "Add tag property" + (ldb/property? page) + "Configure" + :else + "Set property"))]]) (rum/defc db-page-title [page whiteboard-page? sidebar? container-id] @@ -558,7 +574,7 @@ (shui/tabs {:defaultValue default-tab :class "w-full"} - (when (or both? property?) + (when both? [:div.flex.flex-row.gap-1.items-center (shui/tabs-list {:class "h-8"} diff --git a/src/main/frontend/components/property.cljs b/src/main/frontend/components/property.cljs index 8ee2903e03..67d62e6d4f 100644 --- a/src/main/frontend/components/property.cljs +++ b/src/main/frontend/components/property.cljs @@ -638,9 +638,12 @@ (into result cur-properties) result))) result)) - full-properties (->> (concat block-own-properties' - (map (fn [p] [p (get block p)]) class-properties)) - remove-built-in-or-other-position-properties)] + full-properties (cond-> + (->> (concat block-own-properties' + (map (fn [p] [p (get block p)]) class-properties)) + remove-built-in-or-other-position-properties) + (and (ldb/class? block) (empty? (:logseq.property.class/properties block))) + (concat [[:logseq.property.class/properties nil]]))] (cond (empty? full-properties) (when sidebar-properties?