diff options
Diffstat (limited to 'src/react/PopupMenuItem.js')
-rw-r--r-- | src/react/PopupMenuItem.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/react/PopupMenuItem.js b/src/react/PopupMenuItem.js new file mode 100644 index 0000000..98e3f49 --- /dev/null +++ b/src/react/PopupMenuItem.js @@ -0,0 +1,34 @@ +import React from 'react'; +import PropTypes from 'prop-types'; + +class PopupMenuItem extends React.Component { + render() { + const {itemId, value, onClick, selected, disabled} = this.props; + const additionalClasses = selected ? 'selected' : disabled ? 'disabled' : ''; + return ( + <li + className={`sdc-menu-item ${additionalClasses}`} + onClick={event => { + event.stopPropagation(); + onClick && !disabled && onClick(itemId); + }}> + {value} + </li> + ); + } +} + +PopupMenuItem.propTypes = { + itemId: PropTypes.any, + value: PropTypes.any, + selected: PropTypes.bool, + onClick: PropTypes.func, + disabled: PropTypes.bool +}; + +PopupMenuItem.defaultProps = { + selected: false, + disabled: false +}; + +export default PopupMenuItem; |