pleroma-fe/src/components/search_bar/search_bar.js

43 行
826 B
JavaScript
Raw 通常表示 履歴

2020-10-21 03:18:23 +09:00
import { library } from '@fortawesome/fontawesome-svg-core'
import {
faTimes,
faSearch
2020-10-21 03:18:23 +09:00
} from '@fortawesome/free-solid-svg-icons'
library.add(
faTimes,
faSearch
2020-10-21 03:18:23 +09:00
)
2019-07-16 01:42:27 +09:00
const SearchBar = {
data: () => ({
searchTerm: undefined,
hidden: true,
2020-10-21 04:54:43 +09:00
error: false
2019-07-16 01:42:27 +09:00
}),
watch: {
2022-07-31 18:35:48 +09:00
$route: function (route) {
2019-07-16 01:42:27 +09:00
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)
this.$nextTick(() => {
if (!this.hidden) {
this.$refs.searchInput.focus()
}
})
2019-07-16 01:42:27 +09:00
}
}
}
export default SearchBar