aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/button/button.component.js
blob: e8e7984450b3a9e291e2d5850054ce1de26aab58 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import classnames from 'classnames'

const CLASSNAME_DEFAULT = 'btn-default'
const CLASSNAME_PRIMARY = 'btn-primary'
const CLASSNAME_SECONDARY = 'btn-secondary'
const CLASSNAME_LARGE = 'btn--large'

const typeHash = {
  default: CLASSNAME_DEFAULT,
  primary: CLASSNAME_PRIMARY,
  secondary: CLASSNAME_SECONDARY,
}

class Button extends Component {
  render () {
    const { type, large, className, ...buttonProps } = this.props

    return (
      <button
        className={classnames(
          typeHash[type],
          large && CLASSNAME_LARGE,
          className
        )}
        { ...buttonProps }
      >
        { this.props.children }
      </button>
    )
  }
}

Button.propTypes = {
  type: PropTypes.string,
  large: PropTypes.bool,
  className: PropTypes.string,
  children: PropTypes.string,
}

export default Button