<template>
  <div class="steps flex">
    <div v-for="(step, index) in steps" :key="index" class="node">
      <div v-if="step.flag" class="node-status-success">
        <span class="icon"></span>
      </div>
      <div v-else class="node-status-default"></div>
      <template v-if="index < steps.length - 1">
        <div
          v-if="step.flag && steps[index + 1] && steps[index + 1].flag"
          class="node-status-success-line"
        ></div>
        <div v-else class="node-status-default-line"></div>
      </template>
      <div
        :style="{
          width: step.labelWidth ? step.labelWidth + 'px' : 60 + 'px',
          transform: `translateX(-${
            step.labelWidth ? step.labelWidth / 3 : 60 / 3
          }px)`,
        }"
        class="node-cap"
      >
        <div class="node-name">{{ step.name }}</div>
        <div class="node-info">
          <span
            class="node-info-list"
            v-for="(p, i) in step.descriptions"
            :key="i"
            >{{ p }}<br />
            <!-- <br v-if="i == 1" /> -->
            <!-- <i v-if="i % 2 == 0">/</i> -->
          </span>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { PropType } from 'vue'

type StepData = {
  name: string
  flag: boolean
  labelWidth?: number
  descriptions: string[]
}

const props = defineProps({
  steps: {
    type: Array as PropType<StepData[]>,
    default: () => [],
  },
})
</script>

<style lang="scss" scoped>
.steps {
  padding: 0 13px;
  .node {
    position: relative;
    width: 100%;
    &:last-child {
      width: 2%;
    }
    &-name {
      font-size: 14px;
      font-family: Microsoft YaHei;
      font-weight: bold;
      color: #101116;
    }
    &-cap {
      text-align: center;
      margin-top: 10px;
      .node-info {
        display: flex;
        flex-direction: column;
        &-list {
          // font-size: 12px;
          font-family: DIN, Microsoft YaHei;
          font-weight: 400;
          color: #101116;
          margin-top: 8px;
        }
      }
    }
  }
  .node-status-success {
    position: relative;
    width: 24px;
    height: 24px;
    background: #ffffff;
    border: 2px solid #d5327b;
    border-radius: 50%;
    z-index: 2;
    .icon {
      width: 14px;
      height: 14px;
      background: #d5327b;
      border-radius: 50%;
      position: absolute;
      top: 50%;
      left: 50%;
      margin-top: -7px;
      margin-left: -7px;
    }
  }
  .node-status-default {
    width: 24px;
    height: 24px;
    background: #ffffff;
    border: 2px solid #b7b1b4;
    border-radius: 50%;
    z-index: 2;
    position: relative;
  }
  .node-status-success-line {
    height: 6px;
    background: #d5327b;
    position: absolute;
    width: 100%;
    top: 9px;
    left: 0;
    z-index: 1;
  }
  .node-status-default-line {
    height: 6px;
    background: #b7b1b4;
    position: absolute;
    width: 100%;
    top: 9px;
    left: 0;
    z-index: 1;
  }
}
</style>
