All files / components/utilities callout-alert.jsx

100% Statements 4/4
78.57% Branches 11/14
100% Functions 1/1
100% Lines 4/4
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          2x 2x                           1x                 1x                    
import React from 'react';
import PropTypes from 'prop-types';
 
class CalloutAlert extends React.Component {
  render() {
    const classList = this.props.callout ? `callout callout-${this.props.theme}` : `alert alert-${this.props.theme} text-left${this.props.dismissible ? ' alert-dismissible' : ''}`;
    return (
      <div className={classList}>
        {!this.props.callout && this.props.dismissible ? <button type="button" className="close" data-dismiss="alert" aria-hidden="true">×</button> : ''}
        <h4>
          {this.props.icon ? <i className={`fa ${this.props.icon}`} /> : ''}
          {this.props.icon && this.props.header ? ' ' : ''}
          {this.props.header}
        </h4>
        <p>{this.props.content}</p>
      </div>
    );
  }
}
 
CalloutAlert.propTypes = {
  theme: PropTypes.string,
  icon: PropTypes.string,
  header: PropTypes.string,
  content: PropTypes.string,
  callout: PropTypes.bool,
  dismissible: PropTypes.bool
};
 
CalloutAlert.defaultProps = {
  theme: 'success',
  icon: '',
  header: '',
  content: '',
  callout: false,
  dismissible: false
};
 
export default CalloutAlert;