Commit 9d6b35e49b5c5e1fe2d0c3935af27efb20c53a44

Authored by 梁灏
1 parent b40e2e96

Progress add prop success-percent

examples/routers/progress.vue
1 1 <template>
2 2 <div>
3   - <i-progress :percent="percent"></i-progress>
4   - <Button-group size="large">
5   - <Button icon="ios-plus-empty" @click.native="add"></Button>
6   - <Button icon="ios-minus-empty" @click.native="minus"></Button>
7   - </Button-group>
8   - <i-progress :percent="25" :stroke-width="5"></i-progress>
9   - <i-progress :percent="100">
10   - <Icon type="checkmark-circled"></Icon>
11   - <span>成功</span>
12   - </i-progress>
13   - <i-progress :percent="percent"></i-progress>
14   - <div style="height: 150px">
15   - <i-progress vertical :percent="percent" :stroke-width="20" hide-info></i-progress>
16   - <i-progress vertical :percent="percent"></i-progress>
17   - </div>
  3 + <Progress :percent="25"></Progress>
  4 + <br><br>
  5 + <Progress :percent="25" :success-percent="10"></Progress>
18 6 </div>
19 7 </template>
20 8 <script>
21 9 export default {
22   - data () {
23   - return {
24   - percent: 0
25   - }
26   - },
27   - methods: {
28   - add () {
29   - if (this.percent >= 100) {
30   - return false;
31   - }
32   - this.percent += 10;
33   - },
34   - minus () {
35   - if (this.percent <= 0) {
36   - return false;
37   - }
38   - this.percent -= 10;
39   - }
40   - }
  10 +
41 11 }
42 12 </script>
... ...
src/components/circle/circle.vue
... ... @@ -96,13 +96,13 @@
96 96 style = {
97 97 'stroke-dasharray': `${(this.percent / 100) * (this.len - 75)}px ${this.len}px`,
98 98 'stroke-dashoffset': `-${75 / 2}px`,
99   - 'transition': 'stroke-dashoffset .3s ease 0s, stroke-dasharray .3s ease 0s, stroke .3s, stroke-width .06s ease .3s'
  99 + 'transition': 'stroke-dashoffset .3s ease 0s, stroke-dasharray .6s ease 0s, stroke .6s, stroke-width .06s ease .6s'
100 100 };
101 101 } else {
102 102 style = {
103 103 'stroke-dasharray': `${this.len}px ${this.len}px`,
104 104 'stroke-dashoffset': `${((100 - this.percent) / 100 * this.len)}px`,
105   - 'transition': 'stroke-dashoffset 0.3s ease 0s, stroke 0.3s ease'
  105 + 'transition': 'stroke-dashoffset 0.6s ease 0s, stroke 0.6s ease'
106 106 };
107 107 }
108 108 return style;
... ...
src/components/progress/progress.vue
... ... @@ -3,6 +3,7 @@
3 3 <div :class="outerClasses">
4 4 <div :class="innerClasses">
5 5 <div :class="bgClasses" :style="bgStyle"></div>
  6 + <div :class="successBgClasses" :style="successBgStyle"></div>
6 7 </div>
7 8 </div>
8 9 <span v-if="!hideInfo" :class="textClasses">
... ... @@ -30,6 +31,10 @@
30 31 type: Number,
31 32 default: 0
32 33 },
  34 + successPercent: {
  35 + type: Number,
  36 + default: 0
  37 + },
33 38 status: {
34 39 validator (value) {
35 40 return oneOf(value, ['normal', 'active', 'wrong', 'success']);
... ... @@ -80,6 +85,15 @@
80 85 height: `${this.strokeWidth}px`
81 86 };
82 87 },
  88 + successBgStyle () {
  89 + return this.vertical ? {
  90 + height: `${this.successPercent}%`,
  91 + width: `${this.strokeWidth}px`
  92 + } : {
  93 + width: `${this.successPercent}%`,
  94 + height: `${this.strokeWidth}px`
  95 + };
  96 + },
83 97 wrapClasses () {
84 98 return [
85 99 `${prefixCls}`,
... ... @@ -105,6 +119,9 @@
105 119 },
106 120 bgClasses () {
107 121 return `${prefixCls}-bg`;
  122 + },
  123 + successBgClasses () {
  124 + return `${prefixCls}-success-bg`;
108 125 }
109 126 },
110 127 created () {
... ...
src/styles/components/progress.less
... ... @@ -34,6 +34,7 @@
34 34 background-color: #f3f3f3;
35 35 border-radius: 100px;
36 36 vertical-align: middle;
  37 + position: relative;
37 38 }
38 39 &-vertical &-inner {
39 40 height: 100%;
... ... @@ -52,10 +53,18 @@
52 53  
53 54 &-bg {
54 55 border-radius: 100px;
55   - background-color: @info-color;
  56 + background-color: @primary-color;
56 57 transition: all @transition-time linear;
57 58 position: relative;
58 59 }
  60 + &-success-bg{
  61 + border-radius: 100px;
  62 + background-color: @success-color;
  63 + transition: all @transition-time linear;
  64 + position: absolute;
  65 + top: 0;
  66 + left: 0;
  67 + }
59 68  
60 69 &-text {
61 70 display: inline-block;
... ...