All files / components/post social-button.jsx

93.33% Statements 14/15
77.78% Branches 7/9
100% Functions 1/1
93.33% Lines 14/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 43 44 45 46 47            2x     1x 1x     1x 1x         2x 1x 1x 1x 1x 1x   2x               1x         1x              
import React from 'react';
import PropTypes from 'prop-types';
 
class SocialButton extends React.Component {
  render() {
    let position;
    switch(this.props.position) {
      case('left'):
      case('pull-left'):
        position = 'pull-left';
        break;
      case('right'):
      case('pull-right'):
        position = 'pull-right';
        break;
      default:
        position = '';
    }
    let buttonClass, buttonName;
    if (this.props.type === 'like') {
      buttonClass = "fa-thumbs-o-up";
      buttonName = "Like";
    } else Eif(this.props.type === 'share') {
      buttonClass = "fa-share";
      buttonName = "Share";
    }
    return (
      <button className={`btn btn-xs ${position} ${this.props.theme}`}>
        <i className={`fa ${buttonClass}`} />
        {buttonName}
      </button>
    );
  }
}
SocialButton.propTypes = {
  position: PropTypes.string,
  theme: PropTypes.string,
  type: PropTypes.string
};
SocialButton.defaultProps = {
  position: 'left',
  theme: 'btn-default',
  type: 'like'
};
 
export default SocialButton;