All files / src/components/SelectionTable/Level index.jsx

100% Statements 7/7
100% Branches 0/0
100% Functions 3/3
100% Lines 6/6
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                  1x 1x 1x       7x 7x                     1x                  
import styles from './style.postcss';
 
import React, { PureComponent } from 'react';
import Icon from 'components/Icon';
import PropTypes from 'prop-types';
 
class Level extends PureComponent {
 
  _onLevelClick() {
    const { onClick, route, label } = this.props;
    const newRoute = Array.from([...route, label]);
    onClick(newRoute);
  }
 
  render() {
    const { label } = this.props;
    return <div className={styles.Level} onClick={() => this._onLevelClick()}>
      <span className={styles.Level_label}>
        {label}
      </span>
      <span className={styles.Level_icon}>
        <Icon id="chevron-thin-right" />
      </span>
    </div>;
  }
}
 
Level.propTypes = {
  children: PropTypes.node,
  label: PropTypes.string.isRequired,
  onClick: PropTypes.func,
  route: PropTypes.array,
  currentRoute: PropTypes.array,
};
 
export default Level;