<template>
  <div class="page-steps">
    <div :style="{margin}" class="step-list">
      <div v-for="(name, i) of data" :key="i" :class="{finished: index >= i}" class="step-item">0{{ i+1 }}. {{ name }}</div>
    </div>
  </div>
</template>
<script>
export default {
  name: 'Steps',
  props: {
    data: {
      type: Array,
      default() {
        return []
      }
    },
    index: {
      type: Number,
      default() {
        return 0
      }
    },
    // 针对只有2个步骤两边需要填充更多白边时，如卡解绑UI稿
    margin: {
      type: String,
      default() {
        return '0 0 0 0'
      }
    }
  }
}
</script>
<style lang="scss">
.page-steps {
  margin: 0 auto 12px;
  padding: 0 32px;
  width: 960px;
  height: 70px;
  background: #fff;
  border-radius: 8px;
  box-sizing: border-box;
  .step-list {
    height: 70px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    &:after {
      content: '';
      height: 4px;
      background: radial-gradient(circle at 1px 1px,#edeef0 2px, transparent 0);
      background-size: 10px 10px;
      position: absolute;
      top: 50%;
      left: 0;
      right: 0;
      margin-top: -2px;
      z-index: 1;
    }
  }
  .step-item {
    padding: 0 12px 0 34px;
    font-family: PingFangSC-Semibold, PingFang SC;
    font-weight: 600;
    background: #fff url(./icon_arrow.svg) no-repeat 12px center / 14px 14px;
    color: rgba(132, 133, 138, 0.6);
    position: relative;
    z-index: 9;
    &.finished {
      color: #212026;
      background: #fff url(./icon_arrow_finished.svg) no-repeat 12px center / 14px 14px;
    }
    &:first-child {
      padding-left: 22px;
      background-position: 0 center;
    }
  }
}
</style>
