From 8630f91a13e8b8f7b56d2cb3dd2b700ad5ebd6f6 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sun, 30 Oct 2016 16:12:35 +0100 Subject: Add favorite-button. --- src/components/favorite_button/favorite_button.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/components/favorite_button/favorite_button.js (limited to 'src/components/favorite_button/favorite_button.js') 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 -- cgit v1.2.3-70-g09d2