Skip to content

Commit e411d42

Browse files
committed
fix: update progress api and test
1 parent 798aadc commit e411d42

File tree

6 files changed

+66
-21
lines changed

6 files changed

+66
-21
lines changed

components/progress/__tests__/index.test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ describe('Progress', () => {
1919
await asyncExpect(() => {
2020
expect(wrapper.findAll('.ant-progress-status-success')).toHaveLength(1);
2121
});
22+
23+
wrapper.setProps({ percent: 100, successPercent: 0 });
24+
await asyncExpect(() => {
25+
expect(wrapper.findAll('.ant-progress-status-success')).toHaveLength(0);
26+
});
2227
});
2328

2429
it('render out-of-range progress', async () => {

components/progress/circle.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ const Circle = {
3838
} = props;
3939
const circleSize = width || 120;
4040
const circleStyle = {
41-
width: circleSize,
42-
height: circleSize,
41+
width: typeof circleSize === 'number' ? `${circleSize}px` : circleSize,
42+
height: typeof circleSize === 'number' ? `${circleSize}px` : circleSize,
4343
fontSize: circleSize * 0.15 + 6,
4444
};
4545
const circleWidth = strokeWidth || 6;

components/progress/index.en-US.md

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,37 @@
11
## API
22

3+
Properties that shared by all types.
4+
35
| Property | Description | Type | Default |
46
| -------- | ----------- | ---- | ------- |
7+
| type | to set the type, options: `line` `circle` `dashboard` | string | `line` |
58
| format | template function of the content | function(percent, successPercent) | `percent => percent + '%'` |
6-
| gapDegree `(type=circle)` | the gap degree of half circle, 0 ~ 360 | number | 0 |
7-
| gapPosition `(type=circle)` | the gap position, options: `top` `bottom` `left` `right` | string | `top` |
89
| percent | to set the completion percentage | number | 0 |
910
| showInfo | whether to display the progress value and the status icon | boolean | true |
10-
| status | to set the status of the Progress, options: `normal` `success` `exception` `active` | string | `normal` |
11-
| strokeWidth `(type=line)` | to set the width of the progress bar, unit: `px` | number | 10 |
12-
| strokeWidth `(type=circle)` | to set the width of the circular progress bar, unit: percentage of the canvas width | number | 6 |
11+
| status | to set the status of the Progress, options: `success` `exception` `active` `normal` | string | - |
1312
| strokeLinecap | to set the style of the progress linecap | Enum{ 'round', 'square' } | `round` |
1413
| strokeColor | color of progress bar | string | - |
15-
| successPercent | segmented success percent, works when `type="line"` | number | 0 |
16-
| type | to set the type, options: `line` `circle` `dashboard` | string | `line` |
17-
| width `(type=circle)` | to set the canvas width of the circular progress bar, unit: `px` | number | 120 |
14+
| successPercent | segmented success percent | number | 0 |
15+
16+
### `type="line"`
17+
18+
| Property | Description | Type | Default |
19+
| -------- | ----------- | ---- | ------- |
20+
| strokeWidth | to set the width of the progress bar, unit: `px` | number | 10 |
21+
22+
### `type="circle"`
23+
24+
| Property | Description | Type | Default |
25+
| -------- | ----------- | ---- | ------- |
26+
| width | to set the canvas width of the circular progress, unit: `px` | number | 132 |
27+
| strokeWidth | to set the width of the circular progress, unit: percentage of the canvas width | number | 6 |
28+
29+
### `type="dashboard"`
30+
31+
| Property | Description | Type | Default |
32+
| -------- | ----------- | ---- | ------- |
33+
| width | to set the canvas width of the dashboard progress, unit: `px` | number | 132 |
34+
| strokeWidth | to set the width of the dashboard progress, unit: percentage of the canvas width | number | 6 |
35+
| gapDegree | the gap degree of half circle, 0 ~ 360 | number | 0 |
36+
| gapPosition | the gap position, options: `top` `bottom` `left` `right` | string | `top` |
37+

components/progress/index.zh-CN.md

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,37 @@
11
## API
22

3+
各类型共用的属性。
4+
35
| 属性 | 说明 | 类型 | 默认值 |
46
| --- | --- | --- | --- |
7+
| type | 类型,可选 `line` `circle` `dashboard` | string | `line` |
58
| format | 内容的模板函数 | function(percent, successPercent) | `percent => percent + '%'` |
6-
| gapDegree `(type=circle)` | 圆形进度条缺口角度,可取值 0 ~ 360 | number | 0 |
7-
| gapPosition `(type=circle)` | 圆形进度条缺口位置 | Enum{ 'top', 'bottom', 'left', 'right' } | `top` |
89
| percent | 百分比 | number | 0 |
910
| showInfo | 是否显示进度数值或状态图标 | boolean | true |
10-
| status | 状态,可选:`normal` `success` `exception` `active` | string | `normal` |
11-
| strokeWidth `(type=line)` | 进度条线的宽度,单位 px | number | 10 |
12-
| strokeWidth `(type=circle)` | 圆形进度条线的宽度,单位是进度条画布宽度的百分比 | number | 6 |
11+
| status | 状态,可选:`success` `exception` `active` `normal` | string | - |
1312
| strokeLinecap | | Enum{ 'round', 'square' } | `round` |
1413
| strokeColor | 进度条的色彩 | string | - |
15-
| successPercent | 已完成的分段百分比,`type="line"` 时有效 | number | 0 |
16-
| type | 类型,可选 `line` `circle` `dashboard` | string | line |
17-
| width `(type=circle)` | 圆形进度条画布宽度,单位 px | number | 120 |
14+
| successPercent | 已完成的分段百分比 | number | 0 |
15+
16+
### `type="line"`
17+
18+
| 属性 | 说明 | 类型 | 默认值 |
19+
| --- | --- | --- | --- |
20+
| strokeWidth | 进度条线的宽度,单位 px | number | 10 |
21+
22+
### `type="circle"`
23+
24+
| 属性 | 说明 | 类型 | 默认值 |
25+
| --- | --- | --- | --- |
26+
| width | 圆形进度条画布宽度,单位 px | number | 132 |
27+
| strokeWidth | 圆形进度条线的宽度,单位是进度条画布宽度的百分比 | number | 6 |
28+
29+
### `type="dashboard"`
30+
31+
| 属性 | 说明 | 类型 | 默认值 |
32+
| --- | --- | --- | --- |
33+
| width | 仪表盘进度条画布宽度,单位 px | number | 132 |
34+
| strokeWidth | 仪表盘进度条线的宽度,单位是进度条画布宽度的百分比 | number | 6 |
35+
| gapDegree | 仪表盘进度条缺口角度,可取值 0 ~ 360 | number | 0 |
36+
| gapPosition | 仪表盘进度条缺口位置 | Enum{ 'top', 'bottom', 'left', 'right' } | `top` |
37+

components/progress/line.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ const Line = {
1616
} = props;
1717
const percentStyle = {
1818
width: `${validProgress(percent)}%`,
19-
height: strokeWidth || (size === 'small' ? 6 : 8),
19+
height: strokeWidth || (size === 'small' ? '6px' : '8px'),
2020
background: strokeColor,
2121
borderRadius: strokeLinecap === 'square' ? 0 : '100px',
2222
};
2323
const successPercentStyle = {
2424
width: `${validProgress(successPercent)}%`,
25-
height: strokeWidth || (size === 'small' ? 6 : 8),
25+
height: strokeWidth || (size === 'small' ? '6px' : '8px'),
2626
borderRadius: strokeLinecap === 'square' ? 0 : '100px',
2727
};
2828
const successSegment =

components/vc-progress/src/Circle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { propTypes, defaultProps } from './types';
88
const circlePropTypes = {
99
...propTypes,
1010
gapPosition: PropTypes.oneOf(['top', 'bottom', 'left', 'right']),
11-
gapDegree: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
11+
gapDegree: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.bool]),
1212
};
1313

1414
const circleDefaultProps = {

0 commit comments

Comments
 (0)