2020-10-20 18:18:23 +00:00
|
|
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
|
|
|
import {
|
2020-10-20 19:13:19 +00:00
|
|
|
faTimes,
|
|
|
|
faSearch
|
2020-10-20 18:18:23 +00:00
|
|
|
} from '@fortawesome/free-solid-svg-icons'
|
|
|
|
|
|
|
|
library.add(
|
2020-10-20 19:13:19 +00:00
|
|
|
faTimes,
|
|
|
|
faSearch
|
2020-10-20 18:18:23 +00:00
|
|
|
)
|
|
|
|
|
2019-07-15 16:42:27 +00:00
|
|
|
const SearchBar = {
|
|
|
|
data: () => ({
|
|
|
|
searchTerm: undefined,
|
|
|
|
hidden: true,
|
|
|
|
error: false,
|
|
|
|
loading: false
|
|
|
|
}),
|
|
|
|
watch: {
|
|
|
|
'$route': function (route) {
|
|
|
|
if (route.name === 'search') {
|
|
|
|
this.searchTerm = route.query.query
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
find (searchTerm) {
|
|
|
|
this.$router.push({ name: 'search', query: { query: searchTerm } })
|
|
|
|
this.$refs.searchInput.focus()
|
|
|
|
},
|
|
|
|
toggleHidden () {
|
|
|
|
this.hidden = !this.hidden
|
|
|
|
this.$emit('toggled', this.hidden)
|
2019-07-31 17:39:35 +00:00
|
|
|
this.$nextTick(() => {
|
|
|
|
if (!this.hidden) {
|
|
|
|
this.$refs.searchInput.focus()
|
|
|
|
}
|
|
|
|
})
|
2019-07-15 16:42:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default SearchBar
|