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

51 lines
1.2 KiB
JavaScript
Raw Normal View History

2020-02-29 15:42:47 +00:00
import { FormattedMessage } from 'react-intl'
import classNames from 'classnames'
import { shortNumberFormat } from '../utils/numbers'
import Button from './button'
import Text from './text'
export default class TimelineQueueButtonHeader extends PureComponent {
static propTypes = {
onClick: PropTypes.func.isRequired,
count: PropTypes.number,
itemType: PropTypes.string,
2020-02-29 15:42:47 +00:00
floating: PropTypes.bool
}
static defaultProps = {
count: 0,
itemType: 'item',
2020-02-29 15:42:47 +00:00
}
render () {
2020-02-29 15:42:47 +00:00
const { count, itemType, onClick } = this.props
const hasItems = count > 0
2020-02-29 15:42:47 +00:00
// : todo :
const classes = classNames('timeline-queue-header', {
'timeline-queue-header--extended': hasItems,
2020-02-29 15:42:47 +00:00
})
return (
<div className={classes}>
<a className='timeline-queue-header__btn' onClick={onClick}>
{
hasItems &&
<FormattedMessage
id='timeline_queue.label'
defaultMessage='{count} new {type}'
values={{
count: shortNumberFormat(count),
type: count === 1 ? itemType : `${itemType}s`,
}}
/>
}
</a>
</div>
2020-02-29 15:42:47 +00:00
)
}
}