bigbuffet-rw/app/gabsocial/components/timeline_queue_button_header.js

44 lines
1.1 KiB
JavaScript
Raw Normal View History

2020-03-27 13:59:38 -07:00
import React from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
import { shortNumberFormat } from '../utils/numbers';
import classNames from 'classnames';
export default class TimelineQueueButtonHeader extends React.PureComponent {
2020-04-14 11:44:40 -07:00
2020-03-27 13:59:38 -07:00
static propTypes = {
onClick: PropTypes.func.isRequired,
count: PropTypes.number,
itemType: PropTypes.string,
};
static defaultProps = {
count: 0,
itemType: 'item',
};
render() {
2020-03-27 13:59:38 -07:00
const { count, itemType, onClick } = this.props;
const classes = classNames('timeline-queue-header', {
2020-04-14 11:44:40 -07:00
'hidden': (count <= 0),
2020-03-27 13:59:38 -07:00
});
return (
<div className={classes}>
<a className='timeline-queue-header__btn' onClick={onClick}>
{(count > 0) && <FormattedMessage
id='timeline_queue.label'
defaultMessage='Click to see {count} new {type}'
values={{
count: shortNumberFormat(count),
2020-04-14 13:45:38 -07:00
type: count === 1 ? itemType : `${itemType}s`,
2020-03-27 13:59:38 -07:00
}}
/>}
</a>
</div>
);
}
2020-04-14 11:44:40 -07:00
2020-03-27 13:59:38 -07:00
}