Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.