JSFiddle - React, Tailwind, and code Playground
by Kevin Bratt
HTML
<div id="info">Hover over ></div>
<div style="width: 100%; display: table;">
<div style="display: table-row">
<div style="display: table-cell;">
<div onclick="errormode(this)" class="led green blink">
<div class="hilight"></div>
</div>
<div onclick="errormode(this)" class="led red blinkquick">
<div class="hilight"></div>
</div>
<div onclick="errormode(this)" class="led red">
<div class="hilight"></div>
</div>
</div>
<div style="display: table-cell;">
<div onclick="errormode(this)" class="led red">
<div class="hilight"></div>
</div>
<div onclick="errormode(this)" class="led red">
<div class="hilight"></div>
</div>
<div onclick="errormode(this)" class="led red">
<div class="hilight"></div>
</div>
</div>
<div style="display: table-cell;">
<div onclick="errormode(this)" class="led red">
<div class="hilight"></div>
</div>
<div onclick="errormode(this)" class="led red">
<div class="hilight"></div>
</div>
<div onclick="errormode(this)" class="led red">
<div class="hilight"></div>
</div>
</div>
<div style="display: table-cell;">
<div onclick="errormode(this)" class="led red">
<div class="hilight"></div>
</div>
<div onclick="errormode(this)" class="led red">
<div class="hilight"></div>
</div>
<div onclick="errormode(this)" class="led red">
<div class="hilight"></div>
</div>
</div>
</div>
</div>
<button onclick="errormode()">Error</button>
<button onclick="normalmode()">Normal</button>
CSS
body {
background: #888;
}
#info {
color: white;
font-family: sans-serif;
font-weight: bold;
position: absolute;
}
.led {
border-radius: 50%;
width: 30px;
height: 30px;
position: relative;
cursor: pointer;
margin: 20px auto;
border: 3px solid rgba(51, 51, 51, 0);
}
.led.red {
background-color: rgba(34, 0, 0, 1);
}
.led.green {
background-color: rgba(0, 34, 0, 1);
}
.led.yellow {
background-color: rgba(34, 34, 0, 1);
}
.led.red.blink {
animation: led-red-blink 2s infinite;
}
.led.red.blinkquick {
animation: led-red-blink 1s infinite;
}
.led.green.blink {
animation: led-green-blink 2s infinite;
}
.led.yellow.blink {
/*
-webkit-animation: led-yellow-blink 2s infinite;
-moz-animation: led-yellow-blink 2s infinite;
-ms-animation: led-yellow-blink 2s infinite;
-o-animation: led-yellow-blink 2s infinite;
*/
animation: led-yellow-blink 2s infinite;
}
.led.blue.blink {
animation: led-blue-blink 2s infinite;
}
@keyframes led-red-blink {
from {
background-color: rgba(34, 0, 0, 1);
box-shadow: none;
border: 3px solid rgba(51, 51, 51, 0);
}
20% {
background-color: rgba(170, 0, 0, 1);
box-shadow: 0px 0px 10px 5px rgba(255, 0, 0, 0.4);
border: 3px solid rgba(120, 0, 0, 1);
}
to {
background-color: rgba(34, 0, 0, 1);
box-shadow: none;
border: 3px solid rgba(51, 51, 51, 0);
}
}
@keyframes led-green-blink {
from {
background-color: rgba(0, 34, 0, 1);
box-shadow: none;
border: 3px solid rgba(51, 51, 51, 0);
}
20% {
background-color: rgba(0, 170, 0, 1);
box-shadow: 0px 0px 10px 5px rgba(0, 255, 0, 0.4);
border: 3px solid rgba(0, 120, 0, 1);
}
to {
background-color: rgba(0, 34, 0, 1);
box-shadow: none;
border: 3px solid rgba(51, 51, 51, 0);
}
}
@keyframes led-yellow-blink {
from {
background-color: rgba(34, 34, 0, 1);
box-shadow: none;
border: 3px solid rgba(51, 51, 51, 0);
}
20% {
background-color:...
JavaScript
function errormode(elementByRef) {
elementByRef.className += " blink";
elementByRef.onclick = "normalmode(this)";
}
getElementById.
function normalmode(elementByRef) {
elementByRef.className = elementByRef.className.replace(/(?:^|\s)blink(?!\S)/g, '')
elementByRef.onclick = errormode(elementByRef);
}