lbry-desktop/ui/component/notificationBubble/view.jsx

37 lines
897 B
React
Raw Normal View History

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';
import { buildUnseenCountStr } from 'util/notifications';
2020-08-10 22:47:39 +02:00
type Props = {
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 NotificationBubble(props: Props) {
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
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,
})}
>
<span
className={classnames('notification__count', {
'notification__bubble--small': unseenCount > 9,
})}
>
{buildUnseenCountStr(unseenCount)}
</span>
2020-08-10 22:47:39 +02:00
</span>
);
}