<template>
  <view class="kd-tabs-container">
    <view
      class="tab-item"
      @click="tabClick(item, index)"
      :class="{ active: active === index }"
      v-for="(item, index) in list"
      :key="index"
    >
      {{ item }}
    </view>
  </view>
</template>

<script>
export default {
  model: {
    prop: 'active',
    event: 'change'
  },
  props: {
    list: {
      type: Array,
      default: () => []
    },
    active: {
      type: Number,
      default: 0
    }
  },
  methods: {
    tabClick (item, index) {
      this.$emit('change', index)
    }
  }
}
</script>

<style lang="scss" scoped>
.kd-tabs-container {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  // border-bottom: 1rpx solid rgb(215 215 215);
  border-bottom: 1rpx solid #d7d7d7;
  .tab-item {
    height: 50rpx;
    padding: 0 30rpx;
    line-height: 50rpx;
    text-align: center;
    font-size: 32rpx;
    background-color: rgba(242, 242, 242, 1);
    color: #333;
    border-top: 1rpx solid rgba(242, 242, 242, 1);
    border-radius: 4rpx;
    margin-left: 8rpx;
    &.active {
      color: $j-primary-border-green;
      border-color: $j-primary-border-green;
    }
  }
}
</style>
