<script>
export default {
  name: "navTabs",
  props: {
    list: {default: []}
  },
  data() {
    return {
      active: 0
    }
  },
  methods: {
    handleClick(e, i) {
      this.active = i
      this.$emit("click", e)
    }
  },
  mounted() {
    if (this.list.length > 0) {
      this.$emit("click", this.list[0])
    }
  }
}
</script>

<template>
  <section class="navTabs">
    <div class="item" v-for="(e, i) in list" :key="i" v-text="e.label" @click="handleClick(e,i)" :class="{active:i==active}"/>
  </section>
</template>

<style scoped lang="scss">
.navTabs {
  display: flex;
  align-items: center;
  font-size: 12px;
  color: #01FFFF;
  gap: 4px;

  .item {
    opacity: .7;
    position: relative;
    cursor: pointer;

    &:hover {
      opacity: 1;
    }

    &.active {
      opacity: 1;

      &:after {
        content: " ";
        display: block;
        position: absolute;
        bottom: 0;
        left: 50%;
        width: 16px;
        height: 2px;
        transform: translate(-50%, 8px);
        background: #01FFFF;
        border-radius: 4px;
      }
    }
  }
}
</style>
