Created
March 12, 2019 02:55
-
-
Save JorgenVatle/dc2cf00d4cb00e87ac81c1d3f1e48d9d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default { | |
name: 'review-reactions', | |
props: ['agree', 'disagree', 'id'], | |
template: '<div>' + | |
' <span v-if="display === \'agree\'">' + | |
' You and {{ agree }} others disagree to this' + | |
' </span>' + | |
' <span v-else-if="display === \'disagree\'">' + | |
' You and {{ disagree }} others disagree to this' + | |
' </span>' + | |
'</div>', | |
data() { | |
return { | |
display: 'none' | |
} | |
}, | |
methods: { | |
/** | |
* Handle a reaction event. | |
* | |
* @note You'd trigger this using window.vue.$emit('react', {YourPostId}, {ReactionType}) | |
* @param postId // This would be your post ID | |
* @param {'agree'|'disagree'} type | |
*/ | |
handleReaction(postId, type) { | |
if (this.id !== postId) { | |
return; | |
} | |
this.display = type; | |
} | |
}, | |
created() { | |
window.vue.$on('react', this.handleReaction) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment