<commit_before>// (C) Copyright 2014-2015 Hewlett Packard Enterprise Development LP

import React, { PropTypes } from 'react';
import classnames from 'classnames';
import RightLeftIcon from './icons/LinkRightLeft';
import iconsMap from '../index-icons';

const CLASS_ROOT = 'anchor';

const Anchor = props => {
  let icon;

  if (props.icon && iconsMap.hasOwnProperty(props.icon)) {
    let CustomIcon = iconsMap[props.icon];
    icon = <CustomIcon />;
  } else {
    icon = <RightLeftIcon />;
  }

  if (icon && !(props.primary)) {
    icon = (<span className={`${CLASS_ROOT}__icon`}>{icon}</span>);
  }

  let classes = classnames(
    CLASS_ROOT,
    props.className,
    {
      [`${CLASS_ROOT}--primary`]: props.primary,
      [`${CLASS_ROOT}--disabled`]: props.disabled
    }
  );

  return (
    <props.tag id={props.id} className={classes}
      href={props.href}
      target={props.target}
      onClick={props.onClick}>
      {(props.primary || props.icon)? icon : null}
      {props.children}
    </props.tag>
  );
};


Anchor.propTypes = {
  icon: PropTypes.string,
  disabled: PropTypes.bool,
  href: PropTypes.string,
  id: PropTypes.string,
  onClick: PropTypes.func,<commit_msg>updating Anchor.js to default to RightLeftIcon only for primary anchors, and leaving original behavior for Icon anchors (can create icon anchors by passing in child Icon components or icon props)<commit_after>// (C) Copyright 2014-2015 Hewlett Packard Enterprise Development LP

import React, { Children, PropTypes } from 'react';
import classnames from 'classnames';
import RightLeftIcon from './icons/LinkRightLeft';
import iconsMap from '../index-icons';

const CLASS_ROOT = 'anchor';

const Anchor = props => {
  let icon;

  if (props.icon && iconsMap.hasOwnProperty(props.icon)) {
    let CustomIcon = iconsMap[props.icon];
    icon = <CustomIcon />;
  } else {
    icon = <RightLeftIcon />;
  }

  if (props.icon && iconsMap.hasOwnProperty(props.icon)) {
    let CustomIcon = iconsMap[props.icon];
    if (props.primary) {
      icon = <CustomIcon />;
    } else {
      icon = (<span className={`${CLASS_ROOT}__icon`}>{icon}</span>);
    }
  } else if (props.primary) {
    icon = <RightLeftIcon />;
  }

  let classes = classnames(
    CLASS_ROOT,
    props.className,
    {
      [`${CLASS_ROOT}--primary`]: props.primary,
      [`${CLASS_ROOT}--disabled`]: props.disabled
    }
  );

  let children = Children.map(props.children, child => {
    if (child && child.type && child.type.icon) {
      child = <span className={`${CLASS_ROOT}__icon`}>{child}</span>;
    }

    return child;
  });

  return (
    <props.tag id={props.id} className={classes}
      href={props.href}
      target={props.target}
      onClick={props.onClick}>
      {(props.primary || props.icon)? icon : null}
      {children}
    </props.tag>
  );
};


Anchor.propTypes = {
  icon: PropTypes.string,
  disabled: PropTypes.bool,
  href: PropTypes.string,
  id: PropTypes.string,
  onClick: PropTypes.func,
{'fraction_non_alphanumeric': 0.15127175368139223, 'fraction_numerical': 0.00535475234270415, 'mean_word_length': 3.2945402298850577, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4110636', 'n_tokens_mistral': 972, 'n_tokens_neox': 947, 'n_words': 223}