import React, { useState, MouseEvent } from 'react'
import classNames from 'classnames'
import './button.css'

export interface ButtonProps {
  /**
   * Is this the principal call to action on the page?
   */
  type?: 'primary' | 'secondary'
  /**
   * What background color to use
   */
  textColor?: string
  /**
   * How large should the button be?
   */
  size?: 'small' | 'medium' | 'large'
  /**
   * Button contents
   */
  label: string
  /**
   * Optional click handler
   */
  onClick?: (event: MouseEvent<HTMLButtonElement>) => void
}

/**
 * Primary UI component for user interaction
 */
const Button = ({
  type = 'primary',
  textColor,
  size = 'medium',
  onClick,
  label,
}: ButtonProps) => {
  const [theState, setTheState] = useState(4)

  return (
    <button
      type="button"
      className={classNames(
        'storybook-button',
        `storybook-button--${size}`,
        `storybook-button--${type}`
      )}
      style={textColor ? { color: textColor } : {}}
      onClick={onClick}
    >
      {`${label} ${theState}`}
    </button>
  )
}

export default Button
