aboutsummaryrefslogtreecommitdiff
path: root/src/components/react_button/react_button.js
blob: d1d15d930b21c56e9a17f2596d459d50ec5b1d97 (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { mapGetters } from 'vuex'

const ReactButton = {
  props: ['status', 'loggedIn'],
  data () {
    return {
      animated: false,
      showTooltip: false,
      popperOptions: {
        modifiers: {
          preventOverflow: { padding: { top: 50 }, boundariesElement: 'viewport' }
        }
      }
    }
  },
  methods: {
    openReactionSelect () {
      console.log('test')
      this.showTooltip = true
    },
    closeReactionSelect () {
      this.showTooltip = false
    },
    favorite () {
      if (!this.status.favorited) {
        this.$store.dispatch('favorite', { id: this.status.id })
      } else {
        this.$store.dispatch('unfavorite', { id: this.status.id })
      }
      this.animated = true
      setTimeout(() => {
        this.animated = false
      }, 500)
    }
  },
  computed: {
    emojis () {
      return this.$store.state.instance.emoji || []
    },
    classes () {
      return {
        'icon-smile': true,
        'animate-spin': this.animated
      }
    },
    ...mapGetters(['mergedConfig'])
  }
}

export default ReactButton