123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- <template>
- <view class="u-progress" :style="{
- borderRadius: round ? '100rpx' : 0,
- height: height + 'rpx',
- backgroundColor: inactiveColor
- }">
- <view :class="{'u-striped': striped, 'u-striped-active': striped && stripedActive}" 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 (['success', 'error', 'info', 'primary', 'warning'].indexOf(this.type) >= 0) style.backgroundColor = this.$u.color[
- this.type];
- else style.backgroundColor = this.activeColor;
- return style;
- }
- },
- methods: {
- }
- }
- </script>
- <style lang="scss" scoped>
- .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>
|