import React from 'react'; import FontIcon from '../font_icon'; import Ripple from '../ripple'; import style from './style.menu_item'; class MenuItem extends React.Component { static propTypes = { caption: React.PropTypes.string.isRequired, className: React.PropTypes.string, disabled: React.PropTypes.bool, icon: React.PropTypes.string, ripple: React.PropTypes.bool, shortcut: React.PropTypes.string, selected: React.PropTypes.bool }; static defaultProps = { className: '', disabled: false, ripple: false, selected: false }; handleClick = (event) => { if (this.props.onClick && !this.props.disabled) { this.props.onClick(event, this); } }; handleMouseDown = (event) => { if (this.props.ripple && !this.props.disabled) { this.refs.ripple.start(event); } }; render () { let className = style.root; if (this.props.selected) className += ` ${style.selected}`; if (this.props.disabled) className += ` ${style.disabled}`; if (this.props.className) className += ` ${this.props.className}`; return (
  • { this.props.icon ? : null } {this.props.caption} { this.props.shortcut ? {this.props.shortcut} : null } { this.props.ripple ? : null }
  • ); } } export default MenuItem;