mini demo

This commit is contained in:
夏奈 2015-06-15 11:48:30 +08:00
parent dda240d09b
commit 2c58d5e1ce
6 changed files with 70 additions and 24 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" strokeWidth="4" />
<Circle percent="70" width="100" strokeWidth="4" status="exception" />
<Circle percent="100" width="100" strokeWidth="4" />
</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" strokeWidth="4" />
<Circle percent="70" width="100" strokeWidth="4" status="exception" /> <Circle percent="70" width="150" strokeWidth="4" status="exception" />
<Circle percent="100" width="100" strokeWidth="4" /> <Circle percent="100" width="150" strokeWidth="4" />
</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

@ -10,7 +10,7 @@ var Line = React.createClass({
percent: 0, percent: 0,
strokeWidth: 2, strokeWidth: 2,
status: 'normal' // exception status: 'normal' // exception
} };
}, },
render() { render() {
var statusColorMap = { var statusColorMap = {
@ -20,35 +20,35 @@ 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 (
@ -69,7 +69,7 @@ var Circle = React.createClass({
percent: 0, percent: 0,
strokeWidth: 2, strokeWidth: 2,
status: 'normal' // exception status: 'normal' // exception
} };
}, },
render() { render() {
var statusColorMap = { var statusColorMap = {
@ -79,30 +79,30 @@ 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 (

View File

@ -16,7 +16,7 @@
| 参数 | 说明 | 类型 | 默认值 | | 参数 | 说明 | 类型 | 默认值 |
|----------|----------------|----------|--------------| |----------|----------------|----------|--------------|
| 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 |