Spinner.svelte 1.17 KB
<script>
  let { size = 40, color = 'currentColor' } = $props();
</script>

<svg
  fill={color}
  viewBox="0 -10 40 28"
  xmlns="http://www.w3.org/2000/svg"
  width={size}
  height={size * 0.7}
  class="spinner"
>
  <circle cx="8" cy="12" r="3" class="first"/>
  <circle cx="16" cy="12" r="3"/>
  <circle cx="24" cy="12" r="3"/>
  <circle cx="32" cy="12" r="3" class="second"/>
</svg>

<style>
  @keyframes swing {
    0% {
      transform: rotate(0deg);
      animation-timing-function: ease-out;
    }
    25% {
      transform: rotate(50deg);
      animation-timing-function: ease-in;
    }
    50% {
      transform: rotate(0deg);
      animation-timing-function: linear;
    }
  }

  @keyframes swing2 {
    0% {
      transform: rotate(0deg);
      animation-timing-function: linear;
    }
    50% {
      transform: rotate(0deg);
      animation-timing-function: ease-out;
    }
    75% {
      transform: rotate(-50deg);
      animation-timing-function: ease-in;
    }
  }

  .spinner .first {
    animation: swing 1.2s linear infinite;
    transform-origin: center top;
  }

  .spinner .second {
    animation: swing2 1.2s linear infinite;
    transform-origin: center top;
  }
</style>