Updated ListItem design for new line, subtitle, isActive
• Updated: - ListItem design for new line, subtitle, isActive
This commit is contained in:
parent
f4d95b5a17
commit
4fbd606a44
@ -7,6 +7,7 @@ import Text from './text'
|
|||||||
const cx = classNames.bind(_s)
|
const cx = classNames.bind(_s)
|
||||||
|
|
||||||
export default class ListItem extends PureComponent {
|
export default class ListItem extends PureComponent {
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
icon: PropTypes.string,
|
icon: PropTypes.string,
|
||||||
isLast: PropTypes.bool,
|
isLast: PropTypes.bool,
|
||||||
@ -14,9 +15,12 @@ export default class ListItem extends PureComponent {
|
|||||||
to: PropTypes.string,
|
to: PropTypes.string,
|
||||||
href: PropTypes.string,
|
href: PropTypes.string,
|
||||||
title: PropTypes.string,
|
title: PropTypes.string,
|
||||||
|
subtitle: PropTypes.string,
|
||||||
|
isActive: PropTypes.bool,
|
||||||
onClick: PropTypes.func,
|
onClick: PropTypes.func,
|
||||||
size: PropTypes.oneOf([
|
size: PropTypes.oneOf([
|
||||||
'small', 'large'
|
'small',
|
||||||
|
'large',
|
||||||
]),
|
]),
|
||||||
hideArrow: PropTypes.bool,
|
hideArrow: PropTypes.bool,
|
||||||
}
|
}
|
||||||
@ -32,8 +36,16 @@ export default class ListItem extends PureComponent {
|
|||||||
icon,
|
icon,
|
||||||
hideArrow,
|
hideArrow,
|
||||||
isHidden,
|
isHidden,
|
||||||
|
subtitle,
|
||||||
|
isActive,
|
||||||
} = this.props
|
} = this.props
|
||||||
|
|
||||||
|
if (!title) {
|
||||||
|
return (
|
||||||
|
<div className={[_s.default, _s.bgSecondary, _s.width100PC, _s.height4PX].join(' ')} />
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
if (isHidden) {
|
if (isHidden) {
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
@ -45,6 +57,10 @@ export default class ListItem extends PureComponent {
|
|||||||
const small = size === 'small'
|
const small = size === 'small'
|
||||||
const large = size === 'large'
|
const large = size === 'large'
|
||||||
|
|
||||||
|
const textSize = small ? 'small' : large ? 'large' : 'normal'
|
||||||
|
const iconSize = large ? '14px' : '10px'
|
||||||
|
const showActive = isActive !== undefined
|
||||||
|
|
||||||
const containerClasses = cx({
|
const containerClasses = cx({
|
||||||
default: 1,
|
default: 1,
|
||||||
cursorPointer: 1,
|
cursorPointer: 1,
|
||||||
@ -69,8 +85,11 @@ export default class ListItem extends PureComponent {
|
|||||||
fillPrimary: 1,
|
fillPrimary: 1,
|
||||||
})
|
})
|
||||||
|
|
||||||
const textSize = small ? 'small' : large ? 'large' : 'normal'
|
const textContainerClasses = cx({
|
||||||
const iconSize = large ? '14px' : '10px'
|
default: 1,
|
||||||
|
pr5: 1,
|
||||||
|
maxWidth100PC42PX: !hideArrow || showActive,
|
||||||
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Button
|
<Button
|
||||||
@ -89,10 +108,19 @@ export default class ListItem extends PureComponent {
|
|||||||
className={iconClasses}
|
className={iconClasses}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<div className={textContainerClasses}>
|
||||||
|
<Text color='primary' weight={!!subtitle ? 'bold' : 'normal'} size={textSize} className={[_s.overflowHidden, _s.flexNormal, _s.textOverflowEllipsis].join(' ')}>
|
||||||
|
{title}
|
||||||
|
</Text>
|
||||||
|
|
||||||
<Text color='primary' size={textSize} className={[_s.overflowHidden, _s.flexNormal, _s.pr5, _s.textOverflowEllipsis].join(' ')}>
|
{
|
||||||
{title}
|
!!subtitle &&
|
||||||
</Text>
|
<Text color='primary' size='small' className={[_s.overflowHidden, _s.flexNormal, _s.mt5].join(' ')}>
|
||||||
|
{subtitle}
|
||||||
|
</Text>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
{
|
{
|
||||||
!hideArrow &&
|
!hideArrow &&
|
||||||
@ -102,7 +130,17 @@ export default class ListItem extends PureComponent {
|
|||||||
className={[_s.mlAuto, _s.fillSecondary, _s.flexShrink1].join(' ')}
|
className={[_s.mlAuto, _s.fillSecondary, _s.flexShrink1].join(' ')}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
!!showActive &&
|
||||||
|
<input
|
||||||
|
type='radio'
|
||||||
|
checked={isActive}
|
||||||
|
className={[_s.mlAuto, _s.flexShrink1].join(' ')}
|
||||||
|
/>
|
||||||
|
}
|
||||||
</Button>
|
</Button>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user