import React, { PropTypes } from 'react'; import classnames from 'classnames'; import { themr } from 'react-css-themr'; import { AVATAR } from '../identifiers'; import InjectFontIcon from '../font_icon/FontIcon'; const factory = (FontIcon) => { const Avatar = ({ alt, children, className, cover, icon, image, theme, title, ...other }) => (
{children} {cover && typeof image === 'string' && } {!cover && (typeof image === 'string' ? {alt} : image)} {typeof icon === 'string' ? : icon} {title ? {title[0]} : null}
); Avatar.propTypes = { alt: PropTypes.string, children: PropTypes.node, className: PropTypes.string, cover: PropTypes.bool, icon: PropTypes.oneOfType([PropTypes.string, PropTypes.element]), image: PropTypes.oneOfType([PropTypes.string, PropTypes.element]), theme: PropTypes.shape({ avatar: PropTypes.string, image: PropTypes.string, letter: PropTypes.string, }), title: PropTypes.string, }; Avatar.defaultProps = { alt: '', cover: false, }; return Avatar; }; const Avatar = factory(InjectFontIcon); export default themr(AVATAR)(Avatar); export { factory as avatarFactory }; export { Avatar };