Răsfoiți Sursa

enhance: show tooltip for positioned porperties

Tienson Qin 1 an în urmă
părinte
comite
9b86ff649f

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

@@ -2317,7 +2317,7 @@
         [:div.positioned-properties.flex.flex-row.items-center.gap-1.select-none.h-6.flex-wrap
          (for [pid properties]
            (when-let [property (db/entity pid)]
-             (pv/property-value block property (get block pid) opts)))]))))
+             (pv/property-value block property (get block pid) (assoc opts :show-tooltip? true))))]))))
 
 (rum/defc ^:large-vars/cleanup-todo block-content < rum/reactive
   [config {:block/keys [uuid content properties scheduled deadline format pre-block?] :as block} edit-input-id block-id slide?]

+ 29 - 20
src/main/frontend/components/property/value.cljs

@@ -851,7 +851,8 @@
          (values-cp toggle-fn)]))))
 
 (rum/defcs property-value < rum/reactive
-  [state block property v opts]
+  [state block property v {:keys [show-tooltip?]
+                           :as opts}]
   (ui/catch-error
    (ui/block-error "Something wrong" {})
    (let [block-cp (state/get-component :block/blocks-container)
@@ -876,22 +877,30 @@
              (first v)
              :else
              v)
-         closed-values? (seq (:property/closed-values property))]
-     [:div.property-value-inner
-      {:data-type type
-       :class (str (when empty-value? "empty-value")
-                   (when-not (:other-position? opts) " w-full"))}
-      (cond
-        (and multiple-values? (= type :default) (not closed-values?))
-        (property-normal-block-value block property v
-                                     (assoc opts :id (str (:db/id block) "-" (:db/id property))))
-
-        multiple-values?
-        (multiple-values block property v opts schema)
-
-        :else
-        (property-scalar-value block property v
-                               (merge
-                                opts
-                                {:editor-id editor-id
-                                 :dom-id dom-id})))])))
+         closed-values? (seq (:property/closed-values property))
+         value-cp [:div.property-value-inner
+                   {:data-type type
+                    :class (str (when empty-value? "empty-value")
+                                (when-not (:other-position? opts) " w-full"))}
+                   (cond
+                     (and multiple-values? (= type :default) (not closed-values?))
+                     (property-normal-block-value block property v
+                                                  (assoc opts :id (str (:db/id block) "-" (:db/id property))))
+
+                     multiple-values?
+                     (multiple-values block property v opts schema)
+
+                     :else
+                     (property-scalar-value block property v
+                                            (merge
+                                             opts
+                                             {:editor-id editor-id
+                                              :dom-id dom-id})))]]
+     (if show-tooltip?
+       (shui/tooltip-provider
+        (shui/tooltip
+         (shui/tooltip-trigger
+          value-cp)
+         (shui/tooltip-content
+          (str "Change " (:block/original-name property)))))
+       value-cp))))