<template>
  <a class="upanapp-button-tab-item" :class="classes" href="javascript:" :style="style" @click="onItemClick">
    <slot></slot>
  </a>
</template>

<script>
import { childMixin } from '../../mixins/multi-items'

export default {
  name: 'ua-button-tab-item',
  mixins: [childMixin],
  computed: {
    classes () {
      return {
        'upanapp-button-group-current': this.currentIndex === this.$parent.currentIndex,
        'upanapp-button-tab-item-first': this.currentIndex === 0,
        'upanapp-button-tab-item-last': this.currentIndex === this.$parent.$children.length - 1,
        'upanapp-button-tab-item-middle': this.currentIndex > 0 && this.currentIndex !== this.$parent.$children.length - 1
      }
    },
    style () {
      if (this.$parent.height) {
        return {
          height: `${this.$parent.height}px`,
          lineHeight: `${this.$parent.height}px`
        }
      }
    }
  }
}
</script>
