gab-social/app/javascript/gabsocial/components/list_item.js

85 lines
1.7 KiB
JavaScript
Raw Normal View History

2020-02-21 00:57:29 +00:00
import classNames from 'classnames/bind'
2020-03-14 17:31:29 +00:00
import Button from './button'
2020-02-21 00:57:29 +00:00
import Icon from './icon'
2020-03-14 17:31:29 +00:00
import Text from './text'
2020-02-21 00:57:29 +00:00
const cx = classNames.bind(_s)
export default class ListItem extends PureComponent {
static propTypes = {
2020-03-24 04:39:12 +00:00
icon: PropTypes.string,
2020-02-21 00:57:29 +00:00
isLast: PropTypes.bool,
to: PropTypes.string,
2020-03-14 17:31:29 +00:00
href: PropTypes.string,
2020-02-21 00:57:29 +00:00
title: PropTypes.string,
2020-02-28 15:20:47 +00:00
onClick: PropTypes.func,
2020-03-14 17:31:29 +00:00
small: PropTypes.bool,
2020-03-24 04:39:12 +00:00
hideArrow: PropTypes.bool,
2020-02-21 00:57:29 +00:00
}
render() {
2020-03-24 04:39:12 +00:00
const {
title,
isLast,
to,
href,
onClick,
small,
icon,
hideArrow,
} = this.props
2020-02-21 00:57:29 +00:00
const containerClasses = cx({
default: 1,
cursorPointer: 1,
noUnderline: 1,
2020-03-14 17:31:29 +00:00
px15: !small,
py15: !small,
px10: small,
py10: small,
2020-02-21 00:57:29 +00:00
flexRow: 1,
alignItemsCenter: 1,
2020-03-14 17:31:29 +00:00
width100PC: 1,
2020-02-21 00:57:29 +00:00
backgroundSubtle_onHover: 1,
borderColorSecondary: !isLast,
borderBottom1PX: !isLast,
})
2020-03-14 17:31:29 +00:00
const textSize = small ? 'small' : 'normal'
2020-02-21 00:57:29 +00:00
return (
2020-03-14 17:31:29 +00:00
<Button
to={to}
href={href}
onClick={onClick}
className={containerClasses}
noClasses
>
2020-03-24 04:39:12 +00:00
{
!!icon &&
<Icon
id={icon}
width='10px'
height='10px'
className={[_s.mr10, _s.fillColorBlack].join(' ')}
/>
}
2020-03-14 17:31:29 +00:00
<Text color='primary' size={textSize}>
2020-02-21 00:57:29 +00:00
{title}
2020-03-14 17:31:29 +00:00
</Text>
2020-03-24 04:39:12 +00:00
{
!hideArrow &&
<Icon
id='angle-right'
width='10px'
height='10px'
className={[_s.marginLeftAuto, _s.fillColorBlack].join(' ')}
/>
}
2020-03-14 17:31:29 +00:00
</Button>
2020-02-21 00:57:29 +00:00
)
}
}