import React, { PropTypes } from 'react'; import classnames from 'classnames'; import { themr } from 'react-css-themr'; import { CARD } from '../identifiers'; import InjectAvatar from '../avatar/Avatar'; const factory = (Avatar) => { const CardTitle = ({ avatar, children, className, subtitle, theme, title, ...other }) => { const classes = classnames(theme.cardTitle, { [theme.small]: avatar, [theme.large]: !avatar, }, className); return (
{typeof avatar === 'string' ? : avatar}
{title &&
{title}
} {children && typeof children === 'string' && (
{children}
)} {subtitle &&

{subtitle}

} {children && typeof children !== 'string' && children}
); }; CardTitle.propTypes = { avatar: PropTypes.oneOfType([ PropTypes.string, PropTypes.element, ]), children: PropTypes.oneOfType([ PropTypes.string, PropTypes.element, PropTypes.array, ]), className: PropTypes.string, subtitle: PropTypes.oneOfType([ PropTypes.string, PropTypes.element, ]), theme: PropTypes.shape({ large: PropTypes.string, title: PropTypes.string, small: PropTypes.string, subtitle: PropTypes.string, }), title: PropTypes.oneOfType([ PropTypes.string, PropTypes.element, ]), }; return CardTitle; }; const CardTitle = factory(InjectAvatar); export default themr(CARD)(CardTitle); export { CardTitle }; export { factory as cardTitleFactory };