<template>
<view
class="u-progress"
:style="{
borderRadius: round ? '100rpx' : 0,
height: height + 'rpx',
backgroundColor: inactiveColor
}"
>
<view
:class="[
type ? `u-type-${type}-bg` : '',
striped ? 'u-striped' : '',
striped && stripedActive ? 'u-striped-active' : ''
]"
class="u-active"
:style="[progressStyle]"
>{{showPercent ? percent + '%' : ''}}</view>
</view>
</template>
<script>
export default {
name: 'u-line-progress',
props: {
round: {
type: Boolean,
default: true
},
type: {
type: String,
default: ''
},
activeColor: {
type: String,
default: '#19be6b'
},
inactiveColor: {
type: String,
default: '#ececec'
},
percent: {
type: Number,
default: 0
},
showPercent: {
type: Boolean,
default: true
},
height: {
type: [Number, String],
default: 28
},
striped: {
type: Boolean,
default: false
},
stripedActive: {
type: Boolean,
default: false
}
},
data() {
return {}
},
computed: {
progressStyle() {
let style = {}
style.width = this.percent + '%'
if (this.activeColor) style.backgroundColor = this.activeColor
return style
}
},
methods: {}
}
</script>
<style lang="scss" scoped>
@import '../../libs/css/style.components.scss';
.u-progress {
overflow: hidden;
height: 15px;
display: inline-flex;
align-items: center;
width: 100%;
border-radius: 100rpx;
}
.u-active {
width: 0;
height: 100%;
align-items: center;
display: flex;
justify-items: flex-end;
justify-content: space-around;
font-size: 20rpx;
color: #ffffff;
transition: all 0.4s ease;
}
.u-striped {
background-image: linear-gradient(
45deg,
rgba(255, 255, 255, 0.15) 25%,
transparent 25%,
transparent 50%,
rgba(255, 255, 255, 0.15) 50%,
rgba(255, 255, 255, 0.15) 75%,
transparent 75%,
transparent
);
background-size: 39px 39px;
}
.u-striped-active {
animation: progress-stripes 2s linear infinite;
}
@keyframes progress-stripes {
0% {
background-position: 0 0;
}
100% {
background-position: 39px 0;
}
}
</style>