<template>
  <div v-if="isLoading" class="preview-loader" :class="{ shifted }">
    <div class="spinner"></div>
  </div>
</template>

<script setup>
defineProps({
  isLoading: {
    type: Boolean,
    required: true
  },
  shifted: {
    type: Boolean,
    default: false
  }
});
</script>

<style scoped>
.preview-loader {
  position: fixed;
  top: 2rem;
  right: 2rem;
  z-index: 1000;
  pointer-events: none;
  transition: all 0.2s ease-in-out var(--curve);
}

.preview-loader.shifted {
  right: calc(2rem + 19rem * 0.7);
  top: calc(2rem - 30vh * 0.7);
  transform: scale(0.7);
}

.spinner {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: inline-block;
  border-top: 3px solid #000;
  border-right: 3px solid transparent;
  box-sizing: border-box;
  animation: rotation 1s linear infinite;
}

@keyframes rotation {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}
</style>
