forked from EnergySage/es-ds
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EsSearchBar.vue
71 lines (69 loc) · 1.84 KB
/
EsSearchBar.vue
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<template>
<div class="align-items-center w-100 d-flex justify-content-center position-relative">
<form
action="/search/"
class="d-flex align-items-center mx-auto justify-content-center w-100"
method="get">
<es-form-input
id="searchBar"
aria-label="Search bar"
class="w-50"
label-sr-only
name="query"
v-model="searchText"
:placeholder="placeholder"
:value="searchText"
@keydown.enter="checkSearchText">
<template #label>
Search bar
</template>
<template #prefixIcon>
<icon-search />
</template>
</es-form-input>
<es-button
class="ml-50 mb-3"
:disabled="!searchText"
type="submit"
:value="buttonText">
{{ buttonText }}
<!-- <input enterkeyhint="search" /> -->
</es-button>
</form>
<slot name="close" />
</div>
</template>
<script lang="js">
// import axios from 'axios';
import EsButton from './EsButton.vue';
import EsFormInput from './EsFormInput.vue';
export default {
name: 'EsSearchBar',
components: {
EsButton,
EsFormInput,
},
props: {
buttonText: {
type: String,
default: 'Search',
},
placeholder: {
type: String,
default: 'Try "best solar panels"',
},
},
data() {
return {
searchText: '',
};
},
methods: {
checkSearchText(event) {
if (!this.searchText) {
event.preventDefault();
}
},
},
};
</script>