2016-05-20 21:37:19 +08:00
|
|
|
import React, { Component, PropTypes } from 'react';
|
|
|
|
|
|
|
|
const propTypes = {
|
|
|
|
/**
|
|
|
|
* Defines HTML disable Attribute
|
|
|
|
* @defaultValue false
|
|
|
|
*/
|
|
|
|
disabled: PropTypes.bool,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Defines HTML Tag
|
|
|
|
* @defaultValue 'button'
|
|
|
|
*/
|
|
|
|
tagName: PropTypes.string,
|
|
|
|
|
2016-06-18 00:42:17 +08:00
|
|
|
/**
|
|
|
|
* Defines the button label
|
|
|
|
* @defaultValue undefined
|
|
|
|
*/
|
|
|
|
label: PropTypes.string.isRequired,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Defines the button click handler
|
|
|
|
* @defaultValue undefined
|
|
|
|
*/
|
2016-05-20 21:37:19 +08:00
|
|
|
onClick: PropTypes.func.isRequired,
|
|
|
|
};
|
|
|
|
|
|
|
|
const defaultProps = {
|
|
|
|
disabled: false,
|
|
|
|
tagName: 'button',
|
2016-06-18 00:42:17 +08:00
|
|
|
role: 'button',
|
2016-05-20 21:37:19 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
export default class ButtonBase extends Component {
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
let Component = this.props.tagName;
|
|
|
|
|
|
|
|
return (
|
2016-06-18 00:42:17 +08:00
|
|
|
<Component aria-label={this.props.label} {...this.props}>
|
2016-05-20 21:37:19 +08:00
|
|
|
{this.props.children}
|
|
|
|
</Component>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ButtonBase.propTypes = propTypes;
|
|
|
|
ButtonBase.defaultProps = defaultProps;
|