2016-05-29 13:47:27 +03:00
|
|
|
import React, { PropTypes } from 'react';
|
2016-05-16 14:39:59 +03:00
|
|
|
import { themr } from 'react-css-themr';
|
2016-05-28 18:44:29 +03:00
|
|
|
import { AVATAR } from '../identifiers.js';
|
|
|
|
import InjectFontIcon from '../font_icon/FontIcon.js';
|
2015-11-18 00:24:22 +03:00
|
|
|
|
2016-05-28 18:44:29 +03:00
|
|
|
const factory = (FontIcon) => {
|
|
|
|
const Avatar = ({children, className, icon, image, theme, title, ...other}) => (
|
|
|
|
<div data-react-toolbox='avatar' className={`${theme.avatar} ${className}`} {...other}>
|
|
|
|
{children}
|
|
|
|
{typeof image === 'string' ? <img className={theme.image} src={image} title={title} /> : image}
|
|
|
|
{typeof icon === 'string' ? <FontIcon className={theme.letter} value={icon} /> : icon}
|
|
|
|
{title ? <span className={theme.letter}>{title[0]}</span> : null}
|
|
|
|
</div>
|
|
|
|
);
|
2015-11-18 00:24:22 +03:00
|
|
|
|
2016-05-28 18:44:29 +03:00
|
|
|
Avatar.propTypes = {
|
|
|
|
children: PropTypes.node,
|
|
|
|
className: PropTypes.string,
|
|
|
|
icon: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
|
|
|
image: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
|
|
|
theme: React.PropTypes.shape({
|
|
|
|
avatar: React.PropTypes.string.isRequired,
|
|
|
|
image: React.PropTypes.string.isRequired,
|
|
|
|
letter: React.PropTypes.string.isRequired
|
|
|
|
}),
|
|
|
|
title: PropTypes.string
|
|
|
|
};
|
|
|
|
|
|
|
|
return Avatar;
|
2015-11-26 03:53:42 +03:00
|
|
|
};
|
2015-11-18 00:24:22 +03:00
|
|
|
|
2016-05-28 18:44:29 +03:00
|
|
|
const Avatar = factory(InjectFontIcon);
|
|
|
|
export default themr(AVATAR)(Avatar);
|
|
|
|
export { factory as avatarFactory };
|
|
|
|
export { Avatar };
|