bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/button/base/component.jsx
2016-07-11 20:10:55 +00:00

57 lines
1.1 KiB
JavaScript

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,
/**
* Defines the button label
* @defaultValue undefined
*/
label: PropTypes.string.isRequired,
/**
* Defines the button click handler
* @defaultValue undefined
*/
onClick: PropTypes.func.isRequired,
};
const defaultProps = {
disabled: false,
tagName: 'button',
role: 'button',
};
export default class ButtonBase extends Component {
constructor(props) {
super(props);
}
render() {
let Component = this.props.tagName;
const remainingProps = Object.assign({}, this.props);
delete remainingProps.label;
delete remainingProps.tagName;
return (
<Component aria-label={this.props.label} {...remainingProps}>
{this.props.children}
</Component>
);
}
}
ButtonBase.propTypes = propTypes;
ButtonBase.defaultProps = defaultProps;