web2019/static/js/shop/options/Notification.jsx
Egor Savkin 6d6809af7f Show tooltip instead of badge by default
Signed-off-by: Egor Savkin <es@m-labs.hk>
2024-01-15 12:28:07 +08:00

31 lines
836 B
JavaScript

import {OverlayTrigger, Tooltip} from "react-bootstrap";
import React, {useEffect, useState, useRef} from "react";
import {useClickAway} from "./useClickAway";
export function Notification({id, tip, content}) {
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
>
{content}
</OverlayTrigger>
)
}