<template>
  <div class="dot-wrapper">
    <div class="dot-item" v-for="item in itemLen" :key="item">
      <a
        href="javascript:;"
        class="dot-link"
        :style="{
          backgroundColor: item - 1 === currentIndex ? dotBgColor : '#fff',
        }"
        @click="dotClick(item - 1)"
      ></a>
    </div>
  </div>
</template>

<script>
export default {
  name: "Dot",
  props: {
    itemLen: Number,
    currentIndex: {
      type: Number,
      default: 0,
    },
    dotBgColor: {
      type: String,
      default: "#ffff00",
    },
  },
  setup(props, ctx) {
    const dotClick = (index) => {
      ctx.emit("dotClick", index);
    };
    return {
      dotClick,
    };
  },
};
</script>

<style lang="scss" scoped>
.dot-wrapper {
  position: absolute;
  z-index: 2;
  left: 50%;
  transform: translateX(-50%);
  bottom: 5px;
  .dot-item {
    float: left;
    margin-right: 20px;
    a {
      display: inline-block;
      width: 10px;
      height: 10px;
      border-radius: 50%;
    }
  }
}
</style>