<commit_before>import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import AvatarImage from './AvatarImage';
import AvatarInitials from './AvatarInitials';
import AvatarOverlay from './AvatarOverlay';
import Box, { pickBoxProps, omitBoxProps } from '../box';
import cx from 'classnames';
import theme from './theme.css';
import { colorsWithout } from '../../constants';

const colors = colorsWithout(['neutral']);

const hashCode = hexString => parseInt(hexString.substr(-5), 16);

const getColor = id => (id ? colors[Math.abs(hashCode(id)) % colors.length] : 'neutral');

class Avatar extends PureComponent {
  render() {
    const { className, editable, imageUrl, fullName, id, onImageChange, size, shape, ...others } = this.props;
    const avatarClassNames = cx(theme['avatar'], theme[`is-${size}`], theme[`is-${shape}`], className);
    const boxProps = pickBoxProps(others);
    const propsWithoutBoxProps = omitBoxProps(others);

    return (
      <Box className={avatarClassNames} {...boxProps}>
        {imageUrl ? (
          <AvatarImage image={imageUrl} imageAlt={fullName} {...propsWithoutBoxProps} />
        ) : (
          <AvatarInitials color={getColor(id)} name={fullName} {...propsWithoutBoxProps} />
        )}
        {editable && (size === 'large' || size === 'hero') && <AvatarOverlay onClick={onImageChange} />}
      </Box>
    );
  }
}

Avatar.propTypes = {
  /** If true, an overlay will be shown with edit icon. */
  editable: PropTypes.bool,
  /** The image url to show as an avatar. */
  imageUrl: PropTypes.string,
  /** When no image available, avatar initials will be based on this string. */
  fullName: PropTypes.string,
  /** Expects a uuid to determine the avatar initials background color. */
  id: PropTypes.string,
  /** Callback function that is fired when user clicks the edit icon. */
  onImageChange: PropTypes.func,
  /** The shape of the avatar. */
  shape: PropTypes.oneOf(['circle', 'rounded']),
  /** The size of the avatar. */
  size: PropTypes.oneOf(['tiny', 'small', 'medium', 'large', 'hero']),
};

Avatar.defaultProps = {
  shape: 'circle',
  size: 'medium',
};

export default Avatar;<commit_msg>Add creatable prop with default value false<commit_after>import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import AvatarImage from './AvatarImage';
import AvatarInitials from './AvatarInitials';
import AvatarOverlay from './AvatarOverlay';
import Box, { pickBoxProps, omitBoxProps } from '../box';
import cx from 'classnames';
import theme from './theme.css';
import { colorsWithout } from '../../constants';

const colors = colorsWithout(['neutral']);

const hashCode = hexString => parseInt(hexString.substr(-5), 16);

const getColor = id => (id ? colors[Math.abs(hashCode(id)) % colors.length] : 'neutral');

class Avatar extends PureComponent {
  render() {
    const { className, editable, imageUrl, fullName, id, onImageChange, size, shape, ...others } = this.props;
    const avatarClassNames = cx(theme['avatar'], theme[`is-${size}`], theme[`is-${shape}`], className);
    const boxProps = pickBoxProps(others);
    const propsWithoutBoxProps = omitBoxProps(others);

    return (
      <Box className={avatarClassNames} {...boxProps}>
        {imageUrl ? (
          <AvatarImage image={imageUrl} imageAlt={fullName} {...propsWithoutBoxProps} />
        ) : (
          <AvatarInitials color={getColor(id)} name={fullName} {...propsWithoutBoxProps} />
        )}
        {editable && (size === 'large' || size === 'hero') && <AvatarOverlay onClick={onImageChange} />}
      </Box>
    );
  }
}

Avatar.propTypes = {
  /** If true, an add user icon will be shown. */
  creatable: PropTypes.bool,
  /** If true, an overlay will be shown with edit icon. */
  editable: PropTypes.bool,
  /** The image url to show as an avatar. */
  imageUrl: PropTypes.string,
  /** When no image available, avatar initials will be based on this string. */
  fullName: PropTypes.string,
  /** Expects a uuid to determine the avatar initials background color. */
  id: PropTypes.string,
  /** Callback function that is fired when user clicks the edit icon. */
  onImageChange: PropTypes.func,
  /** The shape of the avatar. */
  shape: PropTypes.oneOf(['circle', 'rounded']),
  /** The size of the avatar. */
  size: PropTypes.oneOf(['tiny', 'small', 'medium', 'large', 'hero']),
};

Avatar.defaultProps = {
  creatable: false,
  shape: 'circle',
  size: 'medium',
};

export default Avatar;
{'fraction_non_alphanumeric': 0.15579790785666592, 'fraction_numerical': 0.0013354106387714222, 'mean_word_length': 3.770700636942675, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, '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': '1341069', 'n_tokens_mistral': 1347, 'n_tokens_neox': 1342, 'n_words': 402}