Commit 4b8b19522478ad06470d0d56b74b4d0362c1a59a

Authored by Aresn
Committed by GitHub
2 parents 7f08fb51 48921bf5

Merge pull request #1433 from rijn/629

Add vertical progressbar
examples/routers/progress.vue
@@ -10,6 +10,11 @@ @@ -10,6 +10,11 @@
10 <Icon type="checkmark-circled"></Icon> 10 <Icon type="checkmark-circled"></Icon>
11 <span>成功</span> 11 <span>成功</span>
12 </i-progress> 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>
13 </div> 18 </div>
14 </template> 19 </template>
15 <script> 20 <script>
src/components/progress/progress.vue
@@ -43,6 +43,10 @@ @@ -43,6 +43,10 @@
43 strokeWidth: { 43 strokeWidth: {
44 type: Number, 44 type: Number,
45 default: 10 45 default: 10
  46 + },
  47 + vertical: {
  48 + type: Boolean,
  49 + default: false
46 } 50 }
47 }, 51 },
48 data () { 52 data () {
@@ -68,7 +72,10 @@ @@ -68,7 +72,10 @@
68 return type; 72 return type;
69 }, 73 },
70 bgStyle () { 74 bgStyle () {
71 - return { 75 + return this.vertical ? {
  76 + height: `${this.percent}%`,
  77 + width: `${this.strokeWidth}px`
  78 + } : {
72 width: `${this.percent}%`, 79 width: `${this.percent}%`,
73 height: `${this.strokeWidth}px` 80 height: `${this.strokeWidth}px`
74 }; 81 };
@@ -78,7 +85,8 @@ @@ -78,7 +85,8 @@
78 `${prefixCls}`, 85 `${prefixCls}`,
79 `${prefixCls}-${this.currentStatus}`, 86 `${prefixCls}-${this.currentStatus}`,
80 { 87 {
81 - [`${prefixCls}-show-info`]: !this.hideInfo 88 + [`${prefixCls}-show-info`]: !this.hideInfo,
  89 + [`${prefixCls}-vertical`]: this.vertical
82 90
83 } 91 }
84 ]; 92 ];
src/styles/components/progress.less
@@ -2,7 +2,13 @@ @@ -2,7 +2,13 @@
2 2
3 .@{progress-prefix-cls} { 3 .@{progress-prefix-cls} {
4 display: inline-block; 4 display: inline-block;
  5 +
5 width: 100%; 6 width: 100%;
  7 + &-vertical {
  8 + height: 100%;
  9 + width: auto;
  10 + }
  11 +
6 font-size: @font-size-small; 12 font-size: @font-size-small;
7 position: relative; 13 position: relative;
8 14
@@ -17,6 +23,10 @@ @@ -17,6 +23,10 @@
17 margin-right: -55px; 23 margin-right: -55px;
18 } 24 }
19 } 25 }
  26 + &-vertical &-outer {
  27 + height: 100%;
  28 + width: auto;
  29 + }
20 30
21 &-inner { 31 &-inner {
22 display: inline-block; 32 display: inline-block;
@@ -25,6 +35,20 @@ @@ -25,6 +35,20 @@
25 border-radius: 100px; 35 border-radius: 100px;
26 vertical-align: middle; 36 vertical-align: middle;
27 } 37 }
  38 + &-vertical &-inner {
  39 + height: 100%;
  40 + width: auto;
  41 +
  42 + & > *, &:after {
  43 + display: inline-block;
  44 + vertical-align: bottom;
  45 + }
  46 +
  47 + &:after {
  48 + content: '';
  49 + height: 100%;
  50 + }
  51 + }
28 52
29 &-bg { 53 &-bg {
30 border-radius: 100px; 54 border-radius: 100px;