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

63 lines
1.4 KiB
JavaScript
Raw Normal View History

2020-02-29 10:42:47 -05:00
import { FormattedMessage } from 'react-intl'
2020-04-11 18:29:19 -04:00
import classNames from 'classnames/bind'
2020-02-29 10:42:47 -05:00
import { shortNumberFormat } from '../utils/numbers'
import Button from './button'
import Text from './text'
2020-04-11 18:29:19 -04:00
const cx = classNames.bind(_s)
export default class TimelineQueueButtonHeader extends PureComponent {
static propTypes = {
onClick: PropTypes.func.isRequired,
count: PropTypes.number,
itemType: PropTypes.string,
2020-04-07 21:06:59 -04:00
floating: PropTypes.bool,
2020-02-29 10:42:47 -05:00
}
static defaultProps = {
count: 0,
itemType: 'item',
2020-02-29 10:42:47 -05:00
}
render () {
2020-02-29 10:42:47 -05:00
const { count, itemType, onClick } = this.props
const hasItems = count > 0
2020-04-11 18:29:19 -04:00
const classes = cx({
default: 1,
2020-04-23 02:13:29 -04:00
posFixed: 1,
2020-04-11 18:29:19 -04:00
displayNone: !hasItems,
top80PX: 1,
z4: 1,
center160PX: 1,
2020-02-29 10:42:47 -05:00
})
return (
<div className={classes}>
2020-04-11 18:29:19 -04:00
<Button
2020-04-23 02:13:29 -04:00
isNarrow
2020-04-11 18:29:19 -04:00
color='white'
backgroundColor='brand'
onClick={onClick}
>
{
hasItems &&
2020-04-11 18:29:19 -04:00
<Text color='inherit' size='small'>
<FormattedMessage
id='timeline_queue.label'
defaultMessage='{count} new {type}'
values={{
count: shortNumberFormat(count),
type: count === 1 ? itemType : `${itemType}s`,
}}
/>
</Text>
}
2020-04-11 18:29:19 -04:00
</Button>
</div>
2020-02-29 10:42:47 -05:00
)
}
}