2021-08-26 08:38:16 +02:00
|
|
|
import { FC, useEffect, useState } from 'react';
|
|
|
|
import { NotificationBubbleViewProps } from './NotificationBubbleView.types';
|
|
|
|
|
|
|
|
export const NotificationBubbleView: FC<NotificationBubbleViewProps> = props =>
|
|
|
|
{
|
|
|
|
const { fadesOut = false, close = null, className = '', children = null, ...rest } = props;
|
|
|
|
const [ isFading, setIsFading ] = useState(false);
|
|
|
|
|
|
|
|
useEffect(() =>
|
|
|
|
{
|
|
|
|
if(!fadesOut) return;
|
|
|
|
|
|
|
|
const timeout = setTimeout(() =>
|
|
|
|
{
|
|
|
|
setIsFading(true);
|
|
|
|
|
|
|
|
setTimeout(() => close());
|
|
|
|
}, 8000);
|
|
|
|
|
|
|
|
return () => clearTimeout(timeout);
|
|
|
|
}, [ fadesOut, close ]);
|
|
|
|
|
|
|
|
return (
|
2021-09-16 07:27:23 +02:00
|
|
|
<div className={ ('nitro-notification-bubble rounded ' + (className || '')) } { ...rest } onClick={ close }>
|
2021-08-26 08:38:16 +02:00
|
|
|
{ children }
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|