2020-02-17 17:50:29 +00:00
|
|
|
import { injectIntl, defineMessages } from 'react-intl'
|
2020-02-29 15:42:47 +00:00
|
|
|
import Button from './button'
|
2020-02-17 17:50:29 +00:00
|
|
|
import Icon from './icon'
|
2020-02-29 15:42:47 +00:00
|
|
|
import Text from './text'
|
2019-08-07 06:02:36 +01:00
|
|
|
|
|
|
|
const messages = defineMessages({
|
|
|
|
load_more: { id: 'status.load_more', defaultMessage: 'Load more' },
|
2020-02-17 17:50:29 +00:00
|
|
|
})
|
2019-08-07 06:02:36 +01:00
|
|
|
|
2020-02-24 21:56:07 +00:00
|
|
|
export default
|
|
|
|
@injectIntl
|
2019-08-07 06:02:36 +01:00
|
|
|
class LoadMore extends PureComponent {
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
onClick: PropTypes.func,
|
|
|
|
disabled: PropTypes.bool,
|
|
|
|
visible: PropTypes.bool,
|
|
|
|
maxId: PropTypes.string,
|
|
|
|
gap: PropTypes.bool,
|
|
|
|
intl: PropTypes.object.isRequired,
|
|
|
|
}
|
|
|
|
|
|
|
|
static defaultProps = {
|
|
|
|
visible: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
handleClick = () => {
|
2020-02-17 17:50:29 +00:00
|
|
|
const { gap, maxId } = this.props
|
|
|
|
this.props.onClick(gap ? maxId : undefined)
|
2019-08-07 06:02:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2020-02-17 17:50:29 +00:00
|
|
|
const { disabled, visible, gap, intl } = this.props
|
2019-08-07 06:02:36 +01:00
|
|
|
|
|
|
|
return (
|
2020-02-29 15:42:47 +00:00
|
|
|
<Button
|
|
|
|
block
|
|
|
|
radiusSmall
|
|
|
|
backgroundColor='tertiary'
|
|
|
|
color='primary'
|
2019-08-07 06:02:36 +01:00
|
|
|
disabled={disabled || !visible}
|
|
|
|
style={{ visibility: visible ? 'visible' : 'hidden' }}
|
|
|
|
onClick={this.handleClick}
|
|
|
|
aria-label={intl.formatMessage(messages.load_more)}
|
|
|
|
>
|
2020-02-29 15:42:47 +00:00
|
|
|
{
|
|
|
|
!gap &&
|
|
|
|
<Text color='inherit'>
|
|
|
|
{intl.formatMessage(messages.load_more)}
|
|
|
|
</Text>
|
|
|
|
}
|
|
|
|
{
|
|
|
|
gap &&
|
|
|
|
<Text align='center'>
|
|
|
|
<Icon id='ellipsis' />
|
|
|
|
</Text>
|
|
|
|
}
|
|
|
|
</Button>
|
2020-02-17 17:50:29 +00:00
|
|
|
)
|
2019-08-07 06:02:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|