2020-08-10 22:47:39 +02:00
|
|
|
// @flow
|
|
|
|
import React from 'react';
|
2020-08-11 22:32:03 +02:00
|
|
|
import classnames from 'classnames';
|
2021-07-20 04:02:59 +02:00
|
|
|
import { ENABLE_UI_NOTIFICATIONS } from 'config';
|
2022-03-22 19:03:39 +01:00
|
|
|
import { buildUnseenCountStr } from 'util/notifications';
|
2020-08-10 22:47:39 +02:00
|
|
|
|
|
|
|
type Props = {
|
2021-03-16 02:42:49 +01:00
|
|
|
unseenCount: number,
|
2020-08-11 22:32:03 +02:00
|
|
|
inline: boolean,
|
|
|
|
user: ?User,
|
2020-08-10 22:47:39 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
export default function NotificationHeaderButton(props: Props) {
|
2021-03-16 02:42:49 +01:00
|
|
|
const { unseenCount, inline = false, user } = props;
|
2021-07-20 04:02:59 +02:00
|
|
|
const notificationsEnabled = ENABLE_UI_NOTIFICATIONS || (user && user.experimental_ui);
|
2020-08-10 22:47:39 +02:00
|
|
|
|
2021-03-16 02:42:49 +01:00
|
|
|
if (unseenCount === 0 || !notificationsEnabled) {
|
2020-08-10 22:47:39 +02:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2020-08-11 22:32:03 +02:00
|
|
|
<span
|
|
|
|
className={classnames('notification__bubble', {
|
|
|
|
'notification__bubble--inline': inline,
|
|
|
|
})}
|
|
|
|
>
|
2021-01-11 16:43:39 +01:00
|
|
|
<span
|
|
|
|
className={classnames('notification__count', {
|
2021-03-16 02:42:49 +01:00
|
|
|
'notification__bubble--small': unseenCount > 9,
|
2021-01-11 16:43:39 +01:00
|
|
|
})}
|
|
|
|
>
|
2022-03-22 19:03:39 +01:00
|
|
|
{buildUnseenCountStr(unseenCount)}
|
2021-01-11 16:43:39 +01:00
|
|
|
</span>
|
2020-08-10 22:47:39 +02:00
|
|
|
</span>
|
|
|
|
);
|
|
|
|
}
|