Skip to content

Instantly share code, notes, and snippets.

@gndx
Created February 2, 2022 20:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gndx/89582bf88d4ea223bffe3784037a3e7c to your computer and use it in GitHub Desktop.
Save gndx/89582bf88d4ea223bffe3784037a3e7c to your computer and use it in GitHub Desktop.
import { XCircleIcon } from '@heroicons/react/solid';
const Alert = ({ alert, handleClose }) => {
if (alert && alert?.autoClose) {
setTimeout(() => {
handleClose();
}, 9000);
}
return (
<>
{alert?.active && (
<div x-data className="bg-indigo-100 p-5 w-full rounded mb-8">
<div className="flex space-x-3">
<div className="flex-1 leading-tight text-sm text-black font-medium">{alert.message}</div>
<button type="button">
<XCircleIcon className="w-6 h-6 text-gray-600" onClick={handleClose} />
</button>
</div>
</div>
)}
</>
);
};
export default Alert;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment