JSFiddle - React, Tailwind, and code Playground

by velo_ninja

HTML

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <style>
    /* Add your custom styles for the preloader here */
    body {
      margin: 0;
      font-family: 'Arial', sans-serif;
      display: flex;
      justify-content: center;
      align-items: center;
      height: 100vh;
      background-color: #f0f0f0; /* Background color of the page */
    }

    .preloader-container {
      position: relative;
      width: 100px;
      height: 100px;
    }

    .preloader {
      position: absolute;
      width: 100%;
      height: 100%;
      border-radius: 50%;
      border: 8px solid #3498db; /* Color of the spinner */
      border-top: 8px solid transparent;
      animation: spin 1s linear infinite;
    }

    @keyframes spin {
      0% { transform: rotate(0deg); }
      100% { transform: rotate(360deg); }
    }
  </style>
</head>
<body>
  <div class="preloader-container">
    <div class="preloader"></div>
  </div>

  <!-- Your main content goes here -->

  <script>
    document.addEventListener("DOMContentLoaded", function() {
      function checkSignal() {
        const urlParams = new URLSearchParams(window.location.search);
        const signal = urlParams.get('signal');

        if (signal === 'activate') {
          // Activate the preloader
          document.querySelector('.preloader-container').style.display = 'block';
        } else if (signal === 'inactivate') {
          // Inactivate the preloader
          document.querySelector('.preloader-container').style.display = 'none';
        }

        // Continue checking for the signal
        requestAnimationFrame(checkSignal);
      }

      // Start checking for the signal
      checkSignal();
    });
  </script>
</body>
</html>