Browse Source

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

pull/26/head
afc163 10 years ago
parent
commit
7e35666f98
  1. 38
      components/progress/demo/circle-dynamic.md
  2. 6
      components/progress/demo/circle.md
  3. 2
      components/progress/demo/dynamic.md
  4. 6
      components/progress/demo/line.md
  5. 24
      components/progress/index.jsx
  6. 10
      style/components/progress.less

38
components/progress/demo/circle-dynamic.md

@ -0,0 +1,38 @@
# 动态展示
- order: 4
会动的进度条才是好进度条。
---
````jsx
var ProgressCircle = antd.Progress.Circle;
var MyProgress = React.createClass({
getInitialState() {
return {
percent: 0
};
},
componentDidMount: function() {
var self = this;
setInterval(function() {
if (self.state.percent < 100) {
self.state.percent += 2;
}
self.setState({
percent: self.state.percent
});
}, 100);
},
render() {
return <ProgressCircle percent={this.state.percent} />;
}
});
React.render(
<MyProgress />
, document.getElementById('components-progress-demo-circle-dynamic'));
````

6
components/progress/demo/circle.md

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

2
components/progress/demo/dynamic.md

@ -27,7 +27,7 @@ var MyProgress = React.createClass({
}, 100);
},
render() {
return <Progress percent={this.state.percent} width="300" strokeWidth="3" />;
return <Progress percent={this.state.percent} />;
}
});

6
components/progress/demo/line.md

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

24
components/progress/index.jsx

@ -7,8 +7,9 @@ var React = require('react');
var Line = React.createClass({
getDefaultProps: function () {
return {
width: 300,
percent: 0,
strokeWidth: 4,
strokeWidth: 3,
status: 'normal' // exception
};
},
@ -26,8 +27,9 @@ var Line = React.createClass({
var style = {
'width': this.props.width
};
var wrapStyle = {
'font-size': this.props.width / 100 * this.props.strokeWidth
var fontSize = (this.props.width / 100 * this.props.strokeWidth);
var iconStyle = {
'font-size': (fontSize < 14) ? 14 : fontSize
};
var textStyle = {
'color': statusColorMap[this.props.status]
@ -36,13 +38,14 @@ var Line = React.createClass({
if (this.props.status === 'exception') {
progressInfo = (
<span style={textStyle} className='ant-progress-line-text'>
<i className='anticon anticon-exclamation-round'></i>
<i style={iconStyle} className='anticon anticon-exclamation-round'></i>
</span>
);
} else if(this.props.status === 'success'){
progressInfo = (
<span style={textStyle} className='ant-progress-line-text'>
<i className='anticon anticon-check-round'></i>
<i style={iconStyle} className='anticon anticon-check-round'></i>
</span>
);
}else {
@ -52,7 +55,7 @@ var Line = React.createClass({
}
return (
<div className='ant-progress-line-wrap' style={wrapStyle}>
<div className='ant-progress-line-wrap' >
<div className='ant-progress-line-inner' style={style}>
<Progressline percent={this.props.percent} strokeWidth={this.props.strokeWidth}
strokeColor={statusColorMap[this.props.status]} trailColor="#e9e9e9" />
@ -66,6 +69,7 @@ var Line = React.createClass({
var Circle = React.createClass({
getDefaultProps: function () {
return {
width: 150,
percent: 0,
strokeWidth: 4,
status: 'normal' // exception
@ -87,7 +91,7 @@ var Circle = React.createClass({
'height': this.props.width
};
var wrapStyle = {
'font-size': this.props.width * 0.3
'font-size': this.props.width * 0.2
};
var textStyle = {
'color': statusColorMap[this.props.status]
@ -99,6 +103,12 @@ var Circle = React.createClass({
<i className='anticon anticon-exclamation'></i>
</span>
);
}else if(this.props.status === 'success'){
progressInfo = (
<span style={textStyle} className='ant-progress-circle-text'>
<i className="anticon anticon-check"></i>
</span>
);
}else {
progressInfo = (
<span className="ant-progress-circle-text">{this.props.percent}%</span>

10
style/components/progress.less

@ -5,6 +5,10 @@
&-circle-wrap {
display: inline-block;
}
&-line-wrap {
font-size: 12px;
}
&-line-inner {
display: inline-block;
@ -20,7 +24,7 @@
line-height: 1;
.anticon {
font-size: 1.5em;
font-size: 1.2em;
}
}
@ -35,11 +39,11 @@
width: 100%;
text-align: center;
line-height: 1;
top: 33%;
top: 38%;
left: 0;
.anticon {
font-size: 1em;
font-size: 14/12em;
}
}
}

Loading…
Cancel
Save