import React from 'react';
import PropTypes from 'prop-types';
class InfoTile extends React.Component {
render() {
const xs = this.props.widthXS || this.props.width;
const sm = this.props.widthSM || xs;
const md = this.props.widthMD || sm;
const lg = this.props.widthLG || md;
const xl = this.props.widthXL || lg;
return (
<div className={`col-xs-${xs} col-sm-${sm} col-md-${md} col-lg-${lg} col-xl-${xl}`}>
<div className={`info-box${this.props.percent ? ` ${this.props.theme}` : ''}`}>
<span className={`info-box-icon${this.props.percent ? '' : ` ${this.props.theme}`}`}>
<i className={`fa ${this.props.icon}`} />
</span>
<div className="info-box-content">
<span className="info-box-text">{this.props.subject}</span>
<span className="info-box-number">{this.props.stats}</span>
{this.props.percent ? (
<div>
<div className="progress">
<div
className={`progress-bar ${this.props.progressTheme}`}
style={{ width: `${this.props.percent}%` }}
/>
</div>
<span className="progress-description">
{this.props.content}
</span>
</div>
) : this.props.content}
</div>
</div>
</div>
);
}
}
InfoTile.propTypes = {
width: PropTypes.oneOfType([
PropTypes.number,
PropTypes.string
]),
widthXS: PropTypes.oneOfType([
PropTypes.number,
PropTypes.string
]),
widthSM: PropTypes.oneOfType([
PropTypes.number,
PropTypes.string
]),
widthMD: PropTypes.oneOfType([
PropTypes.number,
PropTypes.string
]),
widthLG: PropTypes.oneOfType([
PropTypes.number,
PropTypes.string
]),
widthXL: PropTypes.oneOfType([
PropTypes.number,
PropTypes.string
]),
icon: PropTypes.string,
stats: PropTypes.oneOfType([
PropTypes.number,
PropTypes.string
]),
percent: PropTypes.number,
content: PropTypes.string,
subject: PropTypes.string,
theme: PropTypes.string,
progressTheme: PropTypes.string
};
InfoTile.defaultProps = {
width: 12,
content: '',
icon: 'fa-star-o',
stats: 0,
subject: '',
theme: 'bg-yellow',
progressTheme: 'bg-white'
};
export default InfoTile;
|