<template>
  <div>
    <ul class="diy-steps">
      <li v-for="(item, index) in stepList" :key="index">
        <div class="diy-step">
          <div class="diy-step-line_left" v-if="index === 0 && item.status === 'undone'" :style="'background-image: linear-gradient(' + '90deg' + ', #ffffff, #bbbbbb)'"/>
          <div class="diy-step-line_left" v-if="index === 0 && item.status !== 'undone'" :style="'background-image: linear-gradient(' + '90deg' + ', #ffffff, #4cb45b)'"/>
          <div class="diy-step-line_left" v-else-if="index !== 0 && item.status === 'undone'" :style="'background-image: linear-gradient(' + '0deg' + ', #bbbbbb, #bbbbbb)'"/>
          <div class="diy-step-line_left" v-else-if="index !== 0 && item.status !== 'undone'" :style="'background-image: linear-gradient(' + '0deg' + ', #4cb45b, #4cb45b)'"/>

          <div class="diy-step-box diy-step__success" v-if="item.status === 'success'">
            <span>
              <i class="el-icon-check"></i>
            </span>
            <strong>{{ item.label }}</strong>
          </div>

          <div class="diy-step-box diy-step__fail" v-else-if="item.status === 'fail'">
            <span>
              <i class="el-icon-close"></i>
            </span>
            <strong>{{ item.label }}</strong>
          </div>

          <div class="diy-step-box diy-step__doing" v-else-if="item.status === 'doing'">
            <span>
              <i class=""></i>
            </span>
            <strong>{{ item.label }}</strong>
          </div>

          <div class="diy-step-box diy-step__undone" v-else-if="item.status === 'undone'">
            <span>
              <i class=""></i>
            </span>
            <strong>{{ item.label }}</strong>
          </div>

          <div class="diy-step-line_right" v-if="index === stepList.length - 1 && item.status === 'success'" :style="'background-image: linear-gradient(' + '90deg' + ', #4cb45b, #ffffff)'"/>
          <div class="diy-step-line_right" v-else-if="index === stepList.length - 1 && item.status === 'fail'" :style="'background-image: linear-gradient(' + '90deg' + ', #4cb45b, #ffffff)'"/>
          <div class="diy-step-line_right" v-else-if="index === stepList.length - 1 && item.status === 'doing'" :style="'background-image: linear-gradient(' + '90deg' + ', #bbbbbb, #ffffff)'"/>
          <div class="diy-step-line_right" v-else-if="index === stepList.length - 1 && item.status === 'undone'" :style="'background-image: linear-gradient(' + '90deg' + ', #bbbbbb, #ffffff)'"/>
          <div class="diy-step-line_right" v-else-if="index !== stepList.length - 1 && item.status === 'undone' && (index + 1 <= stepList.length - 1) && stepList[index + 1].status === 'undone' " :style="'background-image: linear-gradient(' + '180deg' + ', #bbbbbb, #bbbbbb)'"/>
          <div class="diy-step-line_right" v-else-if="index !== stepList.length - 1 && item.status !== 'undone' && (index + 1 <= stepList.length - 1) && stepList[index + 1].status === 'undone' " :style="'background-image: linear-gradient(' + '180deg' + ', #bbbbbb, #bbbbbb)'"/>
          <div class="diy-step-line_right" v-else-if="index !== stepList.length - 1 && item.status !== 'undone' && (index + 1 <= stepList.length - 1) && stepList[index + 1].status !== 'undone' " :style="'background-image: linear-gradient(' + '180deg' + ', #4cb45b, #4cb45b)'"/>
        </div>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  props: ['stepList'],
  data: () => ({
    // stepList : [
    //   {label: '准备好所有的食材', status: 'success'},
    //   {label: '把茶叶和白砂糖放入锅中', status: 'success'},
    //   {label: '将其翻炒至冒泡', status: 'fail'},
    //   {label: '加入白开水煮沸', status: 'doing'},
    //   {label: '倒入纯牛奶', status: 'undone'},
    //   {label: '滤出茶叶就好了', status: 'undone'}
    // ],
  })
}
</script>

<style lang="less">
.diy-steps {
  width: auto;
  height: 55px;
  margin: 40px auto 0 auto;
  padding: 0;
  position: relative;
  display: table;
  font-family: "微软雅黑";
}

.diy-steps li {
  width: 260px;
  height: 100%;
  list-style-type: none;
  font-size: 12px;
  text-align: center;
  position: relative;
  float: left;
}

.diy-steps li .diy-step {
  width: 260px;
  display: inline-block;
  position: absolute;
  margin-left: -130px;
  left: 50%;
  z-index: 1;
}

.diy-step-line_left {
  border-bottom: 1px solid transparent;
  background-image: linear-gradient(90deg, #bbbbbb, #4cb45b);
  width:130px;
  height: 1px;
  display: inline-block;
  position: absolute;
  top: 9px;
  left: 0;
  z-index: 0;
}

.diy-step-line_right {
  border-bottom: 1px solid transparent;
  background-image: linear-gradient(180deg, #bbbbbb, #4cb45b);
  width:130px;
  height: 1px;
  display: inline-block;
  position: absolute;
  top: 9px;
  right: 0;
  z-index: 0;
}

.diy-steps li .diy-step .diy-step-box {
  position: relative;
  z-index: 1;
}

.diy-steps li .diy-step .diy-step-box span {
  display: block;
  width: 13px;
  height: 13px;
  border-radius: 100%;
  color: #fff;
  /* transform: scale(1.2); */
  text-align: center;
  margin: 0 auto 8px auto;
}

.diy-steps li .diy-step .diy-step-box span i {
  display: block;
  width: 13px;
  height: 13px;
  border-radius: 100%;
  line-height: 13px;
}

.diy-steps li .diy-step .diy-step-box strong {
  letter-spacing: 0.5px;
}

/* diy-step__success */
.diy-step__success span {
  border: rgba(55, 171, 71, 0.2) 4px solid;
  border: rgb(215 238 218) 4px solid;
}

.diy-step__success span i {
  background-color: #37ab47;
}

.diy-step__success strong {
  color: #37ab47;
}
/* / diy-step__success */

/* diy-step__fail */
.diy-step__fail span {
  border: rgba(252, 94, 90, 0.2) 4px solid;
  border: rgb(254 223 222) 4px solid;
}

.diy-step__fail span i {
  background-color: #fc5e5a;
}

.diy-step__fail strong {
  color: #fc5e5a;
}
/* / diy-step__fail */

/* diy-step__doing */
.diy-step__doing span {
  border: rgba(94, 124, 224, 0.2) 4px solid;
  border: rgb(223 229 249) 4px solid;
}

.diy-step__doing span i {
  background-color: #5e7ce0;
}

.diy-step__doing strong {
  color: #5e7ce0;
}
/* / diy-step__doing */

/* diy-step__undone */
.diy-step__undone span {
  border: rgba(153, 153, 153, 0.2) 4px solid;
  border: rgb(235 235 235) 4px solid;
}

.diy-step__undone span i {
  background-color: #999999;
}

.diy-step__undone strong {
  color: #999999;
}
/* / diy-step__undone */
</style>