Merge remote-tracking branch 'origin/keyboard-navigation-on-power-search'
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
:active="shortcutIndex === selectedEntry"
|
:active="shortcutIndex === selectedEntry"
|
||||||
:shortcut="shortcut.item"
|
:shortcut="shortcut.item"
|
||||||
@action="$emit('action', shortcut.item.action)"
|
@action="$emit('action', shortcut.item.action)"
|
||||||
|
@mouseover.native="selectedEntry = shortcutIndex"
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
v-if="searchResults.length === 0"
|
v-if="searchResults.length === 0"
|
||||||
@@ -21,12 +22,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {
|
import { computed, onUnmounted, onMounted } from "@nuxtjs/composition-api"
|
||||||
computed,
|
|
||||||
onUnmounted,
|
|
||||||
onMounted,
|
|
||||||
getCurrentInstance,
|
|
||||||
} from "@nuxtjs/composition-api"
|
|
||||||
import Fuse from "fuse.js"
|
import Fuse from "fuse.js"
|
||||||
import { useArrowKeysNavigation } from "~/helpers/powerSearchNavigation"
|
import { useArrowKeysNavigation } from "~/helpers/powerSearchNavigation"
|
||||||
import { HoppAction } from "~/helpers/actions"
|
import { HoppAction } from "~/helpers/actions"
|
||||||
@@ -36,6 +32,10 @@ const props = defineProps<{
|
|||||||
search: string
|
search: string
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(e: "action", action: HoppAction): void
|
||||||
|
}>()
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
keys: ["keys", "label", "action", "tags"],
|
keys: ["keys", "label", "action", "tags"],
|
||||||
}
|
}
|
||||||
@@ -48,10 +48,7 @@ const searchResultsItems = computed(() =>
|
|||||||
searchResults.value.map((searchResult: any) => searchResult.item)
|
searchResults.value.map((searchResult: any) => searchResult.item)
|
||||||
)
|
)
|
||||||
|
|
||||||
const currentInstance = getCurrentInstance()
|
const emitSearchAction = (action: HoppAction) => emit("action", action)
|
||||||
|
|
||||||
const emitSearchAction = (action: HoppAction) =>
|
|
||||||
currentInstance.emit("action", action)
|
|
||||||
|
|
||||||
const { bindArrowKeysListerners, unbindArrowKeysListerners, selectedEntry } =
|
const { bindArrowKeysListerners, unbindArrowKeysListerners, selectedEntry } =
|
||||||
useArrowKeysNavigation(searchResultsItems, {
|
useArrowKeysNavigation(searchResultsItems, {
|
||||||
|
|||||||
@@ -49,6 +49,7 @@
|
|||||||
:shortcut="shortcut"
|
:shortcut="shortcut"
|
||||||
:active="shortcutsItems.indexOf(shortcut) === selectedEntry"
|
:active="shortcutsItems.indexOf(shortcut) === selectedEntry"
|
||||||
@action="runAction"
|
@action="runAction"
|
||||||
|
@mouseover.native="selectedEntry = shortcutsItems.indexOf(shortcut)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -8,36 +8,22 @@
|
|||||||
transition
|
transition
|
||||||
items-center
|
items-center
|
||||||
group
|
group
|
||||||
hover:bg-primaryLight
|
|
||||||
focus:outline-none
|
focus:outline-none
|
||||||
focus-visible:bg-primaryLight
|
focus-visible:bg-primaryLight
|
||||||
search-entry
|
search-entry
|
||||||
"
|
"
|
||||||
:class="{ active, 'outline-none': active, 'focus-visible': active }"
|
:class="{ active, 'focus-visible': active }"
|
||||||
tabindex="0"
|
tabindex="-1"
|
||||||
@click="$emit('action', shortcut.action)"
|
@click="$emit('action', shortcut.action)"
|
||||||
@keydown.enter="$emit('action', shortcut.action)"
|
@keydown.enter="$emit('action', shortcut.action)"
|
||||||
>
|
>
|
||||||
<SmartIcon
|
<SmartIcon
|
||||||
class="
|
class="mr-4 opacity-50 transition svg-icons group-focus:opacity-100"
|
||||||
mr-4
|
:class="{ 'opacity-100 text-secondaryDark': active }"
|
||||||
opacity-50
|
|
||||||
transition
|
|
||||||
svg-icons
|
|
||||||
group-hover:text-secondaryDark group-hover:opacity-100
|
|
||||||
group-focus:opacity-100
|
|
||||||
"
|
|
||||||
:class="{ 'opacity-100': active, 'text-secondaryDark': active }"
|
|
||||||
:name="shortcut.icon"
|
:name="shortcut.icon"
|
||||||
/>
|
/>
|
||||||
<span
|
<span
|
||||||
class="
|
class="flex flex-1 mr-4 transition"
|
||||||
flex flex-1
|
|
||||||
mr-4
|
|
||||||
transition
|
|
||||||
group-hover:text-secondaryDark
|
|
||||||
group-focus:text-secondaryDark
|
|
||||||
"
|
|
||||||
:class="{ 'text-secondaryDark': active }"
|
:class="{ 'text-secondaryDark': active }"
|
||||||
>
|
>
|
||||||
{{ $t(shortcut.label) }}
|
{{ $t(shortcut.label) }}
|
||||||
@@ -76,8 +62,6 @@ defineProps<{
|
|||||||
content: "";
|
content: "";
|
||||||
}
|
}
|
||||||
|
|
||||||
&:hover::after,
|
|
||||||
&:focus::after,
|
|
||||||
&.active::after {
|
&.active::after {
|
||||||
@apply bg-accentLight;
|
@apply bg-accentLight;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user