All files / components/post attachment.jsx

66.67% Statements 6/9
100% Branches 4/4
40% Functions 2/5
66.67% Lines 6/9
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          2x                                           1x 1x 1x                     1x             1x                
import React from 'react';
import PropTypes from 'prop-types';
 
class Attachment extends React.Component {
  render() {
    return (
      <div className="attachment-block clearfix">
        <img className="attachment-img" src={this.props.img} alt="Attachment image" />
        <div className="attachment-pushed">
          <h4 className="attachment-heading">
            <a
              href={this.props.link}
              onClick={this.props.onClick ? e => {
                 e.preventDefault();
                 e.stopPropagation();
                 this.props.onClick();
               } : () => {}}
            >
              {this.props.title}
            </a>
          </h4>
          <div className="attachment-text">
            {this.props.content}
            {this.props.children}
            <a
              href={this.props.link}
              onClick={this.props.onClick ? e => {
                 e.preventDefault();
                 e.stopPropagation();
                 this.props.onClick();
               } : () => {}}
            >
              More...
            </a>
          </div>
        </div>
      </div>
    );
  }
}
Attachment.propTypes = {
  title: PropTypes.string,
  link: PropTypes.string,
  onClick: PropTypes.func,
  img: PropTypes.string,
  content: PropTypes.string
};
Attachment.defaultProps = {
  title: '',
  link: '',
  img: '',
  content: ''
};
 
export default Attachment;