2019-04-03 17:29:03 +02:00
|
|
|
<template>
|
2020-06-11 11:45:52 +02:00
|
|
|
<label for="navSearchField">
|
2020-02-18 08:57:00 +01:00
|
|
|
<span class="visually-hidden">{{ defaultPlaceHolder }}</span>
|
|
|
|
<b-input
|
|
|
|
custom-class="searchField"
|
2020-06-11 11:45:52 +02:00
|
|
|
id="navSearchField"
|
2020-02-18 08:57:00 +01:00
|
|
|
icon="magnify"
|
|
|
|
type="search"
|
|
|
|
rounded
|
|
|
|
:placeholder="defaultPlaceHolder"
|
2020-08-05 14:39:17 +02:00
|
|
|
v-model="search"
|
2020-02-18 08:57:00 +01:00
|
|
|
@keyup.native.enter="enter"
|
|
|
|
/>
|
|
|
|
</label>
|
2019-04-03 17:29:03 +02:00
|
|
|
</template>
|
|
|
|
<script lang="ts">
|
2020-02-18 08:57:00 +01:00
|
|
|
import { Component, Prop, Vue } from "vue-property-decorator";
|
|
|
|
import RouteName from "../router/name";
|
2019-04-03 17:29:03 +02:00
|
|
|
|
|
|
|
@Component
|
|
|
|
export default class SearchField extends Vue {
|
|
|
|
@Prop({ type: String, required: false }) placeholder!: string;
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2020-08-31 12:40:30 +02:00
|
|
|
search = "";
|
2019-04-03 17:29:03 +02:00
|
|
|
|
|
|
|
enter() {
|
2020-08-18 15:26:11 +02:00
|
|
|
this.$emit("navbar-search");
|
2020-02-18 08:57:00 +01:00
|
|
|
this.$router.push({
|
|
|
|
name: RouteName.SEARCH,
|
2020-08-05 14:39:17 +02:00
|
|
|
query: { term: this.search },
|
2020-02-18 08:57:00 +01:00
|
|
|
});
|
2019-04-03 17:29:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
get defaultPlaceHolder(): string {
|
2020-02-18 08:57:00 +01:00
|
|
|
// We can't use "this" inside @Prop's default value.
|
|
|
|
return this.placeholder || (this.$t("Search") as string);
|
2019-04-03 17:29:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
2019-10-10 13:29:58 +02:00
|
|
|
|
|
|
|
<style lang="scss">
|
2020-02-18 08:57:00 +01:00
|
|
|
label span.visually-hidden {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
input.searchField {
|
|
|
|
box-shadow: none;
|
|
|
|
border-color: #b5b5b5;
|
2019-11-05 15:09:40 +01:00
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
&::placeholder {
|
|
|
|
color: gray;
|
|
|
|
}
|
|
|
|
}
|
2019-11-05 15:09:40 +01:00
|
|
|
</style>
|