* WIP - Notification Service * add snackbar provider into the main App component * feat: Notification Service * revert unmodified file * Update DicomHtmlViewport.js * update css classnames * revert toolbarRow * fix revert toolbarRow * styles adjustments and hide method * remove unecessary default options * minor fixes * fix long truncated messages * move SnackbarContext to ui project, rename, export
32 lines
754 B
JavaScript
32 lines
754 B
JavaScript
import React, { useState, useEffect } from 'react';
|
|
|
|
const SnackbarItem = ({ options, onClose }) => {
|
|
const handleClose = () => {
|
|
onClose(options.id);
|
|
};
|
|
|
|
useEffect(() => {
|
|
if (options.autoClose) {
|
|
setTimeout(() => {
|
|
handleClose();
|
|
}, options.duration);
|
|
}
|
|
}, []);
|
|
|
|
return (
|
|
<div
|
|
className={`${options.visible ? '' : 'sb-hidden'} sb-${
|
|
options.type
|
|
} sb-item`}
|
|
>
|
|
<span className="sb-closeBtn" onClick={handleClose}>
|
|
<span className="sb-closeIcon">x</span>
|
|
</span>
|
|
{options.title && <div className="sb-title">{options.title}</div>}
|
|
{options.message && <div className="sb-message">{options.message}</div>}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default SnackbarItem;
|