/* @flow */ /*eslint-disable react/no-multi-comp, flowtype/space-before-type-colon */ import React from 'react' import classnames from 'classnames' import { map } from 'lodash' import Image from "../pb_image/_image.jsx" type AvatarProps = { className?: String, name: String, size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl', status: 'online' | 'away', url: String, } const initials = function(name) { if (name) { return map(name.split(/\s/), name => name[0]).join('').substring(0,2) } } const image = function(url, name) { if (url) { return ( {name} ) } } const PbStatus = ({ size, status } : { size: String, status: String }) => (
) class Avatar extends React.Component { static defaultProps = { name: null, size: 'md' } props: AvatarProps render() { const { className, name, size, status, url } = this.props const css = classnames([ `pb_avatar_kit`, `avatar_${size}`, className, ]) return (
{image(url, name)}
) } } export default Avatar