parent
b96b5eb327
commit
8630f91a13
@ -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
|
@ -0,0 +1,14 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<i :class='classes' class='favorite-button fa' v-on:click.prevent='favorite()'></i>
|
||||||
|
<span v-if='status.fave_num > 0'>{{status.fave_num}}</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script src="./favorite_button.js" ></script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.favorite-button {
|
||||||
|
cursor: pointer
|
||||||
|
}
|
||||||
|
</style>
|
Loading…
Reference in new issue