You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.2 KiB
53 lines
1.2 KiB
4 years ago
|
import React, { PureComponent } from 'react';
|
||
|
import classnames from 'classnames';
|
||
|
import PropTypes from 'prop-types';
|
||
5 years ago
|
|
||
|
export default class MultipleNotifications extends PureComponent {
|
||
5 years ago
|
static defaultProps = {
|
||
|
children: [],
|
||
|
classNames: [],
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
5 years ago
|
static propTypes = {
|
||
5 years ago
|
children: PropTypes.array,
|
||
5 years ago
|
classNames: PropTypes.array,
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
|
state = {
|
||
|
showAll: false,
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
4 years ago
|
render() {
|
||
4 years ago
|
const { showAll } = this.state;
|
||
|
const { children, classNames } = this.props;
|
||
5 years ago
|
|
||
4 years ago
|
const childrenToRender = children.filter(Boolean);
|
||
5 years ago
|
if (childrenToRender.length === 0) {
|
||
4 years ago
|
return null;
|
||
5 years ago
|
}
|
||
|
|
||
|
return (
|
||
5 years ago
|
<div
|
||
5 years ago
|
className={classnames(...classNames, {
|
||
|
'home-notification-wrapper--show-all': showAll,
|
||
|
'home-notification-wrapper--show-first': !showAll,
|
||
|
})}
|
||
5 years ago
|
>
|
||
4 years ago
|
{childrenToRender}
|
||
5 years ago
|
<div
|
||
|
className="home-notification-wrapper__i-container"
|
||
|
onClick={() => this.setState({ showAll: !showAll })}
|
||
|
>
|
||
5 years ago
|
{childrenToRender.length > 1 ? (
|
||
|
<i
|
||
|
className={classnames('fa fa-sm fa-sort-amount-asc', {
|
||
4 years ago
|
flipped: !showAll,
|
||
5 years ago
|
})}
|
||
|
/>
|
||
|
) : null}
|
||
5 years ago
|
</div>
|
||
5 years ago
|
</div>
|
||
4 years ago
|
);
|
||
5 years ago
|
}
|
||
|
}
|