import React from 'react'
import PropTypes from 'prop-types'
import cx from 'classnames'

function MTLabel (props) {
  const {
    type,
    label,
    icon,
    className,
    ...otherProps
  } = props

  const labelIcon = icon ? <span className={ `icon-${icon}` } /> : ''
  return (
    <div
      { ...otherProps }
      className={ cx('label', `label--${type}`, className) }
    >
      { labelIcon }
      { label }
    </div>
  )
}

MTLabel.defaultProps = {
  type: 'base',
}

MTLabel.propTypes = {
  type: PropTypes.oneOf([ 'base', 'blue', 'yellow', 'green', 'red' ]),
  label: PropTypes.string.isRequired,
  icon: PropTypes.string,
}

export default MTLabel
