Merge branch 'master' of github.com:ant-design/ant-design

This commit is contained in:
afc163 2015-06-15 12:11:13 +08:00
commit e1f9c1e11c
6 changed files with 76 additions and 30 deletions

View File

@ -0,0 +1,27 @@
# Circle 用法
- order: 0
Progress Circle用法
---
````jsx
var Circle = antd.Progress.Circle;
React.render(
<div>
<Circle percent="30" width="100" />
<Circle percent="70" width="100" status="exception" />
<Circle percent="100" width="100" />
</div>
, document.getElementById('components-progress-demo-circle-mini'));
````
<style>
.ant-progress-circle-wrap,
.ant-progress-line-wrap {
margin-right: 15px;
margin-bottom: 15px;
}
</style>

View File

@ -11,9 +11,9 @@ var Circle = antd.Progress.Circle;
React.render( React.render(
<div> <div>
<Circle percent="30" width="100" strokeWidth="4" /> <Circle percent="30" width="150" />
<Circle percent="70" width="100" strokeWidth="4" status="exception" /> <Circle percent="70" width="150" status="exception" />
<Circle percent="100" width="100" strokeWidth="4" /> <Circle percent="100" width="150" />
</div> </div>
, document.getElementById('components-progress-demo-circle')); , document.getElementById('components-progress-demo-circle'));
```` ````

View File

@ -0,0 +1,19 @@
# Line 用法
- order: 0
Progress Line用法
---
````jsx
var Line = antd.Progress.Line;
React.render(
<div>
<Line percent="30" width="170" strokeWidth="3" />
<Line percent="70" width="170" strokeWidth="3" status="exception" />
<Line percent="100" width="170" strokeWidth="3" />
</div>
, document.getElementById('components-progress-demo-line-mini'));
````

View File

@ -11,9 +11,9 @@ var Line = antd.Progress.Line;
React.render( React.render(
<div> <div>
<Line percent="30" width="300" strokeWidth="4" /> <Line percent="30" width="300" strokeWidth="3" />
<Line percent="70" width="300" strokeWidth="4" status="exception" /> <Line percent="70" width="300" strokeWidth="3" status="exception" />
<Line percent="100" width="300" strokeWidth="4" /> <Line percent="100" width="300" strokeWidth="3" />
</div> </div>
, document.getElementById('components-progress-demo-line')); , document.getElementById('components-progress-demo-line'));
```` ````

View File

@ -8,9 +8,9 @@ var Line = React.createClass({
getDefaultProps: function () { getDefaultProps: function () {
return { return {
percent: 0, percent: 0,
strokeWidth: 2, strokeWidth: 4,
status: 'normal' // exception status: 'normal' // exception
} };
}, },
render() { render() {
var statusColorMap = { var statusColorMap = {
@ -20,42 +20,42 @@ var Line = React.createClass({
}; };
if (parseInt(this.props.percent) === 100) { if (parseInt(this.props.percent) === 100) {
this.props.status = 'success' this.props.status = 'success';
} }
var style = { var style = {
'width': this.props.width 'width': this.props.width
} };
var wrapStyle = { var wrapStyle = {
'font-size': this.props.width / 100 * this.props.strokeWidth 'font-size': this.props.width / 100 * this.props.strokeWidth
} };
var textStyle = { var textStyle = {
'color': statusColorMap[this.props.status] 'color': statusColorMap[this.props.status]
} };
var progressInfo var progressInfo;
if (this.props.status === 'exception') { if (this.props.status === 'exception') {
progressInfo = ( progressInfo = (
<span style={textStyle} className='ant-progress-line-text'> <span style={textStyle} className='ant-progress-line-text'>
<i className='anticon anticon-exclamation-round'></i> <i className='anticon anticon-exclamation-round'></i>
</span> </span>
) );
} else if(this.props.status === 'success'){ } else if(this.props.status === 'success'){
progressInfo = ( progressInfo = (
<span style={textStyle} className='ant-progress-line-text'> <span style={textStyle} className='ant-progress-line-text'>
<i className='anticon anticon-check-round'></i> <i className='anticon anticon-check-round'></i>
</span> </span>
) );
}else { }else {
progressInfo = ( progressInfo = (
<span className='ant-progress-line-text'>{this.props.percent}%</span> <span className='ant-progress-line-text'>{this.props.percent}%</span>
) );
} }
return ( return (
<div className='ant-progress-line-wrap' style={wrapStyle}> <div className='ant-progress-line-wrap' style={wrapStyle}>
<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={this.props.percent} strokeWidth={this.props.strokeWidth}
strokeColor={statusColorMap[this.props.status]}/> strokeColor={statusColorMap[this.props.status]} trailColor="#e9e9e9" />
</div> </div>
{progressInfo} {progressInfo}
</div> </div>
@ -67,9 +67,9 @@ var Circle = React.createClass({
getDefaultProps: function () { getDefaultProps: function () {
return { return {
percent: 0, percent: 0,
strokeWidth: 2, strokeWidth: 4,
status: 'normal' // exception status: 'normal' // exception
} };
}, },
render() { render() {
var statusColorMap = { var statusColorMap = {
@ -79,37 +79,37 @@ var Circle = React.createClass({
}; };
if (parseInt(this.props.percent) === 100) { if (parseInt(this.props.percent) === 100) {
this.props.status = 'success' this.props.status = 'success';
} }
var style = { var style = {
'width': this.props.width, 'width': this.props.width,
'height': this.props.width 'height': this.props.width
} };
var wrapStyle = { var wrapStyle = {
'font-size': this.props.width * 0.3 'font-size': this.props.width * 0.3
} };
var textStyle = { var textStyle = {
'color': statusColorMap[this.props.status] 'color': statusColorMap[this.props.status]
} };
var progressInfo var progressInfo;
if (this.props.status === 'exception') { if (this.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 { }else {
progressInfo = ( progressInfo = (
<span className="ant-progress-circle-text">{this.props.percent}%</span> <span className="ant-progress-circle-text">{this.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={this.props.percent} strokeWidth={this.props.strokeWidth}
strokeColor={statusColorMap[this.props.status]}/> strokeColor={statusColorMap[this.props.status]} trailColor="#e9e9e9" />
{progressInfo} {progressInfo}
</div> </div>
</div> </div>

View File

@ -8,15 +8,15 @@
## 使用 ## 使用
`<Line perscent="30" />` `<Line percent="30" />`
`<Circle perscent="30" />` `<Circle percent="30" />`
## 属性参数 ## 属性参数
| 参数 | 说明 | 类型 | 默认值 | | 参数 | 说明 | 类型 | 默认值 |
|----------|----------------|----------|--------------| |----------|----------------|----------|--------------|
| perscent | 百分比 | number | 0 | | percent | 百分比 | number | 0 |
| status | 状态有两个值normal、exception | string | normal | | status | 状态有两个值normal、exception | string | normal |
| strokeWidth | 进度条线宽度,单位是进度条画布宽度的百分比 | number | 1 | | strokeWidth | 进度条线宽度,单位是进度条画布宽度的百分比 | number | 1 |
| width | 必填进度条画布宽度单位px。这里没有提供height属性设置Line型高度就是strokeWidthCircle型高度等于width | number | null | | width | 必填进度条画布宽度单位px。这里没有提供height属性设置Line型高度就是strokeWidthCircle型高度等于width | number | null |