All files / components/info-tile info-tile.jsx

100% Statements 8/8
87.5% Branches 14/16
100% Functions 1/1
100% Lines 8/8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86          2x 2x 2x 2x 2x 2x                                                       1x                                                                       1x                      
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;