2018-05-20 08:04:19 +02:00
|
|
|
import React, { Component } from 'react'
|
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
import classnames from 'classnames'
|
2018-05-03 19:51:15 +02:00
|
|
|
|
|
|
|
const SECONDARY = 'secondary'
|
|
|
|
const CLASSNAME_PRIMARY = 'btn-primary'
|
|
|
|
const CLASSNAME_PRIMARY_LARGE = 'btn-primary--lg'
|
|
|
|
const CLASSNAME_SECONDARY = 'btn-secondary'
|
|
|
|
const CLASSNAME_SECONDARY_LARGE = 'btn-secondary--lg'
|
|
|
|
|
|
|
|
const getClassName = (type, large = false) => {
|
|
|
|
let output = type === SECONDARY ? CLASSNAME_SECONDARY : CLASSNAME_PRIMARY
|
|
|
|
|
|
|
|
if (large) {
|
|
|
|
output += ` ${type === SECONDARY ? CLASSNAME_SECONDARY_LARGE : CLASSNAME_PRIMARY_LARGE}`
|
|
|
|
}
|
|
|
|
|
|
|
|
return output
|
|
|
|
}
|
|
|
|
|
|
|
|
class Button extends Component {
|
|
|
|
render () {
|
|
|
|
const { type, large, className, ...buttonProps } = this.props
|
|
|
|
|
|
|
|
return (
|
2018-05-20 08:04:19 +02:00
|
|
|
<button
|
|
|
|
className={classnames(getClassName(type, large), className)}
|
|
|
|
{ ...buttonProps }
|
|
|
|
>
|
|
|
|
{ this.props.children }
|
|
|
|
</button>
|
2018-05-03 19:51:15 +02:00
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Button.propTypes = {
|
|
|
|
type: PropTypes.string,
|
|
|
|
large: PropTypes.bool,
|
|
|
|
className: PropTypes.string,
|
|
|
|
children: PropTypes.string,
|
|
|
|
}
|
|
|
|
|
2018-05-20 08:04:19 +02:00
|
|
|
export default Button
|
2018-05-03 19:51:15 +02:00
|
|
|
|