enhance: display shortcut when highlighted

pull/10493/head
Tienson Qin 2023-11-03 01:03:09 +08:00
parent 12ddf65a22
commit 6e046fb3d1
2 changed files with 11 additions and 3 deletions

View File

@ -71,7 +71,11 @@
:else
[:span text-string]))))))
(rum/defc root [{:keys [icon icon-theme query text info shortcut value-label value title highlighted on-highlight on-highlight-dep header on-click hoverable compact rounded on-mouse-enter component-opts] :as _props :or {hoverable true rounded true}}
(rum/defc root [{:keys [icon icon-theme query text info shortcut value-label value
title highlighted on-highlight on-highlight-dep header on-click
hoverable compact rounded on-mouse-enter component-opts
display-shortcut-on-highlight?] :as _props
:or {hoverable true rounded true}}
{:keys [app-config] :as context}]
(let [ref (rum/create-ref)
highlight-query (partial highlight-query* app-config query)]
@ -123,7 +127,9 @@
[:span.text-gray-11 (str (to-string value-label))])
(when value
[:span.text-gray-11 (to-string value)])])
(when shortcut
(when (and shortcut
(or (and display-shortcut-on-highlight? highlighted)
(not display-shortcut-on-highlight?)))
[:div {:class "flex gap-1"
:style {:opacity (if highlighted 1 0.5)}}
(shortcut/root shortcut context)])]]))

View File

@ -365,7 +365,8 @@
[:div {:class "flex-1"}]
(when (or can-show-more? can-show-less?)
[:a.fade-link.select-node {:on-click (if (= show :more) show-less show-more)}
[:a.text-link.select-node.opacity-50.hover:opacity-90
{:on-click (if (= show :more) show-less show-more)}
(if (= show :more)
[:div.flex.flex-row.gap-1.items-center
"Show less"
@ -382,6 +383,7 @@
:compact true
:rounded false
:highlighted highlighted?
:display-shortcut-on-highlight? true
;; for some reason, the highlight effect does not always trigger on a
;; boolean value change so manually pass in the dep
:on-highlight-dep highlighted-item