fix: update progress api and test
parent
798aadcc91
commit
e411d42d47
|
@ -19,6 +19,11 @@ describe('Progress', () => {
|
||||||
await asyncExpect(() => {
|
await asyncExpect(() => {
|
||||||
expect(wrapper.findAll('.ant-progress-status-success')).toHaveLength(1);
|
expect(wrapper.findAll('.ant-progress-status-success')).toHaveLength(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
wrapper.setProps({ percent: 100, successPercent: 0 });
|
||||||
|
await asyncExpect(() => {
|
||||||
|
expect(wrapper.findAll('.ant-progress-status-success')).toHaveLength(0);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('render out-of-range progress', async () => {
|
it('render out-of-range progress', async () => {
|
||||||
|
|
|
@ -38,8 +38,8 @@ const Circle = {
|
||||||
} = props;
|
} = props;
|
||||||
const circleSize = width || 120;
|
const circleSize = width || 120;
|
||||||
const circleStyle = {
|
const circleStyle = {
|
||||||
width: circleSize,
|
width: typeof circleSize === 'number' ? `${circleSize}px` : circleSize,
|
||||||
height: circleSize,
|
height: typeof circleSize === 'number' ? `${circleSize}px` : circleSize,
|
||||||
fontSize: circleSize * 0.15 + 6,
|
fontSize: circleSize * 0.15 + 6,
|
||||||
};
|
};
|
||||||
const circleWidth = strokeWidth || 6;
|
const circleWidth = strokeWidth || 6;
|
||||||
|
|
|
@ -1,17 +1,37 @@
|
||||||
## API
|
## API
|
||||||
|
|
||||||
|
Properties that shared by all types.
|
||||||
|
|
||||||
| Property | Description | Type | Default |
|
| Property | Description | Type | Default |
|
||||||
| -------- | ----------- | ---- | ------- |
|
| -------- | ----------- | ---- | ------- |
|
||||||
|
| type | to set the type, options: `line` `circle` `dashboard` | string | `line` |
|
||||||
| format | template function of the content | function(percent, successPercent) | `percent => percent + '%'` |
|
| format | template function of the content | function(percent, successPercent) | `percent => percent + '%'` |
|
||||||
| gapDegree `(type=circle)` | the gap degree of half circle, 0 ~ 360 | number | 0 |
|
|
||||||
| gapPosition `(type=circle)` | the gap position, options: `top` `bottom` `left` `right` | string | `top` |
|
|
||||||
| percent | to set the completion percentage | number | 0 |
|
| percent | to set the completion percentage | number | 0 |
|
||||||
| showInfo | whether to display the progress value and the status icon | boolean | true |
|
| showInfo | whether to display the progress value and the status icon | boolean | true |
|
||||||
| status | to set the status of the Progress, options: `normal` `success` `exception` `active` | string | `normal` |
|
| status | to set the status of the Progress, options: `success` `exception` `active` `normal` | string | - |
|
||||||
| strokeWidth `(type=line)` | to set the width of the progress bar, unit: `px` | number | 10 |
|
|
||||||
| strokeWidth `(type=circle)` | to set the width of the circular progress bar, unit: percentage of the canvas width | number | 6 |
|
|
||||||
| strokeLinecap | to set the style of the progress linecap | Enum{ 'round', 'square' } | `round` |
|
| strokeLinecap | to set the style of the progress linecap | Enum{ 'round', 'square' } | `round` |
|
||||||
| strokeColor | color of progress bar | string | - |
|
| strokeColor | color of progress bar | string | - |
|
||||||
| successPercent | segmented success percent, works when `type="line"` | number | 0 |
|
| successPercent | segmented success percent | number | 0 |
|
||||||
| type | to set the type, options: `line` `circle` `dashboard` | string | `line` |
|
|
||||||
| width `(type=circle)` | to set the canvas width of the circular progress bar, unit: `px` | number | 120 |
|
### `type="line"`
|
||||||
|
|
||||||
|
| Property | Description | Type | Default |
|
||||||
|
| -------- | ----------- | ---- | ------- |
|
||||||
|
| strokeWidth | to set the width of the progress bar, unit: `px` | number | 10 |
|
||||||
|
|
||||||
|
### `type="circle"`
|
||||||
|
|
||||||
|
| Property | Description | Type | Default |
|
||||||
|
| -------- | ----------- | ---- | ------- |
|
||||||
|
| width | to set the canvas width of the circular progress, unit: `px` | number | 132 |
|
||||||
|
| strokeWidth | to set the width of the circular progress, unit: percentage of the canvas width | number | 6 |
|
||||||
|
|
||||||
|
### `type="dashboard"`
|
||||||
|
|
||||||
|
| Property | Description | Type | Default |
|
||||||
|
| -------- | ----------- | ---- | ------- |
|
||||||
|
| width | to set the canvas width of the dashboard progress, unit: `px` | number | 132 |
|
||||||
|
| strokeWidth | to set the width of the dashboard progress, unit: percentage of the canvas width | number | 6 |
|
||||||
|
| gapDegree | the gap degree of half circle, 0 ~ 360 | number | 0 |
|
||||||
|
| gapPosition | the gap position, options: `top` `bottom` `left` `right` | string | `top` |
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,37 @@
|
||||||
## API
|
## API
|
||||||
|
|
||||||
|
各类型共用的属性。
|
||||||
|
|
||||||
| 属性 | 说明 | 类型 | 默认值 |
|
| 属性 | 说明 | 类型 | 默认值 |
|
||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- |
|
||||||
|
| type | 类型,可选 `line` `circle` `dashboard` | string | `line` |
|
||||||
| format | 内容的模板函数 | function(percent, successPercent) | `percent => percent + '%'` |
|
| format | 内容的模板函数 | function(percent, successPercent) | `percent => percent + '%'` |
|
||||||
| gapDegree `(type=circle)` | 圆形进度条缺口角度,可取值 0 ~ 360 | number | 0 |
|
|
||||||
| gapPosition `(type=circle)` | 圆形进度条缺口位置 | Enum{ 'top', 'bottom', 'left', 'right' } | `top` |
|
|
||||||
| percent | 百分比 | number | 0 |
|
| percent | 百分比 | number | 0 |
|
||||||
| showInfo | 是否显示进度数值或状态图标 | boolean | true |
|
| showInfo | 是否显示进度数值或状态图标 | boolean | true |
|
||||||
| status | 状态,可选:`normal` `success` `exception` `active` | string | `normal` |
|
| status | 状态,可选:`success` `exception` `active` `normal` | string | - |
|
||||||
| strokeWidth `(type=line)` | 进度条线的宽度,单位 px | number | 10 |
|
|
||||||
| strokeWidth `(type=circle)` | 圆形进度条线的宽度,单位是进度条画布宽度的百分比 | number | 6 |
|
|
||||||
| strokeLinecap | | Enum{ 'round', 'square' } | `round` |
|
| strokeLinecap | | Enum{ 'round', 'square' } | `round` |
|
||||||
| strokeColor | 进度条的色彩 | string | - |
|
| strokeColor | 进度条的色彩 | string | - |
|
||||||
| successPercent | 已完成的分段百分比,`type="line"` 时有效 | number | 0 |
|
| successPercent | 已完成的分段百分比 | number | 0 |
|
||||||
| type | 类型,可选 `line` `circle` `dashboard` | string | line |
|
|
||||||
| width `(type=circle)` | 圆形进度条画布宽度,单位 px | number | 120 |
|
### `type="line"`
|
||||||
|
|
||||||
|
| 属性 | 说明 | 类型 | 默认值 |
|
||||||
|
| --- | --- | --- | --- |
|
||||||
|
| strokeWidth | 进度条线的宽度,单位 px | number | 10 |
|
||||||
|
|
||||||
|
### `type="circle"`
|
||||||
|
|
||||||
|
| 属性 | 说明 | 类型 | 默认值 |
|
||||||
|
| --- | --- | --- | --- |
|
||||||
|
| width | 圆形进度条画布宽度,单位 px | number | 132 |
|
||||||
|
| strokeWidth | 圆形进度条线的宽度,单位是进度条画布宽度的百分比 | number | 6 |
|
||||||
|
|
||||||
|
### `type="dashboard"`
|
||||||
|
|
||||||
|
| 属性 | 说明 | 类型 | 默认值 |
|
||||||
|
| --- | --- | --- | --- |
|
||||||
|
| width | 仪表盘进度条画布宽度,单位 px | number | 132 |
|
||||||
|
| strokeWidth | 仪表盘进度条线的宽度,单位是进度条画布宽度的百分比 | number | 6 |
|
||||||
|
| gapDegree | 仪表盘进度条缺口角度,可取值 0 ~ 360 | number | 0 |
|
||||||
|
| gapPosition | 仪表盘进度条缺口位置 | Enum{ 'top', 'bottom', 'left', 'right' } | `top` |
|
||||||
|
|
||||||
|
|
|
@ -16,13 +16,13 @@ const Line = {
|
||||||
} = props;
|
} = props;
|
||||||
const percentStyle = {
|
const percentStyle = {
|
||||||
width: `${validProgress(percent)}%`,
|
width: `${validProgress(percent)}%`,
|
||||||
height: strokeWidth || (size === 'small' ? 6 : 8),
|
height: strokeWidth || (size === 'small' ? '6px' : '8px'),
|
||||||
background: strokeColor,
|
background: strokeColor,
|
||||||
borderRadius: strokeLinecap === 'square' ? 0 : '100px',
|
borderRadius: strokeLinecap === 'square' ? 0 : '100px',
|
||||||
};
|
};
|
||||||
const successPercentStyle = {
|
const successPercentStyle = {
|
||||||
width: `${validProgress(successPercent)}%`,
|
width: `${validProgress(successPercent)}%`,
|
||||||
height: strokeWidth || (size === 'small' ? 6 : 8),
|
height: strokeWidth || (size === 'small' ? '6px' : '8px'),
|
||||||
borderRadius: strokeLinecap === 'square' ? 0 : '100px',
|
borderRadius: strokeLinecap === 'square' ? 0 : '100px',
|
||||||
};
|
};
|
||||||
const successSegment =
|
const successSegment =
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { propTypes, defaultProps } from './types';
|
||||||
const circlePropTypes = {
|
const circlePropTypes = {
|
||||||
...propTypes,
|
...propTypes,
|
||||||
gapPosition: PropTypes.oneOf(['top', 'bottom', 'left', 'right']),
|
gapPosition: PropTypes.oneOf(['top', 'bottom', 'left', 'right']),
|
||||||
gapDegree: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
gapDegree: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.bool]),
|
||||||
};
|
};
|
||||||
|
|
||||||
const circleDefaultProps = {
|
const circleDefaultProps = {
|
||||||
|
|
Loading…
Reference in New Issue