2024-01-03 17:34:26 +08:00
|
|
|
import {OverlayTrigger, Tooltip} from "react-bootstrap";
|
|
|
|
import React, {useState} from "react";
|
|
|
|
|
|
|
|
export function Notification({id, tip, content}) {
|
|
|
|
const [show, setShow] = useState(true);
|
2024-01-05 13:15:43 +08:00
|
|
|
const onClickHandler = (event) => {
|
|
|
|
// prevent removing badge on touchables
|
|
|
|
if (!event.target.classList.contains("options-badge"))
|
|
|
|
setShow(false);
|
|
|
|
};
|
|
|
|
|
2024-01-03 17:34:26 +08:00
|
|
|
return (
|
2024-01-05 13:15:43 +08:00
|
|
|
<div className="options-notification" onClick={onClickHandler}>
|
2024-01-03 17:34:26 +08:00
|
|
|
{content}
|
2024-01-05 13:15:43 +08:00
|
|
|
{show ? <OverlayTrigger
|
2024-01-03 17:34:26 +08:00
|
|
|
placement="auto"
|
|
|
|
trigger={['click', 'hover', 'focus']}
|
2024-01-05 13:15:43 +08:00
|
|
|
style={{display: 'inline'}}
|
2024-01-03 17:34:26 +08:00
|
|
|
overlay={<Tooltip id={id}>{tip}</Tooltip>}
|
|
|
|
>
|
2024-01-05 13:15:43 +08:00
|
|
|
<span className="options-badge"></span>
|
|
|
|
</OverlayTrigger> : null}
|
|
|
|
|
2024-01-03 17:34:26 +08:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|