logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://hacktivis.me/git/pleroma-fe.git

search_bar.js (826B)


  1. import { library } from '@fortawesome/fontawesome-svg-core'
  2. import {
  3. faTimes,
  4. faSearch
  5. } from '@fortawesome/free-solid-svg-icons'
  6. library.add(
  7. faTimes,
  8. faSearch
  9. )
  10. const SearchBar = {
  11. data: () => ({
  12. searchTerm: undefined,
  13. hidden: true,
  14. error: false
  15. }),
  16. watch: {
  17. $route: function (route) {
  18. if (route.name === 'search') {
  19. this.searchTerm = route.query.query
  20. }
  21. }
  22. },
  23. methods: {
  24. find (searchTerm) {
  25. this.$router.push({ name: 'search', query: { query: searchTerm } })
  26. this.$refs.searchInput.focus()
  27. },
  28. toggleHidden () {
  29. this.hidden = !this.hidden
  30. this.$emit('toggled', this.hidden)
  31. this.$nextTick(() => {
  32. if (!this.hidden) {
  33. this.$refs.searchInput.focus()
  34. }
  35. })
  36. }
  37. }
  38. }
  39. export default SearchBar