<template>
  <div
    v-if="isLoading"
    class="loading-overlay"
    :style="{ backgroundColor: loadingBg.value }"
  >
    <div class="spinner"></div>
  </div>
</template>

<script lang="ts">
import { computed, defineComponent } from "vue";
import { useLoadingStore } from "@/stores/loadingStore";
import { loadingBg } from "@/utils/common";

export default defineComponent({
  computed: {
    loadingBg() {
      return loadingBg;
    },
  },
  setup() {
    const loadingStore = useLoadingStore();
    const isLoading = computed(() => loadingStore.isLoading);

    return {
      isLoading,
    };
  },
});
</script>

<style>
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.spinner {
  border: 4px solid rgb(207, 207, 207);
  border-top: 4px solid #3c8872;

  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
    border: 4px solid rgb(207, 207, 207);
  border-top: 4px solid #3c8872;

}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
</style>
