2021-02-04 19:15:23 +01:00
|
|
|
import React, { PureComponent } from 'react';
|
|
|
|
import classnames from 'classnames';
|
|
|
|
import PropTypes from 'prop-types';
|
2019-08-02 22:31:26 +02:00
|
|
|
|
|
|
|
export default class MultipleNotifications extends PureComponent {
|
2019-11-17 00:13:46 +01:00
|
|
|
static defaultProps = {
|
|
|
|
children: [],
|
|
|
|
classNames: [],
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-11-17 00:13:46 +01:00
|
|
|
|
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,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-08-02 22:31:26 +02:00
|
|
|
|
|
|
|
state = {
|
|
|
|
showAll: false,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-08-02 22:31:26 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
render() {
|
2021-02-04 19:15:23 +01:00
|
|
|
const { showAll } = this.state;
|
|
|
|
const { children, classNames } = this.props;
|
2019-08-02 22:31:26 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
const childrenToRender = children.filter(Boolean);
|
2019-11-10 07:30:07 +01:00
|
|
|
if (childrenToRender.length === 0) {
|
2021-02-04 19:15:23 +01:00
|
|
|
return null;
|
2019-08-06 21:09:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
>
|
2020-11-03 00:41:28 +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', {
|
2020-11-03 00:41:28 +01:00
|
|
|
flipped: !showAll,
|
2019-12-03 17:35:44 +01:00
|
|
|
})}
|
|
|
|
/>
|
|
|
|
) : null}
|
2019-08-06 21:09:40 +02:00
|
|
|
</div>
|
2019-08-02 22:31:26 +02:00
|
|
|
</div>
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2019-08-02 22:31:26 +02:00
|
|
|
}
|
|
|
|
}
|