2015-11-28 00:17:35 +03:00
|
|
|
import React, {PropTypes} from 'react';
|
2016-05-16 14:39:59 +03:00
|
|
|
import { themr } from 'react-css-themr';
|
2015-11-26 03:53:42 +03:00
|
|
|
import FontIcon from '../font_icon';
|
2015-11-18 00:24:22 +03:00
|
|
|
|
2016-05-16 14:39:59 +03:00
|
|
|
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
|
|
|
|
2015-11-26 03:53:42 +03:00
|
|
|
Avatar.propTypes = {
|
2015-11-28 00:17:35 +03:00
|
|
|
children: PropTypes.node,
|
|
|
|
className: PropTypes.string,
|
|
|
|
icon: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
|
|
|
image: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
2016-05-16 14:39:59 +03:00
|
|
|
theme: React.PropTypes.shape({
|
|
|
|
avatar: React.PropTypes.string.isRequired,
|
|
|
|
image: React.PropTypes.string.isRequired,
|
|
|
|
letter: React.PropTypes.string.isRequired
|
|
|
|
}),
|
2015-11-28 00:17:35 +03:00
|
|
|
title: PropTypes.string
|
2015-11-26 03:53:42 +03:00
|
|
|
};
|
2015-11-18 00:24:22 +03:00
|
|
|
|
2016-05-16 14:39:59 +03:00
|
|
|
export default themr('ToolboxAvatar')(Avatar);
|