SearchBar.vue
1.28 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
<script lang="ts" setup>
//#region --import--.
import { SearchIcon, XIcon } from "lucide-vue-next";
import { ref } from "vue";
//#endregion
//#region --Emits--.
// const emit = defineEmits([]);
//#endregion
//#region --Props--.
defineProps({
placeholder: {
type: String,
required: false,
nullable: false,
default: "",
},
});
//#endregion
//#region --Data/refs--.
const searchQuery = ref("");
//#endregion
</script>
<template>
<!-- Barre de recherche -->
<section class="mb-8">
<div class="relative max-w-xl mx-auto">
<input
v-model="searchQuery"
:placeholder="placeholder"
class="w-full px-4 py-3 bg-gray-800 rounded-full text-white placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-primary"
type="text"
@input="console.log('debouncedSearch à prévoir')"
/>
<button
v-if="searchQuery"
class="absolute right-3 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-white"
@click="console.log('clearSearch à prévoir')"
>
<XIcon :size="20" />
</button>
<button v-else class="absolute right-3 top-1/2 transform -translate-y-1/2 text-gray-400">
<SearchIcon :size="20" />
</button>
</div>
</section>
</template>
<style scoped></style>