<template>
	<view class="content">
		<view v-for="(item, index) in list" :key="index" 
			class="list" 
			:style="index == list.length - 1 ? 'padding-bottom: 60rpx' : ''">
			<view class="left">
				<view class="up-line" :class="{'remove-line': index == 0}"
					:style="{'border-color': themeColor, 'background-color': themeColor}"></view>
				<view class="icon" :style="{
					'background-color': index == list.length - 1 && !item.isFinished ? themeColor : '#fff',
					'border-color': themeColor,
					'color': themeColor}">
					<u-icon name="arrow-down" color="#fff" v-if="index == list.length - 1 && !item.isFinished"></u-icon>
					<u-icon name="checkmark" v-else></u-icon>
				</view>
				<view class="down-line" :class="{
						'dotted-line': index == list.length - 1 && !item.isFinished,
						'remove-line': index == list.length - 1 && item.isFinished
					}" :style="{'border-color': themeColor, 'background-color': themeColor}">
				</view>
			</view>
			<view class="right">
				<view class="desc">
					<text class="lf-line-2">{{ item.action }}</text>
					<text class="date">{{ item.created_at }}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: 'lf-step-bar',
		props: {
			themeColor: {
				type: String,
				default: '#1833F2'
			},
			list: {
				type: Array,
				default(){
					return []
				}
			}
		}
	}
</script>

<style lang="scss" scoped="scoped">
	.content{
		width: 100%;
		height: max-content;
		padding: 0 16px;
	}
	.list{
		display: flex;
		align-items: center;
		justify-content: space-between;
		min-height: 46px;
		.left{
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-content: center;
			align-items: center;
			margin-right: 6px;
			.up-line,.down-line{
				height: 20px;
				width: 1px;
				border: 1px solid #1833F2;
				background-color: #1833F2;
				position: relative;
			}
			.remove-line{
				border: none !important;
				background-color: transparent !important;
			}
			.dotted-line::after{
				content: '';
				position: absolute;
				left: -1px;
				bottom: -20px;
				height: 20px;
				width: 0px;
				border: 1px dashed #999999;
			}
			.icon{
				width: 30px;
				height: 30px;
				box-sizing: border-box;
				border: 2px solid #1833F2;
				color: #1833F2;
				border-radius: 50%;
				background-color: #fff;
				display: flex;
				justify-content: center;
				align-content: center;
			}
		}
		.right{
			flex: auto;
			.desc{
				position: relative;
				font-size: 28rpx;
				color: #222222;
				.date{
					position: absolute;
					bottom: -18px;
					left: 0;
					font-size: 24rpx;
					color: #999999;
				}
			}
		}
	}
</style>
