All files / src/components/StudentCard/StudentCard index.jsx

100% Statements 9/9
100% Branches 3/3
100% Functions 2/2
100% Lines 9/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                  8x 8x       8x 8x       8x               3x   3x   3x           3x                        
import styles from './style.postcss';
 
import React, { PureComponent } from 'react';
import Card from 'components/Card';
import classnames from 'classnames';
import PropTypes from 'prop-types';
 
class StudentCard extends PureComponent {
  getChildContext() {
    const { backgroundless = false, withSeparatorLine = false, vertical = false } = this.props;
    return { backgroundless, withSeparatorLine, vertical };
  }
 
  render() {
    const { borderless, statusAccentColor, statusAccentPosition } = this.props;
    const classes = classnames(styles.StudentCard, this.props.className,
        { [styles[`__${statusAccentPosition}`]]: !! statusAccentPosition },
        { [styles[`__${statusAccentColor}`]]: !! statusAccentColor });
 
    return <div className={classes}>
      <Card borderless={!! borderless} className={styles.StudentCard_Card}>
        {this.props.children}
      </Card>
    </div>;
  }
}
 
StudentCard.accentPosition = ['bottom', 'left'];
 
StudentCard.accentColors = ['grey', 'green', 'amber', 'red', 'invalid'];
 
StudentCard.childContextTypes = {
  backgroundless: PropTypes.bool,
  withSeparatorLine: PropTypes.bool,
  vertical: PropTypes.bool,
};
 
StudentCard.propTypes = {
  backgroundless: PropTypes.bool,
  borderless: PropTypes.bool,
  className: PropTypes.string,
  withSeparatorLine: PropTypes.bool,
  statusAccentPosition: PropTypes.oneOf(StudentCard.accentPosition),
  statusAccentColor: PropTypes.oneOf(StudentCard.accentColors),
  children: PropTypes.node,
  vertical: PropTypes.bool,
};
 
export default StudentCard;