<template>
  <div class="loading-container" v-show="visible">
    <div class="content">
      <img src="@/assets/loading.gif" :style="{width: Sized, height: Sized}">
      <div class="text">
        {{ loadingText }}
      </div>
      <slot></slot>
    </div>
  </div>
</template>

<script>

const classEnum = {
  small: '56px',
  default: '86px',
  large: '106px',
  largeX: '126px',
  largeXX: '146px',
  largeXXL: '186px',
}
export default {
  name: "loading",
  data() {
    return {
      size: '100px'
    }
  },
  props: {
    visible: {
      default: false,
      type: Boolean,
      required: true,
    },
    loadingText: {
      default: '',
      type: String,
      required: false,
    },
    fullScreen: {
      default: false,
      type: Boolean,
      required: false,
    },
    size: {
      type: String,
      default: 'default',
      required: false,
    }
  },
  computed: {
    Sized() {
      if (Object.keys(classEnum).some((item) => item === this.size)) {
        return classEnum[this.size]
      } else {
        return classEnum.default
      }
    }
  },
}
</script>

<style scoped lang="scss">
.loading-container {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 3000;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);

  .content {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    background: rgba(255, 255, 255, 1);
    padding: 50px;
    padding-top: 20px;
    border-radius: 2px;
    max-width: 600px;

    .image_small {
      width: 56px;
      height: 56px;
    }

    .image_default {
      width: 100px;
      height: 100px;
    }

    .image_large {
      width: 180px;
      height: 180px;
    }

    .text {
      text-align: center;
      width: 100%;
      color: #666666;
    }
  }
}
</style>
