import React from 'react'
import PropTypes from 'prop-types'
import BEMModule from 'utils/bem'
import styles from './styles.scss'

const bem = new BEMModule(styles)

const MenuItem = ({item, isSelected, nodeRef, onClick}) => {
    const classes = bem.classNames('c-drop-menu__menu-item', {
        danger: item.isDanger,
        selected: isSelected,
    })

    const click = () => onClick(item)

    return (
        <div
            className={classes}
            ref={nodeRef}
            onClick={click}
            title={item.description}
        >
            {item.label}
        </div>
    )
}

MenuItem.propTypes = {
    item: PropTypes.object.isRequired,
    isSelected: PropTypes.bool,
    nodeRef: PropTypes.func,
    onClick: PropTypes.func,
}

export default MenuItem
