<template>
  <div
    :style="styles"
    :class="[`text-${color}`]"
    class="vc-spinner vc-spinner--lds"
  />
</template>

<script lang="ts">
import { defineComponent } from 'vue'
import { convertToUnit } from '@/utils/helpers'

const DEFAULT_SIZE = 40

export default defineComponent({
  name: 'LdsSpinner',
  props: {
    size: {
      type: [String, Number],
      default: DEFAULT_SIZE
    },
    color: {
      type: String,
      default: 'primary'
    }
  },
  computed: {
    styles () {
      const size = convertToUnit(this.size)
      return {
        width: size,
        height: size,
        fontSize: size
      }
    }
  }
})
</script>

<style lang="scss" scoped>
  .vc-spinner--lds {
    display: inline-block;
    border: 0.1em solid var(--ui-lines);
    border-radius: 50%;
    border-top-color: currentColor;
    animation: spin 1s linear infinite;
  }
  @keyframes rotation {
    from {transform: rotate(0deg);}
    to {transform: rotate(359deg);}
  }
</style>
