react-font-style
Version:
React font style editor
32 lines (27 loc) • 864 B
JavaScript
import React, {Component} from 'react';
import cx from 'classnames';
import styles from './Button.css';
export default class Button extends Component {
constructor(props) {
super(props);
}
render() {
let {props} = this;
let {className, isDisabled, focusOnClick, formSubmit, ...otherProps} = props;
className = cx(className, styles.root);
let onMouseDown = (focusOnClick === false) ? this._onMouseDownPreventDefault : props.onMouseDown;
let type = formSubmit ? 'submit' : 'button';
return (
<button type={type} {...otherProps} onMouseDown={onMouseDown} className={className} disabled={isDisabled}>
{props.children}
</button>
);
}
_onMouseDownPreventDefault(event) {
event.preventDefault();
let {onMouseDown} = this.props;
if (onMouseDown != null) {
onMouseDown(event);
}
}
}