import React from 'react';
import PropTypes from 'prop-types';
class TaskItem extends React.Component {
render() {
let stylePercentage = {
width: `${this.props.percentage}%`
}
return (
<li>
<a href={this.props.link} onClick={this.props.onClick}>
<h3>
{this.props.content}
<small className="pull-right">
{`${this.props.percentage}%`}
</small>
</h3>
<div className="progress xs">
<div className={`progress-bar ${this.props.theme}`} style={stylePercentage}>
<span className="sr-only">
{`${this.props.percentage} % Complete`}
</span>
</div>
</div>
</a>
</li>
);
}
}
TaskItem.propTypes = {
percentage: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number
]),
theme: PropTypes.string,
content: PropTypes.string,
link: PropTypes.string,
onClick: PropTypes.func
};
TaskItem.defaultProps = {
percentage: 0,
theme: 'bg-yellow',
content: ''
};
export default TaskItem;
|