All files / src/components/Icon index.jsx

100% Statements 4/4
100% Branches 0/0
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                10x 29x     29x             10x                
import styles from './style.postcss';
import React from 'react';
import classnames from 'classnames';
import InlineSvg from 'components/InlineSvg';
import is from 'is_js';
import icons from './icons';
import PropTypes from 'prop-types';
 
const Icon = ({ className, id, title, onClick }) => {
  const classes = classnames(styles.Icon,
      className,
      { [styles.__clickable]: is.function(onClick) });
  return <InlineSvg className={classes}
      title={title}
      onClick={onClick}>
    {icons.get(id)}
  </InlineSvg>;
};
 
Icon.propTypes = {
  className: PropTypes.string,
  id: PropTypes.oneOf(Object.keys(icons.toObject())),
  title: PropTypes.string,
  onClick: PropTypes.func,
};
 
export default Icon;