insomnia/app/ui/components/base/dropdown/DropdownItem.js
Gregory Schier 314daf155e Verify Before Syncing (#98)
* Added an UNSET sync mode

* Fixed tests

* Remove sync logs and adjusted dropdown

* Fixed duplication kve bug

* Added sync config modal

* AUtobind

* Autobind working

* Hot loading works again

* Remove express

* Fixed tests

* Fix one thing

* Fixed some hmr-related bugs
2017-03-02 17:44:07 -08:00

65 lines
1.3 KiB
JavaScript

import React, {PureComponent, PropTypes} from 'react';
import autobind from 'autobind-decorator';
import classnames from 'classnames';
@autobind
class DropdownItem extends PureComponent {
constructor (props) {
super(props);
}
_handleClick (e) {
const {stayOpenAfterClick, onClick, disabled} = this.props;
if (stayOpenAfterClick) {
e.stopPropagation();
}
if (!onClick || disabled) {
return;
}
if (this.props.hasOwnProperty('value')) {
onClick(this.props.value, e);
} else {
onClick(e);
}
}
render () {
const {
buttonClass,
children,
className,
onClick, // Don't want this in ...props
stayOpenAfterClick, // Don't want this in ...props
...props
} = this.props;
const inner = (
<div className={classnames('dropdown__inner', className)}>
<div className="dropdown__text">{children}</div>
</div>
);
const buttonProps = {
type: 'button',
onClick: this._handleClick,
...props
};
const button = React.createElement(buttonClass || 'button', buttonProps, inner);
return (
<li>{button}</li>
)
}
}
DropdownItem.propTypes = {
buttonClass: PropTypes.any,
stayOpenAfterClick: PropTypes.bool,
value: PropTypes.any,
};
export default DropdownItem;