import React from 'react';
import PropTypes from 'prop-types';
class StatTile extends React.Component {
render() {
let link = '';
let stats = (
<h3>{this.props.stats}</h3>
);
Eif(this.props.link) {
link = (
<a
href={this.props.link}
onClick={this.props.onClick ? e => {
e.preventDefault();
e.stopPropagation();
this.props.onClick();
} : () => {}}
className="small-box-footer"
>
More info <i className="fa fa-arrow-circle-right"></i>
</a>
);
}
Iif(this.props.stats instanceof String && this.props.stats.indexOf('%') !== -1) {
let style = {
fontSize: '20px'
};
stats = (
<h3>
{this.props.stats.replace(/%/g,'')}
<sup style={style}>
{this.props.stats.indexOf('%') >= 0 ? '%' : ''}
</sup>
</h3>
);
}
return (
<div className={`col-md-${this.props.width} col-sm-6 col-xs-12`}>
<div className={`small-box ${this.props.theme}`}>
<div className="inner">
{stats}
<p>{this.props.subject}</p>
</div>
<div className="icon">
<i className={`fa ${this.props.icon}`}></i>
</div>
{link}
</div>
</div>
);
}
}
StatTile.propTypes = {
width: PropTypes.oneOfType([
PropTypes.number,
PropTypes.string
]),
theme: PropTypes.string,
icon: PropTypes.string,
subject: PropTypes.string,
stats: PropTypes.oneOfType([
PropTypes.number,
PropTypes.string
]),
link: PropTypes.string,
onClick: PropTypes.func
};
StatTile.defaultProps = {
width: 3,
theme: 'bg-yellow',
icon: 'fa-user-plus',
subject: '',
stats: 0
};
export default StatTile;
|