All files / components/feature feature.jsx

100% Statements 3/3
50% Branches 2/4
33.33% Functions 1/3
100% Lines 3/3
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          1x                                                                                   1x                                     1x                      
import React from 'react';
import PropTypes from 'prop-types';
 
class Feature extends React.Component {
  render() {
    return (
      <div className="box box-solid">
        <div className="box-body">
          <h4 className="feature-header">
            {this.props.headline}
          </h4>
          <div className="media">
            {this.props.img ? (
              <div className="media-left">
                <a href={this.props.imgLink} onClick={this.props.imgOnClick}>
                  <img
                    src={this.props.img}
                    alt={this.props.imgAlt}
                    className="media-object feature-img"
                  />
                </a>
              </div>
            ) : ''}
            <div className="media-body">
              <div className="clearfix">
                {this.props.cta ? (
                  <p className="pull-right">
                    <a
                      href={this.props.ctaLink}
                      onClick={this.props.ctaOnClick}
                      className={`btn btn-sm ${this.props.ctaTheme}`}
                    >
                      {this.props.cta}
                    </a>
                  </p>
                ) : ''}
                {this.props.content}
                {this.props.children}
              </div>
            </div>
          </div>
        </div>
      </div>
    );
  }
}
 
Feature.propTypes = {
  headline: PropTypes.oneOfType([
    PropTypes.string,
    PropTypes.element
  ]),
  img: PropTypes.string,
  imgLink: PropTypes.string,
  imgOnClick: PropTypes.func,
  imgAlt: PropTypes.string,
  cta: PropTypes.string,
  ctaLink: PropTypes.string,
  ctaOnClick: PropTypes.func,
  ctaTheme: PropTypes.string,
  content: PropTypes.oneOfType([
    PropTypes.string,
    PropTypes.element
  ])
};
 
Feature.defaultProps = {
  headline: '',
  img: '',
  imgOnClick: () => {},
  imgAlt: '',
  ctaOnClick: () => {},
  ctaTheme: 'btn-success',
  content: ''
};
 
export default Feature;