aboutsummaryrefslogtreecommitdiff
path: root/src/components/search_bar/search_bar.js
blob: b8a792eef6b88996b3b91ac6054c3662a9131a56 (plain)
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
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)
    }
  }
}

export default SearchBar