aboutsummaryrefslogtreecommitdiff
path: root/src/components/favorite_button/favorite_button.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/favorite_button/favorite_button.js')
-rw-r--r--src/components/favorite_button/favorite_button.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/components/favorite_button/favorite_button.js b/src/components/favorite_button/favorite_button.js
new file mode 100644
index 00000000..0a8843ea
--- /dev/null
+++ b/src/components/favorite_button/favorite_button.js
@@ -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