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

function MTRow (props) {
  const {
    shouldWrap,
    align,
    children,
    contain,
    center,
    className,
    ...otherProps
  } = props

  const wrapClass = shouldWrap ? 'mt-row--wrap' : ''
  const centerClass = center ? 'container--centered' : ''
  const rowContent = (
    <div
      className={ `mt-row ${wrapClass} mt-row--${align} ${className}` }
      { ...otherProps }
    >
      { children }
    </div>
  )

  return (contain === true)
    ? (
      <div className={ `container ${centerClass}` }>
        { rowContent }
      </div>
    )
    : rowContent
}

MTRow.defaultProps = {
  shouldWrap: false,
  contain: false,
  align: 'stretch',
  center: false,
  className: '',
}

MTRow.propTypes = {
  shouldWrap: PropTypes.bool,
  contain: PropTypes.bool,
  center: PropTypes.bool,
  align: PropTypes.oneOf([ 'stretch', 'top', 'bottom', 'center', 'baseline' ]),
  children: PropTypes.node,
  className: PropTypes.string,
}

export default MTRow
