akkoma-fe/src/components/favorite_button/favorite_button.js

23 lines
470 B
JavaScript
Raw Normal View History

2016-10-30 15:12:35 +00:00
const FavoriteButton = {
props: [ 'status' ],
methods: {
favorite () {
if (!this.status.favorited) {
this.$store.dispatch('favorite', { id: this.status.id})
} else {
this.$store.dispatch('unfavorite', { id: this.status.id})
}
}
},
computed: {
classes () {
return {
'icon-star-empty': !this.status.favorited,
'icon-star': this.status.favorited
}
}
}
}
export default FavoriteButton