JSFiddle - React, Tailwind, and code Playground

by hexzero

HTML

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" href="./style.css" />
    <title>Answer</title>
  </head>
  <body>
    <section>
      <div role="list" class="banner__list w-dyn-items">
        <div
          class="image-container"
          onmouseenter="startSlideShow(true)"
          onmouseleave="startSlideShow(false)"
        >
          <div
            style="background: blue;"
            role="listitem"
            class="banner__item w-dyn- item mySlides"
          ></div>
          <div
            style="background: black;"
            role="listitem"
            class="banner__item w-dyn-item mySlides"
          ></div>
          <div
            style="background: red;"
            role="listitem"
            class="banner__item w-dyn-item mySlides"
          ></div>
        </div>
        <span class="dot" onmouseover="currentSlide(1)"></span>
        <span class="dot" onmouseover="currentSlide(2)"></span>
        <span class="dot" onmouseover="currentSlide(3)"></span>
      </div>
    </section>
  </body>
  <script src="./Main.js" defer></script>
</html>

CSS

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: antiquewhite;
}

.mySlides {
  width: 15rem;
  height: 15rem;
}

.dot {
  background: green;
  width: 3rem;
  height: 3rem;
  display: inline-block;
  border: solid 4px transparent;
}

.dot:first-of-type {
  background: blue;
}

.dot:last-of-type {
  background: red;
}

.dot.active {
  border: solid 4px black;
}

.image-container {
  display: inline-block;
}

JavaScript

var slideIndex = 1;
showSlides(slideIndex);

function plusSlides(n) {
  showSlides((slideIndex += n));
}

function currentSlide(n) {
  showSlides((slideIndex = n));
}

var slideShowInterval;

function startSlideShow(start) {
  if (start) {
    currentSlide((slideIndex += 1));
    slideShowInterval = setInterval(function () {
      currentSlide((slideIndex += 1));
    }, 700);
  } else {
    clearInterval(slideShowInterval);
  }
}

function showSlides(n) {
  var i;
  var slides = document.getElementsByClassName("mySlides");
  var dots = document.getElementsByClassName("dot");
  if (n > slides.length) {
    slideIndex = 1;
  }
  if (n < 1) {
    slideIndex = slides.length;
  }
  for (i = 0; i < slides.length; i++) {
    slides[i].style.display = "none";
  }
  for (i = 0; i < dots.length; i++) {
    dots[i].className = dots[i].className.replace(" active", "");
  }
  slides[slideIndex - 1].style.display = "block";
  dots[slideIndex - 1].className += " active";
}