JSFiddle - React, Tailwind, and code Playground
by mrjordy
HTML
<div class="space"></div>
<div class= "toggleSwitch" id="clickMe"><span class="toggleText"></span>
<div class= "toggleSwitchKnob">
</div>
</div>
<div class="space"></div>
<div class="cube cubeFatShorter cubeBlue" id="c3w10"><div class="cubeNum">3w10</div><div class="cubeName">Fred Fondue</div></div>
<div class="cube cubeFatShorter cubeBlue" id="c3w11"><div class="cubeNum">3w11</div><div class="cubeName">Steve Staples</div></div>
<div class="space"></div>
<div class ="nameOfDiv"></div>
CSS
.space {
height: 50px;
display: block;
}
.toggleSwitch {
display: block;
background: #c6acac;
margin-left: 40px;
height: 20px;
width: 46px;
border-radius: 20px;
border-bottom: 1px solid rgba(255, 255, 255, 0.8);
border-top: 1px solid rgba(0, 0, 0, 0.5);
color: white;
position: relative;
cursor: pointer;
transition: .2s;
box-shadow: inset 0 0 10px rgb(79, 25, 25), 0 0px 17px rgba(0, 0, 0, 0.1);
}
.toggleText {
padding-left: 21px;
position: absolute;
transition: .2s;
user-select: none;
}
.toggleSwitchKnob {
background: #eee;
display: block;
position: absolute;
height: 16px;
width: 18px;
margin: 1px 0 0 1px;
border-radius: 10px;
transition: .3s;
border-top: 2px solid white;
}
.toggleSwitch.toggleSwitchOn {
background: #5aa256;
border-bottom: 1px solid white;
box-shadow: inset 0 0 10px rgb(0, 71, 3), 0 0px 17px rgba(67, 216, 83, 0.2);
}
.toggleSwitch.toggleSwitchOn > .toggleSwitchKnob {
margin: 1px 0 0 27px;
}
.toggleSwitch.toggleSwitchOn > .toggleText {
padding-left: 4px;
position: absolute;
}
/*-----------------------------------------------*/
.whiteout {
background: #fafafa;
}
.conference > .cubeNum {
text-transform: capitalize;
}
.cube.showName > .cubeName {
opacity: 1;
}
.cube.showName > .cubeNum {
top: 16px;
}
/*-----------------------------------------------*/
.cubeBlue {
background: rgba(0, 110, 255, 0.5);
box-shadow: inset 0 0 30px white;
}
.cubeFatShorter {
width: 83px;
height: 70px;
}
.cubeBlue > .cubeNum {
text-shadow: 0px 0px 1px rgba(0, 19, 105, 0.8);
}
.cubeNum {
font-family: kalinga;
font-size: 18px;
height: 24px;
font-weight: bold;
text-transform: uppercase;
color: white;
text-align: center;
line-height: 21px;
position: relative;
top: 50%;
transform: translateY(-50%);
transition: .4s;
}
.cubeName {
opacity: 0;
transition: .4s;
...
JavaScript
// -------------------
$( ".toggleText" ).html( "off" );
$( "#clickMe" ).click(function() {
$( "#clickMe" ).toggleClass( "toggleSwitchOn" );
$('#clickMe .toggleText').html($('#clickMe .toggleText').text() == 'off' ? 'on' : 'off');
$( ".cube" ).toggleClass( "showName" );
});
$(".cube").click(function(){
$( ".nameOfDiv" ).html( $(this).attr("id") );
});