import React, {PureComponent} from 'react';
import PropTypes from 'prop-types';
import {Link} from 'react-router-dom';
import classNames from 'classnames';
import omit from 'lodash.omit';

import './link.scss';

class MoWebLink extends PureComponent {
  static propTypes = {
    href: PropTypes.string,
    theme: PropTypes.string,
    className: PropTypes.string,
    children: PropTypes.any,
    target: PropTypes.string
  };

  static defaultProps = {
    theme: 'blue'
  };

  render() {
    const {href, theme, className, children, target} = this.props;

    return (
      <Link
        {...omit(this.props, 'className', 'theme')}
        className={classNames(
          'mo-web-link',
          `mo-web-link--${theme}`,
          className
        )}
        to={href}
        target={target}
      >
        {children}
      </Link>
    );
  }
}

export default MoWebLink;
