2020-02-29 15:42:47 +00:00
|
|
|
import { FormattedMessage } from 'react-intl'
|
2020-04-11 23:29:19 +01:00
|
|
|
import classNames from 'classnames/bind'
|
2020-02-29 15:42:47 +00:00
|
|
|
import { shortNumberFormat } from '../utils/numbers'
|
2020-05-15 21:31:38 +01:00
|
|
|
import { scrollTo } from '../utils/scroll_to'
|
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-04-11 23:29:19 +01:00
|
|
|
const cx = classNames.bind(_s)
|
|
|
|
|
2019-08-07 06:02:36 +01:00
|
|
|
export default class TimelineQueueButtonHeader extends PureComponent {
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
onClick: PropTypes.func.isRequired,
|
|
|
|
count: PropTypes.number,
|
|
|
|
itemType: PropTypes.string,
|
2020-04-08 02:06:59 +01:00
|
|
|
floating: PropTypes.bool,
|
2020-02-29 15:42:47 +00:00
|
|
|
}
|
2019-08-07 06:02:36 +01:00
|
|
|
|
|
|
|
static defaultProps = {
|
|
|
|
count: 0,
|
|
|
|
itemType: 'item',
|
2020-02-29 15:42:47 +00:00
|
|
|
}
|
2019-08-07 06:02:36 +01:00
|
|
|
|
2020-05-15 21:31:38 +01:00
|
|
|
handleOnClick = () => {
|
|
|
|
scrollTo(document.documentElement, 0, 500)
|
|
|
|
|
|
|
|
this.props.onClick()
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const { count, itemType } = this.props
|
2020-02-29 15:42:47 +00:00
|
|
|
|
|
|
|
const hasItems = count > 0
|
2019-08-07 06:02:36 +01:00
|
|
|
|
2020-04-11 23:29:19 +01:00
|
|
|
const classes = cx({
|
|
|
|
default: 1,
|
|
|
|
displayNone: !hasItems,
|
2020-05-15 21:29:13 +01:00
|
|
|
mtNeg26PX: 1,
|
2020-02-29 15:42:47 +00:00
|
|
|
})
|
2019-08-07 06:02:36 +01:00
|
|
|
|
|
|
|
return (
|
2020-05-15 23:44:55 +01:00
|
|
|
<div className={[_s.default, _s.pb5, _s.posSticky, _s.top120PX, _s.alignItemsCenter, _s.z3].join(' ')}>
|
2020-05-15 21:29:13 +01:00
|
|
|
<div className={classes}>
|
|
|
|
<Button
|
|
|
|
isNarrow
|
|
|
|
color='white'
|
|
|
|
backgroundColor='brand'
|
2020-05-15 21:31:38 +01:00
|
|
|
onClick={this.handleOnClick}
|
2020-05-15 21:29:13 +01:00
|
|
|
>
|
|
|
|
{
|
|
|
|
hasItems &&
|
|
|
|
<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>
|
|
|
|
}
|
|
|
|
</Button>
|
|
|
|
</div>
|
2019-08-07 06:02:36 +01:00
|
|
|
</div>
|
2020-02-29 15:42:47 +00:00
|
|
|
)
|
2019-08-07 06:02:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|