@bigfishtv/cockpit
Version:
34 lines (29 loc) • 813 B
JavaScript
import PropTypes from 'prop-types'
import React, { Component } from 'react'
import classnames from 'classnames'
import Icon from '../../Icon'
/**
* Think of it as a button styled differently
*/
export default class DropdownItem extends Component {
static propTypes = {
/** Text or node to display */
text: PropTypes.node,
disabled: PropTypes.bool,
onClick: PropTypes.func,
}
static defaultProps = {
text: 'Item',
disabled: false,
icon: null,
onClick: () => console.warn('no onClick event set for DropdownItem'),
}
render() {
const { icon, text, style, disabled, onClick } = this.props
return (
<li className={classnames('dropdown-menu-item', { disabled })} onClick={!disabled ? onClick : null} style={style}>
{icon && <Icon name={icon} size={18} />} {text}
</li>
)
}
}