mirror of https://github.com/logseq/logseq
enhance(ui): add trigger as to shui
parent
37a2fab944
commit
a61f9b8a4d
|
@ -5,6 +5,20 @@
|
||||||
(def button-base (util/lsui-wrap "Button" {:static? false}))
|
(def button-base (util/lsui-wrap "Button" {:static? false}))
|
||||||
(def link (util/lsui-wrap "Link"))
|
(def link (util/lsui-wrap "Link"))
|
||||||
|
|
||||||
|
(defn trigger-as
|
||||||
|
([as & props-or-children]
|
||||||
|
(let [[props children] [(first props-or-children) (rest props-or-children)]
|
||||||
|
props' (cond->
|
||||||
|
{:on-key-down #(case (.-key %)
|
||||||
|
(" " "Enter")
|
||||||
|
(do (some-> (.-target %) (.click))
|
||||||
|
(.preventDefault %))
|
||||||
|
:dune)}
|
||||||
|
(map? props)
|
||||||
|
(merge props))
|
||||||
|
children (if (map? props) children (cons props children))]
|
||||||
|
[as props' children])))
|
||||||
|
|
||||||
;; Note: don't define component with rum/defc
|
;; Note: don't define component with rum/defc
|
||||||
;; to be compatible for the radix as-child option
|
;; to be compatible for the radix as-child option
|
||||||
(defn button
|
(defn button
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
(def button base-core/button)
|
(def button base-core/button)
|
||||||
(def link base-core/link)
|
(def link base-core/link)
|
||||||
|
(def trigger-as base-core/trigger-as)
|
||||||
(def tabler-icon icon-v2/root)
|
(def tabler-icon icon-v2/root)
|
||||||
|
|
||||||
(def alert (util/lsui-wrap "Alert"))
|
(def alert (util/lsui-wrap "Alert"))
|
||||||
|
|
|
@ -136,17 +136,15 @@
|
||||||
[:div.flex.flex-row.items-center.mr-2.ml-1 {:style {:height 24}}
|
[:div.flex.flex-row.items-center.mr-2.ml-1 {:style {:height 24}}
|
||||||
[:span.bullet-container.cursor
|
[:span.bullet-container.cursor
|
||||||
[:span.bullet]]]
|
[:span.bullet]]]
|
||||||
[:div.flex.flex-1 {:tabIndex 0
|
(shui/trigger-as :div.flex.flex-1
|
||||||
:on-key-press (fn [e]
|
{:tabIndex 0
|
||||||
(when (= "Enter" (util/ekey e))
|
:on-click click-handler-fn
|
||||||
(click-handler-fn)))
|
:on-drag-enter #(set-hover! true)
|
||||||
:on-click click-handler-fn
|
:on-drag-over #(util/stop %)
|
||||||
:on-drag-enter #(set-hover! true)
|
:on-drop drop-handler-fn
|
||||||
:on-drag-over #(util/stop %)
|
:on-drag-leave #(set-hover! false)}
|
||||||
:on-drop drop-handler-fn
|
[:span.opacity-70
|
||||||
:on-drag-leave #(set-hover! false)}
|
"Click here to edit..."])]])))
|
||||||
[:span.opacity-70
|
|
||||||
"Click here to edit..."]]]])))
|
|
||||||
|
|
||||||
(rum/defc add-button
|
(rum/defc add-button
|
||||||
[args]
|
[args]
|
||||||
|
|
|
@ -186,19 +186,6 @@
|
||||||
:disabled false}
|
:disabled false}
|
||||||
(svg/info)))]))
|
(svg/info)))]))
|
||||||
|
|
||||||
(defn trigger-as
|
|
||||||
([as & props-or-children]
|
|
||||||
(let [[props children] [(first props-or-children) (rest props-or-children)]
|
|
||||||
props (cond->
|
|
||||||
{:on-key-down #(case (.-key %)
|
|
||||||
(" " "Enter")
|
|
||||||
(do (some-> (.-target %) (.click))
|
|
||||||
(.preventDefault %))
|
|
||||||
:dune)}
|
|
||||||
(map? props)
|
|
||||||
(merge props))]
|
|
||||||
[as props children])))
|
|
||||||
|
|
||||||
(rum/defcs ^:large-vars/cleanup-todo property-config
|
(rum/defcs ^:large-vars/cleanup-todo property-config
|
||||||
"All changes to a property must update the db and the *property-schema. Failure to do
|
"All changes to a property must update the db and the *property-schema. Failure to do
|
||||||
so can result in data loss"
|
so can result in data loss"
|
||||||
|
@ -592,7 +579,7 @@
|
||||||
(:block/uuid property)
|
(:block/uuid property)
|
||||||
{:properties {icon-property-id icon}})]
|
{:properties {icon-property-id icon}})]
|
||||||
(shui/popup-hide! id)))))}))]
|
(shui/popup-hide! id)))))}))]
|
||||||
(trigger-as :button
|
(shui/trigger-as :button
|
||||||
(-> (when-not config/publishing?
|
(-> (when-not config/publishing?
|
||||||
{:on-click #(shui/popup-show! (.-target %) content-fn {:as-dropdown? true :auto-focus? true})})
|
{:on-click #(shui/popup-show! (.-target %) content-fn {:as-dropdown? true :auto-focus? true})})
|
||||||
(assoc :class "flex items-center"))
|
(assoc :class "flex items-center"))
|
||||||
|
@ -606,7 +593,7 @@
|
||||||
{:on-click #(route-handler/redirect-to-page! (:block/name property))}
|
{:on-click #(route-handler/redirect-to-page! (:block/name property))}
|
||||||
(:block/original-name property)]
|
(:block/original-name property)]
|
||||||
|
|
||||||
(trigger-as :a
|
(shui/trigger-as :a
|
||||||
{:tabIndex 0
|
{:tabIndex 0
|
||||||
:title (str "Configure property: " (:block/original-name property))
|
:title (str "Configure property: " (:block/original-name property))
|
||||||
:class "property-k flex select-none jtrigger pl-2"
|
:class "property-k flex select-none jtrigger pl-2"
|
||||||
|
|
Loading…
Reference in New Issue