2016-03-28 22:34:50 +02:00
|
|
|
|
import React from 'react';
|
|
|
|
|
import { Accounts } from 'meteor/accounts-base';
|
|
|
|
|
|
|
|
|
|
export class Button extends React.Component {
|
2016-04-02 12:59:50 +02:00
|
|
|
|
shouldComponentUpdate(nextProps) {
|
|
|
|
|
return this.props.href == nextProps.href;
|
2016-03-31 19:29:06 +02:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-28 22:34:50 +02:00
|
|
|
|
render () {
|
2016-04-02 12:59:50 +02:00
|
|
|
|
const { label, href = null, type, disabled = false, className, onClick } = this.props;
|
2016-03-28 22:34:50 +02:00
|
|
|
|
return type == 'link' ? (
|
2016-04-02 12:59:50 +02:00
|
|
|
|
<a href={ href } className={ className } onClick={ onClick }>{ label }</a>
|
2016-03-28 22:34:50 +02:00
|
|
|
|
) : (
|
2016-03-31 19:29:06 +02:00
|
|
|
|
<button className={ className }
|
|
|
|
|
type={type}
|
|
|
|
|
disabled={ disabled }
|
2016-04-02 12:59:50 +02:00
|
|
|
|
onClick={ onClick }>{ label }</button>
|
2016-03-28 22:34:50 +02:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Button.propTypes = {
|
|
|
|
|
onClick: React.PropTypes.func
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Accounts.ui.Button = Button;
|