accounts-ui/imports/ui/components/Button.jsx

30 lines
772 B
React
Raw Normal View History

2016-03-28 22:34:50 +02:00
import React from 'react';
import { Accounts } from 'meteor/accounts-base';
export class Button extends React.Component {
handleClick(evt) {
let { onClick, href } = this.props;
if (!href) {
evt.preventDefault();
onClick(evt);
}
}
2016-03-28 22:34:50 +02:00
render () {
const { label, href = null, type, disabled = false, className } = this.props;
2016-03-28 22:34:50 +02:00
return type == 'link' ? (
<a href={ href } className={ className } onClick={ this.handleClick.bind(this) }>{ label }</a>
2016-03-28 22:34:50 +02:00
) : (
<button className={ className }
type={type} 
disabled={ disabled }
onClick={ this.handleClick.bind(this) }>{ label }</button>
2016-03-28 22:34:50 +02:00
);
}
}
Button.propTypes = {
onClick: React.PropTypes.func
};
Accounts.ui.Button = Button;