JSFiddle - React, Tailwind, and code Playground

by robjoeol

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.5.1/gsap.min.js"></script>
<!-- Click to restart animation. -->
<div class="poster">
  <div class="shadow"></div>
  <div class="content">
    <p>uncle jam's army<br />live in concert</p>
    <p>this friday<br />march 11 1988 / 8 pm</p>
    <p>eazy e and</p>
    <p class="title">
      <span class="acronynm">n</span>
      <span class="acronynm">w</span>
      <span class="acronynm">a</span>
    </p>
    <p>at skateland u.s.a.<br />1950 south central ave.</p>
  </div>
</div>
<input id="volume" type="checkbox" />
<label for="volume" title="Toggle sound">
  <svg viewBox="0 0 24 24">
    <path d="M14,3.23V5.29C16.89,6.15 19,8.83 19,12C19,15.17 16.89,17.84 14,18.7V20.77C18,19.86 21,16.28 21,12C21,7.72 18,4.14 14,3.23M16.5,12C16.5,10.23 15.5,8.71 14,7.97V16C15.5,15.29 16.5,13.76 16.5,12M3,9V15H7L12,20V4L7,9H3Z"></path>
  </svg>
  <svg viewBox="0 0 24 24">
    <path d="M12,4L9.91,6.09L12,8.18M4.27,3L3,4.27L7.73,9H3V15H7L12,20V13.27L16.25,17.53C15.58,18.04 14.83,18.46 14,18.7V20.77C15.38,20.45 16.63,19.82 17.68,18.96L19.73,21L21,19.73L12,10.73M19,12C19,12.94 18.8,13.82 18.46,14.64L19.97,16.15C20.62,14.91 21,13.5 21,12C21,7.72 18,4.14 14,3.23V5.29C16.89,6.15 19,8.83 19,12M16.5,12C16.5,10.23 15.5,8.71 14,7.97V10.18L16.45,12.63C16.5,12.43 16.5,12.21 16.5,12Z"></path>
  </svg>
</label>

CSS

/* Click to restart animation. Source code: https://github.com/robole/artifice/ */
@import url("https://fonts.googleapis.com/css2?family=Archivo:wght@700&display=swap");

:root {
  --acronymn-font-size: 14rem;
  --small-text-padding: 2rem;
  --animation-time: 4s;
}

* {
  box-sizing: border-box;
}

body {
  background-color: black;
  perspective: 500px;
  perspective-origin: center 20%;
}

.poster {
  position: relative;
  font-family: "Archivo", serif;
  width: 300px;
  height: 400px;
  padding-top: 35px;
  margin: 30px auto;
  background: rgb(38, 106, 255);
  background: radial-gradient(
    circle,
    rgba(38, 106, 255, 1) 15%,
    rgba(168, 168, 247, 1) 21%,
    rgba(38, 106, 255, 1) 24%,
    rgba(0, 0, 138, 1) 50%
  );
  color: rgb(255, 255, 255);
  row-gap: 0;
  font-size: 0.5rem;
  transform: translateZ(-2000px);
  border: rgb(18, 47, 109) 1px solid;
  border-radius: 33% 33% 2% 2%;
  box-shadow: rgba(65, 65, 255, 0.5) 0 0 20px 5px;
}

.shadow {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  border-radius: inherit;
  box-shadow: rgba(65, 65, 255, 0.5) 0 0 20px 30px;
  opacity: 0;
  z-index: -1;
}

.content {
  display: grid;
  overflow: hidden;
}

p:not(.title) {
  padding-left: var(--small-text-padding);
}

.title {
  position: relative;
  height: calc(var(--acronymn-font-size));
  font-size: var(--acronymn-font-size);
  margin: 0;
  transform-origin: center center;
  transform: translateX(10%) scaleX(1.2);
  isolation: isolate;
}

.acronynm {
  position: absolute;
  color: red;
  opacity: 0.6;
  margin: 0;
  top: -20%;
  mix-blend-mode: luminosity;
}

.acronynm:nth-child(1) {
  z-index: 3;
  left: -6%;
}

.acronynm:nth-child(2) {
  color: white;
  left: 12%;
  top: -4%;
}

.acronynm:nth-child(3) {
  left: 53%;
  top: 6%;
}

label {
  position: fixed;
  top: 0;
  right: 0;
  height: 44px;
  width: 44px;
  cursor: pointer;
}

label > svg {
  position: absolute;
  height: 100%;
  width: 100%;
}

label path {
  fill: white;
}

label...

JavaScript

const animationDuration = 3;

const volume = document.querySelector("input");
volume.addEventListener("click", toggleMute);

const poster = document.getElementsByClassName("poster")[0];
poster.style.willChange = "transform, opacity"; // improves perf
poster.addEventListener("click", replay);

let siren = new Audio(
  "https://github.com/robole/artifice/raw/master/nwa/remix/siren.mp3"
);
// let siren = new Audio("siren.mp3");
siren.muted = true;

let tween1 = gsap.to(".poster", {
  z: 0,
  duration: animationDuration
});
let tween2 = gsap.to(".content", {
  rotationY: "1800",
  duration: animationDuration,
  onStart: playSiren,
  onComplete: stopSiren,
});
let tween3 = gsap.to(".shadow", {
  opacity: 1,
  duration: 0.25,
  yoyo: true,
  repeat: -1,
});
let tween4 = gsap.to(".poster", {
  opacity: 0.75,
  duration: 0.3,
  repeat: -1,
});

function toggleMute() {
  siren.muted = !siren.muted;

  if (tween2.isActive()) {
    playSiren();
  }
}

function stopSiren() {
  siren.pause();
}

function playSiren() {
  siren.currentTime = 0;
  siren.play();
}

function replay() {
  siren.currentTime = 0;
  tween1.restart();
  tween2.restart();
  tween3.restart();
}