react-toolbox/components/avatar/Avatar.js

25 lines
858 B
JavaScript
Raw Normal View History

2015-11-28 00:17:35 +03:00
import React, {PropTypes} from 'react';
2015-11-26 03:53:42 +03:00
import FontIcon from '../font_icon';
import style from './style';
2015-11-26 03:53:42 +03:00
const Avatar = ({children, className, icon, image, title, ...other}) => {
return (
2015-11-28 00:09:18 +03:00
<div data-react-toolbox='avatar' className={`${style.avatar} ${className}`} {...other}>
2015-11-26 03:53:42 +03:00
{children}
2015-11-28 00:09:18 +03:00
{typeof image === 'string' ? <img className={style.image} src={image} title={title} /> : image}
{typeof icon === 'string' ? <FontIcon className={style.letter} value={icon} /> : icon}
{title ? <span className={style.letter}>{title[0]}</span> : null}
2015-11-26 03:53:42 +03:00
</div>
);
};
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]),
title: PropTypes.string
2015-11-26 03:53:42 +03:00
};
export default Avatar;