JSFiddle - React, Tailwind, and code Playground
HTML
<div class="arrow-up" data-bind="click: num.upvote.bind(num)"></div>
<h5 data-bind="text: num.value, css: { pink: num.changed }">3</h5>
<div class="arrow-down" data-bind="click: num.downvote.bind(num)"></div>
CSS
.arrow-up {
width: 0;
height: 0;
border-left: 20px solid transparent;
border-right: 20px solid transparent;
border-bottom: 20px solid black;
}
.arrow-down {
width: 0;
height: 0;
border-left: 20px solid transparent;
border-right: 20px solid transparent;
border-top: 20px solid #f00;
}
h5 {
position:relative;
font-size:20px;
left:12px;
}
.pink {
color: pink;
}
JavaScript
function Num(value) {
this.value = ko.observable(value);
this.changed = ko.observable(false);
}
Num.prototype.upvote = function() {
this.value(this.value()+1);
this.changed(true);
}
Num.prototype.downvote = function() {
this.value(this.value()-1);
this.changed(true);
}
var model = {
num: new Num(1),
}
ko.applyBindings(model);