<template>
  <div
    v-if="isLoading"
    class="loading-overlay-goods"
    :style="{ backgroundColor: loadingBg.value }"
  >
    <div class="spinner-goods"></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-goods {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  background-color: rgba(0, 0, 0, 0.45);
}

.spinner-goods {
  border: 4px solid rgb(207, 207, 207);
  border-top: 4px solid var(--global-primary-color);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  animation: spin 1s linear infinite;
}

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