<template>
  <div>
    <div class="progressOuter">
      <div class="progressInner">
        <div
          class="progressBg"
          :style="style"
        />
      </div>
    </div>
    <div
      class="progressPer"
      v-if="isShowInfo"
    >
      {{ percent }}%
    </div>
  </div>
</template>

<script>
export default {
  name: 'Progress',
  props: {
    percent: {
      type: Number,
      default: 0,
    },
    percentHeight: {
      type: Number,
      default: 10,
    },
    isShowInfo: {
      type: Boolean,
      default: true,
    },
  },
  computed: {
    style() {
      return {
        '--height': this.percentHeight + 'px',
        '--width': this.percent + '%',
      }
    },
  },
}
</script>

<style lang="scss" scoped>
@import '../const/variable.scss';

.progressOuter {
  display: inline-block;
  margin-right: calc(-2em - 10px);
  padding-right: calc(2em + 10px);
  width: 100%;
}
.progressInner {
  background-color: palette(gray, base);
  border-radius: 100px;
  display: inline-block;
  overflow: hidden;
  position: relative;
  vertical-align: middle;
  width: 100%;
}
.progressBg {
  --height: 10px;
  --width: 0%;
  background-color: palette(blue, base);
  border-radius: 100px;
  height: var(--height);
  transition: all 0.4s cubic-bezier(0.08, 0.82, 0.17, 1) 0s;
  width: var(--width);
}
.progressPer {
  text-align: right;
  margin-top: 5px;
}
</style>
