import React, { Fragment, useState } from 'react'; import { Transition } from '@headlessui/react'; import { CheckCircleIcon, ExclamationCircleIcon, InformationCircleIcon, ShieldExclamationIcon, } from '@heroicons/react/24/outline'; import { XMarkIcon } from '@heroicons/react/20/solid'; export interface ToasterProps { children?: any; } export interface ToastBaseProps { children?: any; type: 'success' | 'error' | 'warning' | 'info'; } export interface ToastTitleProps { children?: any; } export interface ToastContentProps { children?: any; } const Toaster = ({ children }: ToasterProps) => { return (
{children}
); }; const Title = ({ children }: ToastTitleProps) => { return

{children}

; }; const Content = ({ children }: ToastContentProps) => { return

{children}

; }; const ToastBase = ({ children, type }: ToastBaseProps) => { const [showToast, setShowToast] = useState(true); const toastTypes = { success: { icon: CheckCircleIcon, color: 'text-green-400', }, warning: { icon: ShieldExclamationIcon, color: 'text-yellow-400', }, error: { icon: ExclamationCircleIcon, color: 'text-cu-red', }, info: { icon: InformationCircleIcon, color: 'text-gray-600', }, }; return (
{React.createElement(toastTypes[type].icon, { className: `w-6 h-6 ${toastTypes[type].color}`, 'aria-hidden': 'true', })}
{children}
); }; ToastBase.displayName = 'Toast'; Title.displayName = 'Toast.Title'; Content.displayName = 'Toast.Content'; export const Toast = Object.assign(ToastBase, { Toaster, Title, Content, });