import React from 'react'
import cx from 'classnames'

function MTCheckbox (props) {
  const {
    checked,
    children,
    disabled,
    inputProps = {},
    labelProps = {},
    name,
    onChange,
    className,
    ...otherProps
  } = props

  return (
    <div { ...otherProps } className={ cx('mt-checkbox', className) }>
      <input { ...inputProps } name={ name } type="checkbox" checked={ checked } onChange={ onChange } disabled={ disabled } />
      <label { ...labelProps } htmlFor={ name } className={ cx('mt-checkbox__label', labelProps.className) }>{ children }</label>
      <span className="mt-checkbox__checkmark" />
    </div>
  )
}

export default MTCheckbox
