All files / components/dropdown-list dropdown-list.jsx

100% Statements 3/3
72.73% Branches 16/22
100% Functions 1/1
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          1x                                               1x                                             1x                
import React from 'react';
import PropTypes from 'prop-types';
 
class DropdownList extends React.Component {
  render() {
    return (
      <li className="dropdown">
        <a
          className="dropdown-toggle"
          data-toggle="dropdown"
          aria-expanded="false"
        >
          {this.props.icon && !this.props.iconRight ? (<i className={`fa ${this.props.icon}`} />) : ''}
          {this.props.headline && this.props.icon && !this.props.iconRight ? ' ' : ''}
          {this.props.headline}
          {this.props.headline && this.props.icon && this.props.iconRight ? ' ' : ''}
          {this.props.icon && this.props.iconRight ? (<i className={`fa ${this.props.icon}`} />) : ''}
        </a>
        <ul className="dropdown-menu">
          {this.props.dropHeader ? <li className="header">{this.props.dropHeader}</li> : ''}
          {this.props.dropContent}
          {this.props.children}
          {this.props.dropFooter ? <li className="footer">{this.props.dropFooter}</li> : ''}
        </ul>
      </li>
    );
  }
}
 
DropdownList.propTypes = {
  headline: PropTypes.oneOfType([
    PropTypes.element,
    PropTypes.string
  ]),
  icon: PropTypes.string,
  iconRight: PropTypes.bool,
  dropHeader: PropTypes.oneOfType([
    PropTypes.element,
    PropTypes.array,
    PropTypes.string
  ]),
  dropFooter: PropTypes.oneOfType([
    PropTypes.element,
    PropTypes.array,
    PropTypes.string
  ]),
  dropContent: PropTypes.oneOfType([
    PropTypes.element,
    PropTypes.array
  ])
};
 
DropdownList.defaultProps = {
  headline: '',
  icon: '',
  iconRight: false,
  dropContent: []
};
 
export default DropdownList;