JSFiddle - React, Tailwind, and code Playground

by Ray Peters

HTML

<ul id="bucket"></ul>

CSS

html, body { margin: 0; }
ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
}

li {
  flex: 1;
  color: #fff;
  font-family: 'Arial';
  text-shadow: 1px 1px 0px rgba(0, 0, 0, 0.25);
  font-weight: 800;
  margin: 0;
  padding: 1.25em;
  text-align: center;
  font-size: 0.75em;
  min-width: 4px;
  display: inline-block;
  
  transition-duration: 0.5s;
  transition-property: background-color, opacity;
  background-color: rgba(0, 0, 0, 0.07);
  border-right: 1px solid rgba(0,0,0,0.1);
  border-bottom: 1px solid rgba(0,0,0,0.1);
}

li:hover {
  transition: none !important;
  background-color: rgba(0, 0, 0, 0.02) !important;
}

body.green li {
  opacity: 0.5;
  background-color: #249b67;
}

body.white li {
  opacity: 0;
}

body.dark-green li {
  opacity: 0.9;
  background-color: #114830;
}

JavaScript

_activate();

function _activate() {
  _fillBucket();
  
  _shimmer( 'dark-green', 500 );
  _shimmer( 'green', 2000, true );
  _shimmer( 'white', 3500 );
}

function _fillBucket() {
	var frag, i, l;
  
  frag = document.createDocumentFragment();
  
  i = 0;
  l = 150;
  
  for ( ; i < l; ++i ) {
  	frag.appendChild( _makeBox( i ) );
  }
  
  document
  	.getElementById( 'bucket' )
    .appendChild( frag );
}

function _shimmer( toClass, wait, reverse ) {
  setTimeout( function() {
	  _setTransitionDelays( reverse );
		document.body.classList = toClass;
  }, wait );
}

function _setTransitionDelays( reverse ) {
	var bucketElem, bucketBoundingRect, child, children, boundingRect, i, l;
  
  bucketElem = document.getElementById( 'bucket' );
  bucketBoundingRect = bucketElem.getBoundingClientRect();
  
  children = bucketElem.querySelectorAll( '.shimmer-column' );
  
  i = 0;
  l = children.length;
  
  for ( ; i < l; ++i ) { 
  	child = children[ i ];
    boundingRect = child.getBoundingClientRect();
    child.style.transitionDelay = ( ( ( boundingRect.top + ( reverse ? ( bucketBoundingRect.right - boundingRect.right ) : boundingRect.left ) ) / 2 ) + 'ms' );
  }
}


function _makeBox( content ) {
	var li, text;
  
  li = document.createElement( 'li' );
  //text = document.createTextNode( content );
  
  //li.appendChild( text );
 	li.classList = 'shimmer-column';
  
  return li;
}