forked from M-Labs/web2019
30 lines
817 B
JavaScript
30 lines
817 B
JavaScript
import {OverlayTrigger, Tooltip} from "react-bootstrap";
|
|
import React, {useEffect, useState} from "react";
|
|
|
|
export function Notification({id, tip, content, sideMenuIsOpen}) {
|
|
const [show, setShow] = useState(false);
|
|
|
|
useEffect(() => {
|
|
setTimeout(() => {
|
|
setShow(true)
|
|
}, 100);
|
|
|
|
setTimeout(() => {
|
|
setShow(false)
|
|
}, 5000);
|
|
}, []);
|
|
|
|
return (
|
|
<OverlayTrigger
|
|
placement="top"
|
|
trigger={["click", "hover"]}
|
|
style={{display: 'inline'}}
|
|
show={show}
|
|
onToggle={() => setShow(false)}
|
|
overlay={<Tooltip id={id}>{tip}</Tooltip>}
|
|
rootClose={!sideMenuIsOpen}
|
|
>
|
|
{content}
|
|
</OverlayTrigger>
|
|
)
|
|
} |