JSFiddle - React, Tailwind, and code Playground

by stvnmntjy

HTML

<div class="outer" data-bind="click: toggleColor, css: bgColor">
    <p class="center">
        <input type="text" data-bind="clickBubble: false">
    </p>
</div>

CSS

.outer {
    cursor: pointer;
    padding-bottom: 5px;
    padding-top: 5px;
    width: 250px;
}
.center {
    text-align: center;
}
.green {
    background-color: green;
}
.yellow {
    background-color: yellow;
}

JavaScript

var ViewModel = function () {
    _this = this;
    _this.bgColor = ko.observable("green");
    _this.toggleColor = function () {
        oldColor = _this.bgColor();
        if (oldColor === "green") {
            _this.bgColor("yellow");    
        } else {
            _this.bgColor("green");             
        }                
    };
};

ko.applyBindings(new ViewModel());