2019-04-03 17:29:03 +02:00
|
|
|
<template>
|
2019-10-10 13:29:58 +02:00
|
|
|
<b-input custom-class="searchField" icon="magnify" type="search" rounded :placeholder="defaultPlaceHolder" v-model="searchText" @keyup.native.enter="enter" />
|
2019-04-03 17:29:03 +02:00
|
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
|
|
import { Component, Prop, Vue } from 'vue-property-decorator';
|
|
|
|
import { RouteName } from '@/router';
|
|
|
|
|
|
|
|
@Component
|
|
|
|
export default class SearchField extends Vue {
|
|
|
|
@Prop({ type: String, required: false }) placeholder!: string;
|
|
|
|
searchText: string = '';
|
|
|
|
|
|
|
|
enter() {
|
|
|
|
this.$router.push({ name: RouteName.SEARCH, params: { searchTerm: this.searchText } });
|
|
|
|
}
|
|
|
|
|
|
|
|
get defaultPlaceHolder(): string {
|
|
|
|
// We can't use "this" inside @Prop's default value.
|
2019-09-12 11:34:01 +02:00
|
|
|
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">
|
|
|
|
input.searchField {
|
|
|
|
box-shadow: none;
|
|
|
|
border-color: #b5b5b5;
|
2019-11-05 15:09:40 +01:00
|
|
|
|
|
|
|
&::placeholder {
|
|
|
|
color: gray;
|
|
|
|
}
|
2019-10-10 13:29:58 +02:00
|
|
|
}
|
2019-11-05 15:09:40 +01:00
|
|
|
</style>
|