Source: Chip/index.js

import React, { memo } from 'react';
import { string } from 'prop-types';

import Chip from '@material-ui/core/Chip';

import './index.css';

/**
 * CustomChip component
 *
 * @param {Object} props
 * @param {string} props.customBgColor
 * @param {string} props.customColor
 */
function CustomChip({ customBgColor, customColor, ...rest }) {
  let style = {};

  if (customBgColor) {
    style = { ...style, backgroundColor: customBgColor };

    if (!customColor) {
      style = { ...style, color: 'white' };
    }
  }

  if (customColor) {
    style = { ...style, color: customColor };
  }

  return <Chip style={style} {...rest} />;
}

CustomChip.propTypes = {
  customColor: string,
  customBgColor: string
};

export default memo(CustomChip);