Skip to content

Commit 6687af7

Browse files
committed
cleanup: Search bar, not fully there
1 parent 4a95314 commit 6687af7

File tree

1 file changed

+28
-29
lines changed

1 file changed

+28
-29
lines changed
Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,27 @@
11
<script setup lang="ts">
22
import { refDebounced } from '@vueuse/core'
33
import { ref, toRef, watch } from 'vue'
4+
import type { MaybeRefOrGetter } from 'vue'
45
56
import { cn } from '@/utils/tailwindUtil'
67
7-
const props = withDefaults(
8-
defineProps<{
9-
searcher?: (
10-
query: string,
11-
onCleanup: (cleanupFn: () => void) => void
12-
) => Promise<void>
13-
updateKey?: (() => unknown) | unknown
14-
}>(),
15-
{
16-
searcher: async () => {}
17-
}
18-
)
8+
const { searcher = async () => {}, ...props } = defineProps<{
9+
searcher?: (
10+
query: string,
11+
onCleanup: (cleanupFn: () => void) => void
12+
) => Promise<void>
13+
updateKey?: MaybeRefOrGetter<unknown>
14+
}>()
1915
2016
const searchQuery = defineModel<string>({ default: '' })
2117
2218
const isQuerying = ref(false)
23-
const debouncedSearchQuery = refDebounced(searchQuery, 700, {
24-
maxWait: 700
19+
const debouncedSearchQuery = refDebounced(searchQuery, 100, {
20+
maxWait: 100
2521
})
2622
watch(searchQuery, (value) => {
2723
isQuerying.value = value !== debouncedSearchQuery.value
2824
})
29-
3025
const updateKey =
3126
typeof props.updateKey === 'function'
3227
? props.updateKey
@@ -42,11 +37,11 @@ watch(
4237
cleanupFn?.()
4338
})
4439
45-
void props
46-
.searcher(debouncedSearchQuery.value, (cb) => (cleanupFn = cb))
47-
.finally(() => {
40+
void searcher(debouncedSearchQuery.value, (cb) => (cleanupFn = cb)).finally(
41+
() => {
4842
if (!isCleanup) isQuerying.value = false
49-
})
43+
}
44+
)
5045
},
5146
{ immediate: true }
5247
)
@@ -56,24 +51,28 @@ watch(
5651
<label
5752
:class="
5853
cn(
59-
'h-8 bg-zinc-500/20 rounded-lg outline outline-offset-[-1px] outline-node-component-border transition-all duration-150',
60-
'flex-1 flex px-2 items-center text-base leading-none cursor-text',
61-
searchQuery?.trim() !== '' ? 'text-base-foreground' : '',
62-
'hover:outline-component-node-widget-background-highlighted/80',
63-
'focus-within:outline-component-node-widget-background-highlighted/80'
54+
'py-1.5 bg-secondary-background rounded-lg transition-all duration-150',
55+
'flex-1 flex gap-2 px-2 items-center',
56+
'text-base-foreground border-0',
57+
'focus-within:ring focus-within:ring-component-node-widget-background-highlighted/80'
6458
)
6559
"
6660
>
6761
<i
68-
v-if="isQuerying"
69-
class="mr-2 icon-[lucide--loader-circle] size-4 animate-spin"
62+
:class="
63+
cn(
64+
'size-4 text-muted-foreground',
65+
isQuerying
66+
? 'icon-[lucide--loader-circle] animate-spin'
67+
: 'icon-[lucide--search]'
68+
)
69+
"
7070
/>
71-
<i v-else class="mr-2 icon-[lucide--search] size-4" />
7271
<input
7372
v-model="searchQuery"
7473
type="text"
75-
class="bg-transparent border-0 outline-0 ring-0 text-left"
76-
:placeholder="$t('g.search')"
74+
class="bg-transparent border-0 outline-0 ring-0 h-5"
75+
:placeholder="$t('g.searchPlaceholder')"
7776
/>
7877
</label>
7978
</template>

0 commit comments

Comments
 (0)