diff --git a/components/progress/Circle.jsx b/components/progress/Circle.jsx
index 7e9ad28007..074d0ba142 100644
--- a/components/progress/Circle.jsx
+++ b/components/progress/Circle.jsx
@@ -1,4 +1,4 @@
-import { Circle as Progresscircle } from 'rc-progress';
+import { RcProgressCircle } from 'rc-progress';
import React from 'react';
import Icon from '../icon';
@@ -65,7 +65,7 @@ export default class Circle extends React.Component {
return (
diff --git a/components/progress/Line.jsx b/components/progress/Line.jsx
index 13818d395c..c560516f2a 100644
--- a/components/progress/Line.jsx
+++ b/components/progress/Line.jsx
@@ -1,71 +1,96 @@
-import React from 'react';
+import React, { PropTypes } from 'react';
import Icon from '../icon';
+import { Circle } from 'rc-progress';
+import classNames from 'classnames';
+
+const statusColorMap = {
+ normal: '#2db7f5',
+ exception: '#ff5500',
+ success: '#87d068'
+};
-const prefixCls = 'ant-progress';
export default class Line extends React.Component {
static defaultProps = {
+ type: 'line',
percent: 0,
- strokeWidth: 10,
- status: 'normal', // exception active
showInfo: true,
- trailColor: '#f3f3f3'
+ trailColor: '#f3f3f3',
+ prefixCls: 'ant-progress',
}
static propTypes = {
- status: React.PropTypes.oneOf(['normal', 'exception', 'active', 'success']),
- showInfo: React.PropTypes.bool,
- percent: React.PropTypes.number,
- strokeWidth: React.PropTypes.number,
- trailColor: React.PropTypes.string,
- format: React.PropTypes.func,
+ status: PropTypes.oneOf(['normal', 'exception', 'active', 'success']),
+ showInfo: PropTypes.bool,
+ percent: PropTypes.number,
+ strokeWidth: PropTypes.number,
+ trailColor: PropTypes.string,
+ format: PropTypes.func,
}
render() {
- let props = { ...this.props };
-
- if (parseInt(props.percent, 10) === 100) {
- props.status = 'success';
- }
-
+ const { prefixCls, status, format, percent, trailColor,
+ type, strokeWidth, width, className, showInfo, ...restProps } = this.props;
+ const progressStatus = (parseInt(percent, 10) >= 100 && !('status' in this.props))
+ ? 'success' : (status || 'normal');
let progressInfo;
- let fullCls = '';
-
- const format = props.format || (percent => `${percent}%`);
+ let progress;
+ const textFormatter = format || (percentNumber => `${percentNumber}%`);
- if (props.showInfo) {
- if (props.status === 'exception') {
- progressInfo = (
-
- {props.format ? format(props.percent) : }
-
- );
- } else if (props.status === 'success') {
- progressInfo = (
-
- {props.format ? format(props.percent) : }
-
- );
+ if (showInfo) {
+ let text;
+ const iconType = type === 'circle' ? '' : '-circle';
+ if (progressStatus === 'exception') {
+ text = format ? textFormatter(percent) :
;
+ } else if (progressStatus === 'success') {
+ text = format ? textFormatter(percent) :
;
} else {
- progressInfo = (
-
{format(props.percent)}
- );
+ text = textFormatter(percent);
}
- } else {
- fullCls = ` ${prefixCls}-line-wrap-full`;
+ progressInfo =
{text};
}
- let percentStyle = {
- width: `${props.percent}%`,
- height: props.strokeWidth
- };
- return (
-
-
-
-
+ if (type === 'line') {
+ const percentStyle = {
+ width: `${percent}%`,
+ height: strokeWidth || 10,
+ };
+ progress = (
+
- {progressInfo}
+ );
+ } else if (type === 'circle') {
+ const circleSize = width || 132;
+ const circleStyle = {
+ width: circleSize,
+ height: circleSize,
+ fontSize: circleSize * 0.16 + 6,
+ };
+ progress = (
+
+
+ {progressInfo}
+
+ );
+ }
+
+ const classString = classNames({
+ [`${prefixCls}`]: true,
+ [`${prefixCls}-${type}`]: true,
+ [`${prefixCls}-status-${progressStatus}`]: true,
+ [`${prefixCls}-show-info`]: showInfo,
+ [className]: !!className,
+ });
+
+ return (
+
+ {progress}
);
}
diff --git a/components/progress/demo/circle-dynamic.md b/components/progress/demo/circle-dynamic.md
index 3778a86713..57f8165466 100644
--- a/components/progress/demo/circle-dynamic.md
+++ b/components/progress/demo/circle-dynamic.md
@@ -7,7 +7,6 @@ title: 进度圈动态展示
````jsx
import { Progress, Button, Icon } from 'antd';
-const ProgressCircle = Progress.Circle;
const ButtonGroup = Button.Group;
const MyProgress = React.createClass({
@@ -33,7 +32,7 @@ const MyProgress = React.createClass({
render() {
return (
-
+