Skip to content

Commit 87fe071

Browse files
committed
chore: simplify and always keep tagline
1 parent ed977dc commit 87fe071

4 files changed

Lines changed: 52 additions & 25 deletions

File tree

app/components/InstantSearch.vue

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,48 @@ onPrehydrate(el => {
77
const settingsSaved = JSON.parse(localStorage.getItem('npmx-settings') || '{}')
88
const enabled = settingsSaved.instantSearch
99
if (enabled === false) {
10-
el.classList.add('hidden')
10+
el.querySelector('[data-instant-search-on]')!.className = 'hidden'
11+
el.querySelector('[data-instant-search-off]')!.className = ''
1112
}
1213
})
1314
</script>
1415

1516
<template>
16-
<p
17-
id="instant-search-advisory"
18-
class="text-fg-muted text-sm text-pretty"
19-
:class="settings.instantSearch ? '' : 'hidden'"
20-
>
17+
<p id="instant-search-advisory" class="text-fg-muted text-sm text-pretty">
2118
<span
2219
class="i-lucide:zap align-middle text-fg relative top-[-0.1em] me-1"
2320
style="font-size: 0.8em"
2421
aria-hidden="true"
25-
></span>
26-
<i18n-t keypath="search.instant_search_advisory">
27-
<template #label>
28-
<strong>{{ $t('search.instant_search') }}</strong>
29-
</template>
30-
<template #settings>
31-
<LinkBase to="/settings">{{ $t('settings.title') }}</LinkBase>
32-
</template>
33-
<template #shortcut>
34-
<kbd class="text-xs"
35-
><kbd class="text-fg bg-bg-muted border border-border px-1 py-[2px] rounded-sm">Ctrl</kbd
36-
>+<kbd class="text-fg bg-bg-muted border border-border px-1 py-[2px] rounded-sm"
37-
>/</kbd
38-
></kbd
39-
>
40-
</template>
41-
</i18n-t>
22+
/>
23+
<span data-instant-search-on :class="settings.instantSearch ? '' : 'hidden'">
24+
<i18n-t keypath="search.instant_search_advisory">
25+
<template #label>
26+
{{ $t('search.instant_search') }}
27+
</template>
28+
<template #state>
29+
<strong>{{ $t('search.instant_search_on') }}</strong>
30+
</template>
31+
<template #action>
32+
<button type="button" class="underline" @click="settings.instantSearch = false">
33+
{{ $t('search.instant_search_turn_off') }}
34+
</button>
35+
</template>
36+
</i18n-t>
37+
</span>
38+
<span data-instant-search-off :class="settings.instantSearch ? 'hidden' : ''">
39+
<i18n-t keypath="search.instant_search_advisory">
40+
<template #label>
41+
{{ $t('search.instant_search') }}
42+
</template>
43+
<template #state>
44+
<strong>{{ $t('search.instant_search_off') }}</strong>
45+
</template>
46+
<template #action>
47+
<button type="button" class="underline" @click="settings.instantSearch = true">
48+
{{ $t('search.instant_search_turn_on') }}
49+
</button>
50+
</template>
51+
</i18n-t>
52+
</span>
4253
</p>
4354
</template>

app/pages/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ defineOgImageComponent('Default', {
8989
no-correct
9090
size="large"
9191
class="w-full ps-8 pe-24"
92-
:aria-describedby="settings.instantSearch ? 'instant-search-advisory' : undefined"
92+
aria-describedby="instant-search-advisory"
9393
@focus="isSearchFocused = true"
9494
@blur="isSearchFocused = false"
9595
/>

i18n/locales/en.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,11 @@
6666
"view_org_packages": "View packages by this organization"
6767
},
6868
"instant_search": "Instant search",
69-
"instant_search_advisory": "{label}: navigate to results as you type. Turn off in {settings} or press {shortcut}."
69+
"instant_search_on": "on",
70+
"instant_search_off": "off",
71+
"instant_search_turn_on": "turn on",
72+
"instant_search_turn_off": "turn off",
73+
"instant_search_advisory": "{label} {state} — {action}"
7074
},
7175
"nav": {
7276
"main_navigation": "Main",

i18n/schema.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,18 @@
202202
"instant_search": {
203203
"type": "string"
204204
},
205+
"instant_search_on": {
206+
"type": "string"
207+
},
208+
"instant_search_off": {
209+
"type": "string"
210+
},
211+
"instant_search_turn_on": {
212+
"type": "string"
213+
},
214+
"instant_search_turn_off": {
215+
"type": "string"
216+
},
205217
"instant_search_advisory": {
206218
"type": "string"
207219
}

0 commit comments

Comments
 (0)