JSFiddle - React, Tailwind, and code Playground
by joplomacedo
HTML
<div class="card">
<div class="wallet">
<div class="wallet__closer">
<div class="wallet__closer__threshold"></div>
<div class="wallet__closer__real">
<div class="wallet__closer_circle"></div>
</div>
</div>
<div class="wallet__coins">
<div class="wallet__coin wallet__coin--1"></div><!--
--><div class="wallet__coin wallet__coin--2"></div>
</div>
<div class="wallet__side wallet__side--left"></div>
<div class="wallet__side wallet__side--right"></div>
</div> <!-- .wallet -->
<div class="open_wallet"></div>
</div> <!-- .card -->
CSS
.wallet,
.wallet__side {
width: 73px;
height: 50px;
border-radius: 0 3px 3px 0;
}
.wallet {
position: absolute;
bottom: 0;
right: 0;
perspective: 1300px;
z-index: 1;
}
.card.is-open .wallet {
pointer-events: none;
}
.wallet__closer {
position: absolute;
top: 50%;
right: 0;
transform: translateY(-50%);
height: 11px;
z-index: 2;
}
.card.is-open .wallet__closer {
z-index: -1;
transform: translateY(-50%) translateX(-26px);
transition: transform .2s .4s, z-index .4s;
}
.wallet__closer__threshold,
.wallet__closer__real {
position: absolute;
height: 100%;
background: #453379;
}
.wallet__closer__threshold {
width: 3px;
right: -3px;
}
.wallet__closer__real {
right: -3px;
width: 22px;
border-radius: 5px 0 0 5px;
transition: .2s;
}
.card.is-open .wallet__closer__real {
transform: rotateY(180deg) perspective(900px);
transform-origin: right;
}
.wallet__closer_circle {
height: 6px;
width: 6px;
position: absolute;
left: 5px;
border-radius: 50px;
top: 0;
bottom: 0;
margin: auto;
background: #beb1e2;
}
.wallet__coins {
position: absolute;
bottom: 100%;
left: 50%;
transform: translateX(-50%) translateY(50%);
white-space: nowrap;
}
.wallet__coin {
display: inline-block;
width: 20px;
height: 20px;
background-color: #888;
border-radius: 50%;
box-shadow: 0 1px 5px #00000054;
margin-bottom: -2px;
}
.wallet__coin--1 {
margin-right: -4px;
transform: translateY(2px);
}
.card.is-open .wallet__coin {
transition: .12s;
}
.card.is-open .wallet__coin--1 {
transform: translateY(13px);
}
.card.is-open .wallet__coin--2 {
transform: translateY(13px);
transition-delay: .08s;
}
.wallet__side {
position: absolute;
top: 0;
right: 0;
transition: .4s;
}
.wallet__side--left {
background-color: #7d5bdd;
transform: perspective(300px) rotateY(0);
transform-origin: left;
z-index: 1;
transition: transform .4s 1s, background-color .1s 1.1s;
}
.card.is-open...
JavaScript
var $wallet = $('.wallet'),
$open_wallet = $('.open_wallet'),
$card = $('.card');
$wallet.on('click', function () {
var open_wallet_dims = getDims($open_wallet);
$card
.addClass('is-opening')
.addClass('is-open')
.css({
height: open_wallet_dims.height,
width: open_wallet_dims.width
});
setTimeout(function () {
$card
.removeClass('is-opening')
.css({
height: '',
width: ''
});
}, 1450);
});
function getDims( $el ) {
return {
width: $el.outerWidth(),
height: $el.outerHeight()
};
}