Skip to content

Commit

Permalink
enhance(ux): auto-complete ux with mouse
Browse files Browse the repository at this point in the history
  • Loading branch information
xyhp915 authored and logseq-cldwalker committed Mar 13, 2023
1 parent 652c43f commit a345f43
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/main/frontend/ui.cljs
Expand Up @@ -483,7 +483,7 @@
item-render
class
header]}]
(let [current-idx (get state ::current-idx)]
(let [*current-idx (get state ::current-idx)]
[:div#ui__ac {:class class}
(if (seq matched)
[:div#ui__ac-inner.hide-scrollbar
Expand All @@ -492,17 +492,20 @@
[:<>
{:key idx}
(let [item-cp
[:div {:key idx}
(let [chosen? (= @current-idx idx)]
[:div.menu-link-wrap
{:key idx
;; mouse-move event to indicate that cursor moved by user
:on-mouse-move #(reset! *current-idx idx)}
(let [chosen? (= @*current-idx idx)]
(menu-link
{:id (str "ac-" idx)
:class (when chosen? "chosen")
:on-mouse-down (fn [e]
(util/stop e)
(if (and (gobj/get e "shiftKey") on-shift-chosen)
(on-shift-chosen item)
(on-chosen item)))}
(if item-render (item-render item chosen?) item) nil))]]
{:id (str "ac-" idx)
:class (when chosen? "chosen")
:on-mouse-down (fn [e]
(util/stop e)
(if (and (gobj/get e "shiftKey") on-shift-chosen)
(on-shift-chosen item)
(on-chosen item)))}
(if item-render (item-render item chosen?) item) nil))]]

(if get-group-name
(if-let [group-name (get-group-name item)]
Expand Down
5 changes: 5 additions & 0 deletions src/main/frontend/ui.css
Expand Up @@ -32,6 +32,11 @@
visibility: visible;
}
}

&:not(.chosen):hover {
background-color: unset !important;
color: var(--ls-primary-text-color);
}
}
}
}
Expand Down

0 comments on commit a345f43

Please sign in to comment.