mirror of
https://github.com/ant-design/ant-design.git
synced 2025-08-06 16:06:28 +08:00
Remove deperated progress form usage
This commit is contained in:
parent
95c3a3daf9
commit
1df8bccf26
@ -1,6 +1,5 @@
|
|||||||
import { Circle as Progresscircle } from 'rc-progress';
|
import { Circle as Progresscircle } from 'rc-progress';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import warning from 'warning';
|
|
||||||
import Icon from '../icon';
|
import Icon from '../icon';
|
||||||
|
|
||||||
const prefixCls = 'ant-progress';
|
const prefixCls = 'ant-progress';
|
||||||
@ -18,11 +17,7 @@ let Line = React.createClass({
|
|||||||
percent: React.PropTypes.number,
|
percent: React.PropTypes.number,
|
||||||
strokeWidth: React.PropTypes.number,
|
strokeWidth: React.PropTypes.number,
|
||||||
trailColor: React.PropTypes.string,
|
trailColor: React.PropTypes.string,
|
||||||
format: React.PropTypes.oneOfType([
|
format: React.PropTypes.func,
|
||||||
React.PropTypes.node,
|
|
||||||
React.PropTypes.string,
|
|
||||||
React.PropTypes.func,
|
|
||||||
]),
|
|
||||||
},
|
},
|
||||||
getDefaultProps() {
|
getDefaultProps() {
|
||||||
return {
|
return {
|
||||||
@ -43,35 +38,24 @@ let Line = React.createClass({
|
|||||||
let progressInfo;
|
let progressInfo;
|
||||||
let fullCls = '';
|
let fullCls = '';
|
||||||
|
|
||||||
if (props.format) {
|
const format = props.format || (percent => `${percent}%`);
|
||||||
warning(typeof props.format === 'function',
|
|
||||||
'antd.Progress props.format type is function, change format={xxx} to format={() => xxx}');
|
|
||||||
}
|
|
||||||
|
|
||||||
let text = props.format || `${props.percent}%`;
|
|
||||||
if (typeof props.format === 'string') {
|
|
||||||
// 向下兼容原来的字符串替换方式
|
|
||||||
text = props.format.replace('${percent}', props.percent);
|
|
||||||
} else if (typeof props.format === 'function') {
|
|
||||||
text = props.format(props.percent);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (props.showInfo) {
|
if (props.showInfo) {
|
||||||
if (props.status === 'exception') {
|
if (props.status === 'exception') {
|
||||||
progressInfo = (
|
progressInfo = (
|
||||||
<span className={`${prefixCls}-line-text`}>
|
<span className={`${prefixCls}-line-text`}>
|
||||||
{props.format ? text : <Icon type="cross-circle" />}
|
{props.format ? format(props.percent) : <Icon type="cross-circle" />}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
} else if (props.status === 'success') {
|
} else if (props.status === 'success') {
|
||||||
progressInfo = (
|
progressInfo = (
|
||||||
<span className={`${prefixCls}-line-text`}>
|
<span className={`${prefixCls}-line-text`}>
|
||||||
{props.format ? text : <Icon type="check-circle" />}
|
{props.format ? format(props.percent) : <Icon type="check-circle" />}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
progressInfo = (
|
progressInfo = (
|
||||||
<span className={`${prefixCls}-line-text`}>{text}</span>
|
<span className={`${prefixCls}-line-text`}>{format(props.percent)}</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -102,11 +86,7 @@ let Circle = React.createClass({
|
|||||||
strokeWidth: React.PropTypes.number,
|
strokeWidth: React.PropTypes.number,
|
||||||
width: React.PropTypes.number,
|
width: React.PropTypes.number,
|
||||||
trailColor: React.PropTypes.string,
|
trailColor: React.PropTypes.string,
|
||||||
format: React.PropTypes.oneOfType([
|
format: React.PropTypes.func,
|
||||||
React.PropTypes.node,
|
|
||||||
React.PropTypes.string,
|
|
||||||
React.PropTypes.func,
|
|
||||||
]),
|
|
||||||
},
|
},
|
||||||
getDefaultProps() {
|
getDefaultProps() {
|
||||||
return {
|
return {
|
||||||
@ -130,35 +110,24 @@ let Circle = React.createClass({
|
|||||||
fontSize: props.width * 0.16 + 6
|
fontSize: props.width * 0.16 + 6
|
||||||
};
|
};
|
||||||
let progressInfo;
|
let progressInfo;
|
||||||
let text = props.format || `${props.percent}%`;
|
|
||||||
|
|
||||||
if (props.format) {
|
const format = props.format || (percent => `${percent}%`);
|
||||||
warning(typeof props.format === 'function',
|
|
||||||
'antd.Progress props.format type is function, change format={xxx} to format={() => xxx}');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof props.format === 'string') {
|
|
||||||
// 向下兼容原来的字符串替换方式
|
|
||||||
text = props.format.replace('${percent}', props.percent);
|
|
||||||
} else if (typeof props.format === 'function') {
|
|
||||||
text = props.format(props.percent);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (props.status === 'exception') {
|
if (props.status === 'exception') {
|
||||||
progressInfo = (
|
progressInfo = (
|
||||||
<span className={`${prefixCls}-circle-text`}>
|
<span className={`${prefixCls}-circle-text`}>
|
||||||
{props.format ? text : <Icon type="exclamation" />}
|
{props.format ? format(props.percent) : <Icon type="exclamation" />}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
} else if (props.status === 'success') {
|
} else if (props.status === 'success') {
|
||||||
progressInfo = (
|
progressInfo = (
|
||||||
<span className={`${prefixCls}-circle-text`}>
|
<span className={`${prefixCls}-circle-text`}>
|
||||||
{props.format ? text : <Icon type="check" />}
|
{props.format ? format(props.percent) : <Icon type="check" />}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
progressInfo = (
|
progressInfo = (
|
||||||
<span className={`${prefixCls}-circle-text`}>{text}</span>
|
<span className={`${prefixCls}-circle-text`}>{format(props.percent)}</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user