JSFiddle - React, Tailwind, and code Playground

by EAdrian

HTML

<div class="container">
    <div class="score">
        <span>Score</span>
        <div class="score_rate">
            <div>0</div>
            <div>1</div>
            <div>2</div>
            <div>3</div>
            <div>4</div>
            <div>5</div>
        </div>
    </div>
    <div class="score_drop"></div>
</div>

<div class="container">
    <div class="score">
        <span>Score</span>
        <div class="score_rate">
            <div>0</div>
            <div>1</div>
            <div>2</div>
            <div>3</div>
            <div>4</div>
            <div>5</div>
        </div>
    </div>
    <div class="score_drop"></div>
</div>

SCSS

* {
    box-sizing: border-box;
}
.container {
    width: 100%;
    white-space: nowrap;
    background-color: #fff;
    text-align: center;
    color: #fff;
    display: inline-block;
}
.score {
    display: inline-block;
    position: relative;
    border-right: 1px solid #fff;
    width:55%;
    max-width: 135px;
    height: 75px;
    background-color: #0075c0;
    line-height: 75px;
    border-bottom-left-radius: 10px;
    border-top-left-radius: 10px;
}
.score_drop {
    display: inline-block;
    vertical-align: top;
    cursor: pointer;
    width:40%;
    max-width: 80px;
    height: 75px;
    background-color: #0075c0;
    border-bottom-right-radius: 10px;
    border-top-right-radius: 10px;
    &:hover {
        background-color: rgba(0, 117, 192, 0.9);
    }
    img {
        padding-top: 22px;
    }
    background: url(http://s8.postimg.org/ctjou8l7l/plus.gif) no-repeat;
    background-position: center;
    background-size: 50% 50%;
    background-color: #0075c0;
}
.score_minus {
    background: url(http://s27.postimg.org/r11kdi38f/minus.gif) no-repeat;
    background-position: center;
    background-size: 50% 50%;
    background-color: #0075c0;
}

.score_dropdown_active {
    background-color: rgba(0, 117, 192, 1);
}
.score_rate {
    display: none;
    position: absolute;
    background-color: #0075c0;
    color: #fff;
    padding: 0 2px;
    left: 0;
    width: 100%;
    margin-top: 1px;
    border-radius: 5px;
    div {
        width: 100%;
        line-height: normal;
        cursor: pointer;
        padding: 5px 0;
        margin: 2px 0;
        background-color: rgba(0,0,0,0.1);
        border-radius: 5px;
        &:hover {
            background-color: rgba(0,0,0,0.3);
        }
    }
}

JavaScript

$('.score_drop').click(function(e) {
    e.preventDefault();
    var $main = $(this).parents('.container');
    $main.find('.score_rate').slideToggle(400, function() {
        $main.find('.score_drop').toggleClass('score_minus');
    });
    return false;
});

$('html').click(function() {
    $main = $('.score_drop.score_minus');
    $($main).each(function( index ) {
        var $this = $(this);                                 
		$this.parents('.container').find('.score_rate').slideToggle(400, function(){
			$this.toggleClass('score_minus');
		});
    });
});