You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

136 lines
3.5 KiB

10 years ago
'use strict';
var Progressline = require('rc-progress').Line;
var Progresscircle = require('rc-progress').Circle;
var React = require('react');
var Line = React.createClass({
getDefaultProps: function () {
10 years ago
return {
10 years ago
width: 300,
10 years ago
percent: 0,
10 years ago
strokeWidth: 3,
status: 'normal' // exception
10 years ago
};
10 years ago
},
render() {
var statusColorMap = {
'normal': '#3FC7FA',
'exception': '#FE8C6A',
'success': '#85D262'
};
if (parseInt(this.props.percent) === 100) {
10 years ago
this.props.status = 'success';
}
10 years ago
var style = {
'width': this.props.width
10 years ago
};
10 years ago
var fontSize = (this.props.width / 100 * this.props.strokeWidth);
var iconStyle = {
'font-size': (fontSize < 14) ? 14 : fontSize
10 years ago
};
var textStyle = {
'color': statusColorMap[this.props.status]
10 years ago
};
var progressInfo;
if (this.props.status === 'exception') {
10 years ago
progressInfo = (
<span style={textStyle} className='ant-progress-line-text'>
10 years ago
<i style={iconStyle} className='anticon anticon-exclamation-round'></i>
</span>
10 years ago
);
10 years ago
} else if(this.props.status === 'success'){
progressInfo = (
<span style={textStyle} className='ant-progress-line-text'>
10 years ago
<i style={iconStyle} className='anticon anticon-check-round'></i>
</span>
10 years ago
);
10 years ago
}else {
progressInfo = (
<span className='ant-progress-line-text'>{this.props.percent}%</span>
10 years ago
);
10 years ago
}
return (
10 years ago
<div className='ant-progress-line-wrap' >
<div className='ant-progress-line-inner' style={style}>
<Progressline percent={this.props.percent} strokeWidth={this.props.strokeWidth}
10 years ago
strokeColor={statusColorMap[this.props.status]} trailColor="#e9e9e9" />
</div>
10 years ago
{progressInfo}
</div>
);
}
});
var Circle = React.createClass({
getDefaultProps: function () {
10 years ago
return {
10 years ago
width: 150,
10 years ago
percent: 0,
10 years ago
strokeWidth: 4,
status: 'normal' // exception
10 years ago
};
10 years ago
},
render() {
var statusColorMap = {
'normal': '#3FC7FA',
'exception': '#FE8C6A',
'success': '#85D262'
};
if (parseInt(this.props.percent) === 100) {
10 years ago
this.props.status = 'success';
}
10 years ago
var style = {
'width': this.props.width,
'height': this.props.width
10 years ago
};
var wrapStyle = {
10 years ago
'font-size': this.props.width * 0.2
10 years ago
};
var textStyle = {
'color': statusColorMap[this.props.status]
10 years ago
};
var progressInfo;
if (this.props.status === 'exception') {
10 years ago
progressInfo = (
<span style={textStyle} className='ant-progress-circle-text'>
<i className='anticon anticon-exclamation'></i>
</span>
10 years ago
);
10 years ago
}else if(this.props.status === 'suucess'){
progressInfo = (
<span style={textStyle} className='ant-progress-circle-text'>
<i className="anticon anticon-check"></i>
</span>
);
}else {
10 years ago
progressInfo = (
<span className="ant-progress-circle-text">{this.props.percent}%</span>
10 years ago
);
10 years ago
}
return (
<div className="ant-progress-circle-wrap" style={wrapStyle}>
<div className="ant-progress-circle-inner" style={style}>
<Progresscircle percent={this.props.percent} strokeWidth={this.props.strokeWidth}
10 years ago
strokeColor={statusColorMap[this.props.status]} trailColor="#e9e9e9" />
{progressInfo}
</div>
10 years ago
</div>
);
}
});
module.exports = {
Line: Line,
Circle: Circle
};