<commit_before>/* eslint-disable react/no-multi-comp */
import React, { Component, PropTypes } from 'react';
import cx from 'classnames';

import * as links from './social-media-share-links';
import { windowOpen } from './utils';

const supportedNetworks = Object.keys(links);

export default class ShareButton extends Component {
  static propTypes = {
    className: PropTypes.string,
    network: PropTypes.oneOf(supportedNetworks),
    url: PropTypes.string.isRequired,
    opts: PropTypes.object,
  };

  onClick = (e) => {
    e.preventDefault();
    windowOpen(this.link());
    return false;
  }

  link() {
    const { url, opts, network } = this.props;
    return links[network](url, opts);
  }

  render() {
    const {
      className,
      network,
      ...rest,
    } = this.props;

    return (
      <div {...rest}
        onClick={this.onClick}
        url={this.link()}
        className={cx(
          'SocialMediaShareButton',
          `SocialMediaShareButton--${network}`,
          className
        )} />
    );
  }
}

/* HOC to ease migration from v1 to v2.<commit_msg>remove deprecated return from onClick in share buttons<commit_after>/* eslint-disable react/no-multi-comp */
import React, { Component, PropTypes } from 'react';
import cx from 'classnames';

import * as links from './social-media-share-links';
import { windowOpen } from './utils';

const supportedNetworks = Object.keys(links);

export default class ShareButton extends Component {
  static propTypes = {
    className: PropTypes.string,
    network: PropTypes.oneOf(supportedNetworks),
    url: PropTypes.string.isRequired,
    opts: PropTypes.object,
  };

  onClick = (e) => {
    e.preventDefault();
    windowOpen(this.link());
  }

  link() {
    const { url, opts, network } = this.props;
    return links[network](url, opts);
  }

  render() {
    const {
      className,
      network,
      ...rest,
    } = this.props;

    return (
      <div {...rest}
        onClick={this.onClick}
        url={this.link()}
        className={cx(
          'SocialMediaShareButton',
          `SocialMediaShareButton--${network}`,
          className
        )} />
    );
  }
}

/* HOC to ease migration from v1 to v2.
{'fraction_non_alphanumeric': 0.13769751693002258, 'fraction_numerical': 0.0018058690744920992, 'mean_word_length': 2.5974025974025974, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2447689', 'n_tokens_mistral': 661, 'n_tokens_neox': 663, 'n_words': 162}