@import "../../styles/variables";

$small-spinner-size: 1.2em;
$medium-spinner-size: 1.8em;
$large-spinner-size: 2.1em;

:host {
  display: inline-block;
  width: $medium-spinner-size;
  height: $medium-spinner-size;
  position: relative;

  &.size-small {
    width: $small-spinner-size;
    height: $small-spinner-size;
  }

  &.size-large {
    width: $large-spinner-size;
    height: $large-spinner-size;
  }

  .dot {
    width: 100%;
    height: 100%;
    position: absolute;
    left: 0;
    top: 0;
  }

  .dot:before {
    content: "";
    display: block;
    margin: 0 auto;
    width: 15%;
    height: 15%;
    background-color: #333;
    border-radius: 100%;
    -webkit-animation: dotFadeDelay 1.2s infinite ease-in-out both;
    animation: dotFadeDelay 1.2s infinite ease-in-out both;
  }

  @each $analytics, $color in $analytics-colors {
    &.#{$analytics} {
      .dot:before {
        background-color: $color;
      }
    }
  }

  &.multicolor {
    @each $name, $color in $analytics-colors {
      $i: index($analytics-colors, $name $color);
      .dot:nth-of-type(#{$i}) {
        &:before {
          background-color: $color;
        }
      }
    }
  }

  &.white,
  &[inverse] {
    .dot:before {
      background-color: $white;
    }
  }

  .dot2 {
    -webkit-transform: rotate(30deg);
    -ms-transform: rotate(30deg);
    transform: rotate(30deg);
  }
  .dot3 {
    -webkit-transform: rotate(60deg);
    -ms-transform: rotate(60deg);
    transform: rotate(60deg);
  }
  .dot4 {
    -webkit-transform: rotate(90deg);
    -ms-transform: rotate(90deg);
    transform: rotate(90deg);
  }
  .dot5 {
    -webkit-transform: rotate(120deg);
    -ms-transform: rotate(120deg);
    transform: rotate(120deg);
  }
  .dot6 {
    -webkit-transform: rotate(150deg);
    -ms-transform: rotate(150deg);
    transform: rotate(150deg);
  }
  .dot7 {
    -webkit-transform: rotate(180deg);
    -ms-transform: rotate(180deg);
    transform: rotate(180deg);
  }
  .dot8 {
    -webkit-transform: rotate(210deg);
    -ms-transform: rotate(210deg);
    transform: rotate(210deg);
  }
  .dot9 {
    -webkit-transform: rotate(240deg);
    -ms-transform: rotate(240deg);
    transform: rotate(240deg);
  }
  .dot10 {
    -webkit-transform: rotate(270deg);
    -ms-transform: rotate(270deg);
    transform: rotate(270deg);
  }
  .dot11 {
    -webkit-transform: rotate(300deg);
    -ms-transform: rotate(300deg);
    transform: rotate(300deg);
  }
  .dot12 {
    -webkit-transform: rotate(330deg);
    -ms-transform: rotate(330deg);
    transform: rotate(330deg);
  }
  .dot2:before {
    -webkit-animation-delay: -1.1s;
    animation-delay: -1.1s;
  }
  .dot3:before {
    -webkit-animation-delay: -1s;
    animation-delay: -1s;
  }
  .dot4:before {
    -webkit-animation-delay: -0.9s;
    animation-delay: -0.9s;
  }
  .dot5:before {
    -webkit-animation-delay: -0.8s;
    animation-delay: -0.8s;
  }
  .dot6:before {
    -webkit-animation-delay: -0.7s;
    animation-delay: -0.7s;
  }
  .dot7:before {
    -webkit-animation-delay: -0.6s;
    animation-delay: -0.6s;
  }
  .dot8:before {
    -webkit-animation-delay: -0.5s;
    animation-delay: -0.5s;
  }
  .dot9:before {
    -webkit-animation-delay: -0.4s;
    animation-delay: -0.4s;
  }
  .dot10:before {
    -webkit-animation-delay: -0.3s;
    animation-delay: -0.3s;
  }
  .dot11:before {
    -webkit-animation-delay: -0.2s;
    animation-delay: -0.2s;
  }
  .dot12:before {
    -webkit-animation-delay: -0.1s;
    animation-delay: -0.1s;
  }

  @-webkit-keyframes dotFadeDelay {
    0%,
    39%,
    100% {
      opacity: 0;
    }
    40% {
      opacity: 1;
    }
  }

  @keyframes dotFadeDelay {
    0%,
    39%,
    100% {
      opacity: 0;
    }
    40% {
      opacity: 1;
    }
  }
}
