JSFiddle - React, Tailwind, and code Playground

Account transition effect #3

by Travis Almand

HTML

<div id="test" class="account-container">
  <div class="account">click me</div>
</div>

<div class="account-container selected">
  <div class="account"></div>
</div>

SCSS

.account-container {
  align-items: center;
  background: linear-gradient(45deg, #b4ddb4 0%,#83c783 17%,#52b152 33%,#008a00 67%,#005700 83%,#002400 100%);
  border-radius: 10px;
  box-shadow: 0 0 8px 0 rgba(0, 0, 0, 0.5);
  display: flex;
  height: 100px;
  justify-content: center;
  margin: 20px;
  position: relative;
  overflow: hidden;
  width: 300px;
  
  &::after {
    background-color: #fff;
    content: '';
    display: block;
    height: 100%;
    left: -25%;
    position: absolute;
    right: 0;
    transform: translate3d(0, 0, 0) skew(45deg, 0);
    transition: 150ms cubic-bezier(0.50, 0.00, 0.20, 1.00);
    width: 150%;
  }
  
  &.selected::after {
    transform: translate3d(100%, 0, 0) skew(45deg, 0);
    transition: 250ms cubic-beziere(0.50, 0.00, 0.20, 1.00);
  }
}

.account {
  background-color: white;
  border-radius: 10px;
  height: calc(100% - 12px);
  position: relative;
  transition: 0.5s;
  width: calc(100% - 12px);
  z-index: 2;
}

JavaScript

document.querySelector('#test').addEventListener('click', function () {
	this.classList.toggle('selected');
});