-
-
Notifications
You must be signed in to change notification settings - Fork 427
Expand file tree
/
Copy pathInstantSearch.vue
More file actions
54 lines (51 loc) · 1.82 KB
/
InstantSearch.vue
File metadata and controls
54 lines (51 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<script setup lang="ts">
import { useSettings } from '~/composables/useSettings'
const { settings } = useSettings()
onPrehydrate(el => {
const settingsSaved = JSON.parse(localStorage.getItem('npmx-settings') || '{}')
const enabled = settingsSaved.instantSearch
if (enabled === false) {
el.querySelector('[data-instant-search-on]')!.className = 'hidden'
el.querySelector('[data-instant-search-off]')!.className = ''
}
})
</script>
<template>
<p id="instant-search-advisory" class="text-fg-muted text-sm text-pretty">
<span
class="i-lucide:zap align-middle text-fg relative top-[-0.1em] me-1"
style="font-size: 0.8em"
aria-hidden="true"
/>
<span data-instant-search-on :class="settings.instantSearch ? '' : 'hidden'">
<i18n-t keypath="search.instant_search_advisory">
<template #label>
{{ $t('search.instant_search') }}
</template>
<template #state>
<strong>{{ $t('search.instant_search_on') }}</strong>
</template>
<template #action>
<button type="button" class="underline" @click="settings.instantSearch = false">
{{ $t('search.instant_search_turn_off') }}
</button>
</template>
</i18n-t>
</span>
<span data-instant-search-off :class="settings.instantSearch ? 'hidden' : ''">
<i18n-t keypath="search.instant_search_advisory">
<template #label>
{{ $t('search.instant_search') }}
</template>
<template #state>
<strong>{{ $t('search.instant_search_off') }}</strong>
</template>
<template #action>
<button type="button" class="underline" @click="settings.instantSearch = true">
{{ $t('search.instant_search_turn_on') }}
</button>
</template>
</i18n-t>
</span>
</p>
</template>