|
@ -3,6 +3,7 @@ |
|
|
var Progressline = require('rc-progress').Line; |
|
|
var Progressline = require('rc-progress').Line; |
|
|
var Progresscircle = require('rc-progress').Circle; |
|
|
var Progresscircle = require('rc-progress').Circle; |
|
|
var React = require('react'); |
|
|
var React = require('react'); |
|
|
|
|
|
var assign = require('object-assign'); |
|
|
|
|
|
|
|
|
var Line = React.createClass({ |
|
|
var Line = React.createClass({ |
|
|
getDefaultProps() { |
|
|
getDefaultProps() { |
|
@ -20,28 +21,30 @@ var Line = React.createClass({ |
|
|
'success': '#85D262' |
|
|
'success': '#85D262' |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
if (parseInt(this.props.percent) === 100) { |
|
|
var props = assign({}, this.props); |
|
|
this.props.status = 'success'; |
|
|
|
|
|
|
|
|
if (parseInt(props.percent) === 100) { |
|
|
|
|
|
props.status = 'success'; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var style = { |
|
|
var style = { |
|
|
'width': this.props.width |
|
|
'width': props.width |
|
|
}; |
|
|
}; |
|
|
var fontSize = (this.props.width / 100 * this.props.strokeWidth); |
|
|
var fontSize = (props.width / 100 * props.strokeWidth); |
|
|
var iconStyle = { |
|
|
var iconStyle = { |
|
|
'font-size': (fontSize < 14) ? 14 : fontSize |
|
|
'fontSize': (fontSize < 14) ? 14 : fontSize |
|
|
}; |
|
|
}; |
|
|
var textStyle = { |
|
|
var textStyle = { |
|
|
'color': statusColorMap[this.props.status] |
|
|
'color': statusColorMap[props.status] |
|
|
}; |
|
|
}; |
|
|
var progressInfo; |
|
|
var progressInfo; |
|
|
if (this.props.status === 'exception') { |
|
|
if (props.status === 'exception') { |
|
|
progressInfo = ( |
|
|
progressInfo = ( |
|
|
<span style={textStyle} className='ant-progress-line-text'> |
|
|
<span style={textStyle} className='ant-progress-line-text'> |
|
|
<i style={iconStyle} className="anticon anticon-exclamation-circle"></i> |
|
|
<i style={iconStyle} className="anticon anticon-exclamation-circle"></i> |
|
|
</span> |
|
|
</span> |
|
|
); |
|
|
); |
|
|
} else if (this.props.status === 'success') { |
|
|
} else if (props.status === 'success') { |
|
|
progressInfo = ( |
|
|
progressInfo = ( |
|
|
<span style={textStyle} className='ant-progress-line-text'> |
|
|
<span style={textStyle} className='ant-progress-line-text'> |
|
|
<i style={iconStyle} className="anticon anticon-check-circle"></i> |
|
|
<i style={iconStyle} className="anticon anticon-check-circle"></i> |
|
@ -49,15 +52,15 @@ var Line = React.createClass({ |
|
|
); |
|
|
); |
|
|
} else { |
|
|
} else { |
|
|
progressInfo = ( |
|
|
progressInfo = ( |
|
|
<span className='ant-progress-line-text'>{this.props.percent}%</span> |
|
|
<span className='ant-progress-line-text'>{props.percent}%</span> |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return ( |
|
|
return ( |
|
|
<div className='ant-progress-line-wrap'> |
|
|
<div className='ant-progress-line-wrap'> |
|
|
<div className='ant-progress-line-inner' style={style}> |
|
|
<div className='ant-progress-line-inner' style={style}> |
|
|
<Progressline percent={this.props.percent} strokeWidth={this.props.strokeWidth} |
|
|
<Progressline percent={props.percent} strokeWidth={props.strokeWidth} |
|
|
strokeColor={statusColorMap[this.props.status]} trailColor="#e9e9e9" /> |
|
|
strokeColor={statusColorMap[props.status]} trailColor="#e9e9e9" /> |
|
|
</div> |
|
|
</div> |
|
|
{progressInfo} |
|
|
{progressInfo} |
|
|
</div> |
|
|
</div> |
|
@ -81,28 +84,30 @@ var Circle = React.createClass({ |
|
|
'success': '#85D262' |
|
|
'success': '#85D262' |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
if (parseInt(this.props.percent) === 100) { |
|
|
var props = assign({}, this.props); |
|
|
this.props.status = 'success'; |
|
|
|
|
|
|
|
|
if (parseInt(props.percent) === 100) { |
|
|
|
|
|
props.status = 'success'; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var style = { |
|
|
var style = { |
|
|
'width': this.props.width, |
|
|
'width': props.width, |
|
|
'height': this.props.width |
|
|
'height': props.width |
|
|
}; |
|
|
}; |
|
|
var wrapStyle = { |
|
|
var wrapStyle = { |
|
|
'font-size': this.props.width * 0.16 + 6 |
|
|
'fontSize': props.width * 0.16 + 6 |
|
|
}; |
|
|
}; |
|
|
var textStyle = { |
|
|
var textStyle = { |
|
|
'color': statusColorMap[this.props.status] |
|
|
'color': statusColorMap[props.status] |
|
|
}; |
|
|
}; |
|
|
var progressInfo; |
|
|
var progressInfo; |
|
|
if (this.props.status === 'exception') { |
|
|
if (props.status === 'exception') { |
|
|
progressInfo = ( |
|
|
progressInfo = ( |
|
|
<span style={textStyle} className='ant-progress-circle-text'> |
|
|
<span style={textStyle} className='ant-progress-circle-text'> |
|
|
<i className='anticon anticon-exclamation'></i> |
|
|
<i className='anticon anticon-exclamation'></i> |
|
|
</span> |
|
|
</span> |
|
|
); |
|
|
); |
|
|
} else if (this.props.status === 'success') { |
|
|
} else if (props.status === 'success') { |
|
|
progressInfo = ( |
|
|
progressInfo = ( |
|
|
<span style={textStyle} className='ant-progress-circle-text'> |
|
|
<span style={textStyle} className='ant-progress-circle-text'> |
|
|
<i className="anticon anticon-check"></i> |
|
|
<i className="anticon anticon-check"></i> |
|
@ -110,15 +115,15 @@ var Circle = React.createClass({ |
|
|
); |
|
|
); |
|
|
} else { |
|
|
} else { |
|
|
progressInfo = ( |
|
|
progressInfo = ( |
|
|
<span className="ant-progress-circle-text">{this.props.percent}%</span> |
|
|
<span className="ant-progress-circle-text">{props.percent}%</span> |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return ( |
|
|
return ( |
|
|
<div className="ant-progress-circle-wrap" style={wrapStyle}> |
|
|
<div className="ant-progress-circle-wrap" style={wrapStyle}> |
|
|
<div className="ant-progress-circle-inner" style={style}> |
|
|
<div className="ant-progress-circle-inner" style={style}> |
|
|
<Progresscircle percent={this.props.percent} strokeWidth={this.props.strokeWidth} |
|
|
<Progresscircle percent={props.percent} strokeWidth={props.strokeWidth} |
|
|
strokeColor={statusColorMap[this.props.status]} trailColor="#e9e9e9" /> |
|
|
strokeColor={statusColorMap[props.status]} trailColor="#e9e9e9" /> |
|
|
{progressInfo} |
|
|
{progressInfo} |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|