<template>
<div class="upanapp-step-item" :class=" { 'upanapp-step-item-with-tail' : !currentStepLast} ">
  <div :class="'upanapp-step-item-tail ' + 'upanapp-step-item-tail-' + currentStatus" v-show="!currentStepLast" :style="{right: $parent.gutter}"></div>
  <div :class="'upanapp-step-item-head ' + 'upanapp-step-item-head-' + currentStatus">
    <div class="upanapp-step-item-head-inner">
      <span v-if="!icon && currentStatus!='finish'" class="upanapp-step-item-icon">{{currentStepNumber}}</span>
      <span v-else :class="'upanapp-step-item-icon ' + 'upanapp-step-item-' + iconName">
        <ua-icon type="success_no_circle" class="upanapp-step-item-checked"></ua-icon>
      </span>
    </div>
  </div>
  <div :class="'upanapp-step-item-main ' + 'upanapp-step-item-main-' + currentStatus" :style="{backgroundColor: $parent.backgroundColor, paddingRight: currentStepLast ? 0 : $parent.gutter}">
    <span class="upanapp-step-item-title">{{title}}</span>
    <div class="upanapp-step-item-description">{{description}}</div>
  </div>
</div>
</template>

<script>
import UaIcon from '../icon'

export default {
  name: 'ua-step-item',
  props: {
    title: String,
    description: String,
    stepNumber: Number,
    stepLast: Boolean,
    icon: String,
    status: String,
    tailWidth: Object
  },
  computed: {
    iconName () {
      return this.icon || 'check'
    }
  },
  created () {
    this.currentStatus = this.status
    this.currentStepLast = this.stepLast
    this.currentStepNumber = this.stepNumber
  },
  data () {
    return {
      currentStatus: '',
      currentStepLast: false,
      currentStepNumber: 0
    }
  },
  components: {
    UaIcon
  }
}
</script>
