All files / src/containers/Sidebar/Link index.jsx

85.71% Statements 6/7
75% Branches 3/4
100% Functions 1/1
85.71% Lines 6/7
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                  1x 20x 7x     13x 13x               1x              
import styles from './style.postcss';
 
import React from 'react';
import { Link } from 'react-router';
import is from 'is_js';
import PathComparator from 'domain/PathComparator';
import classnames from 'classnames';
import PropTypes from 'prop-types';
 
const LinkComponent = ({ currentPath, to, children }) => {
  if (PathComparator.equal(currentPath, to)) {
    return <div className={classnames(styles.LinkComponent, styles.__current)}>{children}</div>;
  }
 
  Eif (is.not.url(to)) {
    return <Link to={to} className={styles.LinkComponent}>{children}</Link>;
  }
 
  return <a href={to} target="_blank" rel="noopener noreferrer" className={styles.LinkComponent}>
    {children}
  </a>;
};
 
LinkComponent.propTypes = {
  children: PropTypes.node,
  to: PropTypes.string,
  currentPath: PropTypes.string,
};
 
export default LinkComponent;