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

46 lines
1.1 KiB
JavaScript
Raw Normal View History

2020-02-17 17:50:29 +00:00
import { injectIntl, defineMessages } from 'react-intl'
import Icon from './icon'
const messages = defineMessages({
load_more: { id: 'status.load_more', defaultMessage: 'Load more' },
2020-02-17 17:50:29 +00:00
})
export default @injectIntl
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)
}
render() {
2020-02-17 17:50:29 +00:00
const { disabled, visible, gap, intl } = this.props
return (
<button
2020-02-17 17:50:29 +00:00
className={[styles.default].join(' ')}
disabled={disabled || !visible}
style={{ visibility: visible ? 'visible' : 'hidden' }}
onClick={this.handleClick}
aria-label={intl.formatMessage(messages.load_more)}
>
2019-08-13 16:54:29 +01:00
{!gap && intl.formatMessage(messages.load_more)}
{gap && <Icon id='ellipsis-h' />}
</button>
2020-02-17 17:50:29 +00:00
)
}
}