Sha256: eca4fb07e99cec326765f148eff7553ee723704d673b08a357d5912a2ec6224f
Contents?: true
Size: 1.06 KB
Versions: 2
Compression:
Stored size: 1.06 KB
Contents
import React from 'react'; import PropTypes from "prop-types"; import classnames from 'classnames'; import { map } from 'lodash'; import Image from "../pb_image/_image.jsx"; const propTypes = { className: PropTypes.string, name: PropTypes.string, size: PropTypes.string, url: PropTypes.string }; const defaultProps = { name: null, size: "base" }; 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 ( <Image alt={name} url={url} /> ) } }; class Avatar extends React.Component { render() { const { className, name, size, url } = this.props; const css = classnames([ `pb_avatar_kit`, `avatar_${size}`, className, ]) return ( <div className={css} data-initials={initials(name)} > {image(url, name)} </div> ) } } Avatar.propTypes = propTypes; Avatar.defaultProps = defaultProps; export default Avatar;
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
playbook_ui-2.8.6 | app/pb_kits/playbook/pb_avatar/_avatar.jsx |
playbook_ui-2.8.5 | app/pb_kits/playbook/pb_avatar/_avatar.jsx |