All files / components/card/card-header index.js

0% Statements 0/26
0% Branches 0/8
0% Functions 0/3
0% Lines 0/11
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44                                                                                       
import React from 'react'
import PropTypes from 'prop-types'
import cx from 'classnames'
 
import CardHeaderStyled from './card-header.styled'
import CardHeaderIconStyled from './card-header-icon.styled'
 
const CardHeaderIcon = ({ icon }) => (
  <CardHeaderIconStyled>
    <img src={icon} />
  </CardHeaderIconStyled>
)
 
const CardHeader = ({ className, icon, title, custom }) => (
  <CardHeaderStyled className={cx({
    'has-icon': !!icon,
    'has-custom': !!custom
  }, className)}>
    {icon && <CardHeaderIcon icon={icon} />}
    <div className='card-header-wrapper'>
      <span className='card-header-title'>{title}</span>
      { custom && <span className='card-header-custom'>{custom}</span> }
    </div>
  </CardHeaderStyled>
)
 
CardHeaderIcon.propTypes = {
  icon: PropTypes.string
}
 
CardHeader.propTypes = {
  className: PropTypes.string,
  icon: PropTypes.string,
  title: PropTypes.string.isRequired,
  custom: PropTypes.node
}
 
CardHeader.defaultProps = {
  icon: '',
  custom: null
}
 
export { CardHeader }