Add favorite-button.
This commit is contained in:
parent
b96b5eb327
commit
8630f91a13
7 changed files with 85 additions and 11 deletions
22
src/components/favorite_button/favorite_button.js
Normal file
22
src/components/favorite_button/favorite_button.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
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
|
Loading…
Add table
Add a link
Reference in a new issue