import React from 'react'
import MTIcon from './mt-icon'

function MTToast (props) {
  const {
    children,
    color = 'gray',
    icon,
    onClose,
    title,
    ...rest
  } = props

  return (
    <div className={ `mt-toast mt-toast--${color}` } { ...rest }>
      <div className="mt-toast__header">
        <div>
          { icon &&
            <MTIcon type={ icon } />
          }
          <span className="mt-toast__title">{ title }</span>
        </div>
        { onClose &&
          <span className="mt-toast__close icon-close" onClick={ onClose } />
        }
      </div>
      { children && (
        <div className="mt-toast__body">
          { children }
        </div>
      ) }
    </div>
  )
}

export default MTToast
