import React from 'react' import PropTypes from 'prop-types' import classNames from 'classnames/bind' import Button from './button' import Icon from './icon' import Image from './image' import Text from './text' const cx = classNames.bind(_s) class ListItem extends React.PureComponent { handleOnClick = (e) => { if (!!this.props.onClick) { this.props.onClick(e) } } render() { const { title, isLast, to, href, onClick, actionIcon, size, icon, image, hideArrow, isHidden, subtitle, isActive, } = this.props if (!title) { return (
) } if (isHidden) { return ( {title} ) } const small = size === 'small' const large = size === 'large' const textSize = small ? 'normal' : large ? 'large' : 'normal' const iconSize = large ? '14px' : '10px' const imageSize = large ? '22px' : '18px' const showActive = isActive !== undefined const containerClasses = cx({ default: 1, cursorPointer: 1, noUnderline: 1, px15: !small, py15: !small, px10: small, py10: small, flexRow: 1, alignItemsCenter: 1, width100PC: 1, outlineNone: 1, bgTransparent: 1, bgSubtle_onHover: 1, borderColorSecondary: !isLast, borderBottom1PX: !isLast, }) const iconClasses = cx({ mr10: !large, mr15: large, colorPrimary: !!icon, circle: !icon && !!image, }) const textContainerClasses = cx({ default: 1, pr5: 1, maxWidth100PC42PX: !hideArrow || showActive, }) return ( ) } } ListItem.propTypes = { icon: PropTypes.string, image: PropTypes.string, isLast: PropTypes.bool, isHidden: PropTypes.bool, to: PropTypes.string, href: PropTypes.string, title: PropTypes.string, subtitle: PropTypes.string, isActive: PropTypes.bool, actionIcon: PropTypes.bool, onClick: PropTypes.func, size: PropTypes.oneOf([ 'small', 'large', ]), hideArrow: PropTypes.bool, } export default ListItem