import React from 'react'; import './treat-progress.less'; export default class TreatProgress extends React.Component { componentWillMount() { this.setState({ value: 0 }); const self = this; setTimeout(() => { self.setState({ value: self.props.value }); }, 300); } render() { const val = this.state.value; const r = 90; const c = Math.PI * r * 2; var pct = ((100 - val) / 100) * c; return (
{this.props.value + '%'} { this.props.label &&
{this.props.label}
}
); } } TreatProgress.propTypes = { value: React.PropTypes.number, width: React.PropTypes.number, height: React.PropTypes.number, label: React.PropTypes.string }; TreatProgress.defaultProps = { width: 100, height: 100 };