all files / src/panels/ImageIcon/ index.js

68.75% Statements 11/16
21.43% Branches 3/14
50% Functions 1/2
66.67% Lines 10/15
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                                                               
'use strict';
 
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = ImageIcon;
 
var _react = require('react');
 
var _react2 = _interopRequireDefault(_react);
 
var _propTypes = require('prop-types');
 
var _propTypes2 = _interopRequireDefault(_propTypes);
 
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
 
function ImageIcon(props) {
  if (props.data && props.data.image) {
    return _react2.default.createElement('img', {
      alt: props.data.alt || 'ImageIcon',
      src: props.data.image,
      style: { height: props.height }
    });
  }
 
  if (props.data && props.data.icon) {
    return _react2.default.createElement('i', { className: props.data.icon });
  }
 
  return null;
}
 
ImageIcon.propTypes = {
  data: _propTypes2.default.object.isRequired,
  height: _propTypes2.default.string
};
 
ImageIcon.defaultProps = {
  height: '1.5em'
};