Updated ListItem to have image and customizable right action icon

• Updated:
- ListItem to have image
- ListItem to have customizable right action icon
This commit is contained in:
mgabdev 2020-07-21 16:49:54 -05:00
parent 87f85131b7
commit 4a467278ea

View File

@ -2,6 +2,7 @@ import { Fragment } from 'react'
import classNames from 'classnames/bind' import classNames from 'classnames/bind'
import Button from './button' import Button from './button'
import Icon from './icon' import Icon from './icon'
import Image from './image'
import Text from './text' import Text from './text'
const cx = classNames.bind(_s) const cx = classNames.bind(_s)
@ -10,6 +11,7 @@ export default class ListItem extends PureComponent {
static propTypes = { static propTypes = {
icon: PropTypes.string, icon: PropTypes.string,
image: PropTypes.string,
isLast: PropTypes.bool, isLast: PropTypes.bool,
isHidden: PropTypes.bool, isHidden: PropTypes.bool,
to: PropTypes.string, to: PropTypes.string,
@ -17,6 +19,7 @@ export default class ListItem extends PureComponent {
title: PropTypes.string, title: PropTypes.string,
subtitle: PropTypes.string, subtitle: PropTypes.string,
isActive: PropTypes.bool, isActive: PropTypes.bool,
actionIcon: PropTypes.bool,
onClick: PropTypes.func, onClick: PropTypes.func,
size: PropTypes.oneOf([ size: PropTypes.oneOf([
'small', 'small',
@ -32,8 +35,10 @@ export default class ListItem extends PureComponent {
to, to,
href, href,
onClick, onClick,
actionIcon,
size, size,
icon, icon,
image,
hideArrow, hideArrow,
isHidden, isHidden,
subtitle, subtitle,
@ -59,6 +64,7 @@ export default class ListItem extends PureComponent {
const textSize = small ? 'small' : large ? 'large' : 'normal' const textSize = small ? 'small' : large ? 'large' : 'normal'
const iconSize = large ? '14px' : '10px' const iconSize = large ? '14px' : '10px'
const imageSize = large ? '22px' : '18px'
const showActive = isActive !== undefined const showActive = isActive !== undefined
const containerClasses = cx({ const containerClasses = cx({
@ -82,7 +88,8 @@ export default class ListItem extends PureComponent {
const iconClasses = cx({ const iconClasses = cx({
mr10: !large, mr10: !large,
mr15: large, mr15: large,
fillPrimary: 1, fillPrimary: !!icon,
circle: !icon && !!image,
}) })
const textContainerClasses = cx({ const textContainerClasses = cx({
@ -100,6 +107,16 @@ export default class ListItem extends PureComponent {
noClasses noClasses
> >
{
!!image &&
<Image
src={image}
height={imageSize}
width={imageSize}
className={iconClasses}
/>
}
{ {
!!icon && !!icon &&
<Icon <Icon
@ -125,7 +142,7 @@ export default class ListItem extends PureComponent {
{ {
!hideArrow && !hideArrow &&
<Icon <Icon
id='angle-right' id={!!actionIcon ? actionIcon : 'angle-right'}
size='10px' size='10px'
className={[_s.mlAuto, _s.fillSecondary, _s.flexShrink1].join(' ')} className={[_s.mlAuto, _s.fillSecondary, _s.flexShrink1].join(' ')}
/> />