JSFiddle - React, Tailwind, and code Playground

by tjerabek

HTML

<div class="numbers">
    <div class="hours number"><span class="value">0</span>
    </div>
    <div class="delimiter">
    :
    </div>
    <div class="minutes number"><span class="value">0</span>
    </div>
</div>
<a href="#" class="add-hour btn">+1h</a>
<a href="#" class="rem-hour btn">-1h</a>

CSS

body{
    padding: 10em;
    font-family: arial;
}
.delimiter{
    float: left;
    padding: 1em .5em;
}
.number{
    width: 3em;
    height: 3em;
    background: rgb(233, 233, 233);
    float: left;
    overflow: hidden;
    -webkit-border-radius: 3px;
    -moz-border-radius: 3px;
    border-radius: 3px;
}
.number .value{
    width: 3em;
    height: 3em;
    display: block;
    line-height: 3em;
    text-align: center;
    -webkit-transition: all 400ms ease-in-out;
-moz-transition: all 400ms ease-in-out;
-ms-transition: all 400ms ease-in-out;
-o-transition: all 400ms ease-in-out;
transition: all 400ms ease-in-out;
    font-weight: bold;
}

.btn{
    width: 3em;
    height: 3em;
    background: #3498db;
    display: inline-block;
    text-align: center;
    line-height: 3em;
    -webkit-border-radius: 3px;
    -moz-border-radius: 3px;
    border-radius: 3px;
    font-weight: bold;
    text-decoration: none;
    color: white;
}
.btn:hover{
    background: #e8534f;
}
.add-hour{
    margin-left: 2em;
}

JavaScript

var hours = 0;
var minutes = 0;
var maxHours = 0;
$(document).on('click', '.add-hour', function(){
    increseHour();
    return false;
});
$(document).on('click', '.rem-hour', function(){
    decreseHour();
    return false;
});

increseHour = function(){
    hours+=1;
    move = hours * 3;
    if(maxHours<hours){
        $('.hours').append('<div class="value">'+hours+'</div>');
        maxHours++;
    }
    $('.hours').find('.value').first().css('margin-top', '-'+move+'em');
}

decreseHour = function(){
    if(hours>0){
        hours-=1;
        move = hours * 3;
        $('.hours').find('.value').first().css('margin-top', '-'+move+'em');
    }
}

$(document).ready(function(){
    for (var i=0;i<15;i++)
    { 
        increseHour();
    }
});