<template>
  <div v-show="spinning" class="spin-container">
    <div class="spin-overlay">
      <div class="loading-wrap">
        <div class="loading-dots">
          <span class="dot dot-spin"><i></i><i></i><i></i><i></i></span>
        </div>
      </div>
    </div>
  </div>
</template>
  
<script lang="ts" setup>
defineProps<{
  spinning: boolean
}>()
</script>
  
<style lang="scss" scoped>
.spin-container {
  position: relative;
  .spin-overlay {
    /* position: fixed; */
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* background-color: rgba(255, 255, 255, 0.7); */
    z-index: 1001;
    .loading-wrap {
      display: flex;
      position: absolute;
      top: 50%;
      left: 50%;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      transform: translate3d(-50%, -50%, 0);
      .dots {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 98px;
      }
      .dot {
        display: inline-block;
        position: relative;
        box-sizing: border-box;
        width: 28px;
        height: 28px;
        margin-top: 30px;
        transform: rotate(45deg);
        animation: ant-rotate 1.2s infinite linear;
        font-size: 32px;
        i {
          display: block;
          position: absolute;
          width: 13px;
          height: 13px;
          transform: scale(0.75);
          transform-origin: 50% 50%;
          animation: ant-spin-move 1s infinite linear alternate;
          border-radius: 100%;
          opacity: 0.3;
          background-color: #0065cc;
          &:nth-child(1) {
            top: 0;
            left: 0;
          }
          &:nth-child(2) {
            top: 0;
            right: 0;
            animation-delay: 0.4s;
          }
          &:nth-child(3) {
            right: 0;
            bottom: 0;
            animation-delay: 0.8s;
          }
          &:nth-child(4) {
            bottom: 0;
            left: 0;
            animation-delay: 1.2s;
          }
        }
      }
    }
  }
}

@keyframes ant-rotate {
  to {
    transform: rotate(405deg);
  }
}

@keyframes ant-rotate {
  to {
    transform: rotate(405deg);
  }
}

@keyframes ant-spin-move {
  to {
    opacity: 1;
  }
}

@keyframes ant-spin-move {
  to {
    opacity: 1;
  }
}
</style>