2019-08-02 22:31:26 +02:00
|
|
|
import React, { PureComponent } from 'react'
|
|
|
|
import classnames from 'classnames'
|
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
|
|
|
|
export default class MultipleNotifications extends PureComponent {
|
2019-11-17 00:13:46 +01:00
|
|
|
static defaultProps = {
|
|
|
|
children: [],
|
|
|
|
classNames: [],
|
|
|
|
}
|
|
|
|
|
2019-08-02 22:31:26 +02:00
|
|
|
static propTypes = {
|
2019-11-10 07:30:07 +01:00
|
|
|
children: PropTypes.array,
|
2019-08-02 22:31:26 +02:00
|
|
|
classNames: PropTypes.array,
|
|
|
|
}
|
|
|
|
|
|
|
|
state = {
|
|
|
|
showAll: false,
|
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
|
|
|
const { showAll } = this.state
|
2019-11-17 00:13:46 +01:00
|
|
|
const { children, classNames } = this.props
|
2019-08-02 22:31:26 +02:00
|
|
|
|
2020-02-15 21:34:12 +01:00
|
|
|
const childrenToRender = children.filter((child) => child)
|
2019-11-10 07:30:07 +01:00
|
|
|
if (childrenToRender.length === 0) {
|
2019-08-06 21:09:40 +02:00
|
|
|
return null
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2019-08-02 22:31:26 +02:00
|
|
|
<div
|
2019-08-06 21:09:40 +02:00
|
|
|
className={classnames(...classNames, {
|
|
|
|
'home-notification-wrapper--show-all': showAll,
|
|
|
|
'home-notification-wrapper--show-first': !showAll,
|
|
|
|
})}
|
2019-08-02 22:31:26 +02:00
|
|
|
>
|
2019-11-10 07:30:07 +01:00
|
|
|
{ childrenToRender }
|
2019-08-06 21:09:40 +02:00
|
|
|
<div
|
|
|
|
className="home-notification-wrapper__i-container"
|
|
|
|
onClick={() => this.setState({ showAll: !showAll })}
|
|
|
|
>
|
2019-12-03 17:35:44 +01:00
|
|
|
{childrenToRender.length > 1 ? (
|
|
|
|
<i
|
|
|
|
className={classnames('fa fa-sm fa-sort-amount-asc', {
|
|
|
|
'flipped': !showAll,
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
) : null}
|
2019-08-06 21:09:40 +02:00
|
|
|
</div>
|
2019-08-02 22:31:26 +02:00
|
|
|
</div>
|
2019-08-06 21:09:40 +02:00
|
|
|
)
|
2019-08-02 22:31:26 +02:00
|
|
|
}
|
|
|
|
}
|