blob: 466e9b848dc503d610d7c5e8c2d3b0c7ca7e8891 (
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
|
const FavoriteButton = {
props: ['status'],
data () {
return {
animated: false
}
},
methods: {
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: {
classes () {
return {
'icon-star-empty': !this.status.favorited,
'icon-star': this.status.favorited,
'animate-spin': this.animated
}
}
}
}
export default FavoriteButton
|