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

26 lines
692 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 {
2016-04-02 12:59:50 +02:00
shouldComponentUpdate(nextProps) {
return this.props.href == nextProps.href;
}
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
) : (
<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;