2020-08-17 21:07:16 +01:00
|
|
|
import React from 'react'
|
2020-08-17 21:59:29 +01:00
|
|
|
import PropTypes from 'prop-types'
|
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'
|
|
|
|
import Text from './text'
|
2019-08-07 06:02:36 +01:00
|
|
|
|
2020-08-17 21:07:16 +01:00
|
|
|
class LoadMore extends React.PureComponent {
|
2019-08-07 06:02:36 +01:00
|
|
|
|
2020-04-28 06:33:58 +01:00
|
|
|
handleClick = (e) => {
|
2020-05-02 07:25:55 +01:00
|
|
|
this.props.onClick(e)
|
2019-08-07 06:02:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2020-04-28 06:33:58 +01:00
|
|
|
const {
|
|
|
|
disabled,
|
|
|
|
visible,
|
|
|
|
intl,
|
|
|
|
} = this.props
|
2019-08-07 06:02:36 +01:00
|
|
|
|
2020-05-15 06:34:30 +01:00
|
|
|
if (!visible || disabled) return null
|
|
|
|
|
2019-08-07 06:02:36 +01:00
|
|
|
return (
|
2020-08-18 21:49:11 +01:00
|
|
|
<div className={[_s.d, _s.py15, _s.px10].join(' ')}>
|
2020-04-17 06:35:46 +01:00
|
|
|
<Button
|
2020-04-23 07:13:29 +01:00
|
|
|
isBlock
|
2020-04-17 06:35:46 +01:00
|
|
|
radiusSmall
|
|
|
|
backgroundColor='tertiary'
|
|
|
|
color='primary'
|
|
|
|
disabled={disabled || !visible}
|
2020-04-28 06:33:58 +01:00
|
|
|
style={{
|
|
|
|
visibility: visible ? 'visible' : 'hidden',
|
|
|
|
}}
|
2020-04-17 06:35:46 +01:00
|
|
|
onClick={this.handleClick}
|
|
|
|
aria-label={intl.formatMessage(messages.load_more)}
|
|
|
|
>
|
2020-11-09 07:36:33 +00:00
|
|
|
<Text color='inherit' align='center' weight='medium' className={_s.py5}>
|
2020-04-28 06:33:58 +01:00
|
|
|
{intl.formatMessage(messages.load_more)}
|
|
|
|
</Text>
|
2020-04-17 06:35:46 +01:00
|
|
|
</Button>
|
|
|
|
</div>
|
2020-02-17 17:50:29 +00:00
|
|
|
)
|
2019-08-07 06:02:36 +01:00
|
|
|
}
|
|
|
|
|
2020-08-18 01:57:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
const messages = defineMessages({
|
|
|
|
load_more: { id: 'status.load_more', defaultMessage: 'Load more' },
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
LoadMore.propTypes = {
|
|
|
|
onClick: PropTypes.func,
|
|
|
|
disabled: PropTypes.bool,
|
|
|
|
visible: PropTypes.bool,
|
|
|
|
intl: PropTypes.object.isRequired,
|
|
|
|
}
|
|
|
|
|
|
|
|
LoadMore.defaultProps = {
|
|
|
|
visible: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
export default injectIntl(LoadMore)
|