enhance(ux): better highlights page name for the search result items

This commit is contained in:
charlie
2024-04-27 14:32:02 +08:00
committed by Tienson Qin
parent c67b8b5fa4
commit e40e39c3aa
2 changed files with 12 additions and 4 deletions

View File

@@ -41,7 +41,7 @@
[:span normal-text])))))
(rum/defc root [{:keys [icon icon-theme query text info shortcut value-label value
title highlighted on-highlight on-highlight-dep header on-click
title highlighted on-highlight on-highlight-dep header on-click hls-page?
hoverable compact rounded on-mouse-enter component-opts source-page] :as _props
:or {hoverable true rounded true}}
{:keys [app-config] :as context}]
@@ -93,8 +93,9 @@
(if (and (= icon "page") (not= text source-page)) ;; alias
[:div.flex.flex-row.items-center.gap-2
(highlight-query text)
[:div.opacity-50.font-normal "alias of"]
source-page]
(if-not hls-page?
[:<> [:div.opacity-50.font-normal "alias of"] source-page]
[:div.opacity-50.font-normal.text-xs " — Highlights page"])]
(highlight-query text))
(when info
[:span.text-xs.text-gray-11 " — " (highlight-query info)])]]

View File

@@ -2,6 +2,7 @@
(:require
[clojure.string :as string]
[frontend.components.block :as block]
[frontend.extensions.pdf.utils :as pdf-utils]
[frontend.context.i18n :refer [t]]
[frontend.db :as db]
[frontend.db.model :as model]
@@ -604,9 +605,15 @@
[:div.search-results
(for [item visible-items
:let [highlighted? (= item highlighted-item)]]
:let [highlighted? (= item highlighted-item)
page? (= "page" (some-> item :icon))
text (some-> item :text)
source-page (some-> item :source-page)
hls-page? (and page? (pdf-utils/hls-file? source-page))]]
(let [item (shui/list-item (assoc item
:query (when-not (= group :create) @(::input state))
:text (if hls-page? (pdf-utils/fix-local-asset-pagename text) text)
:hls-page? hls-page?
:compact true
:rounded false
:hoverable @*mouse-active?