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 AlerterProps { children?: any; } export interface AlertBaseProps { children?: any; type: 'success' | 'error' | 'warning' | 'info'; } export interface AlertTitleProps { children?: any; } export interface AlertContentProps { children?: any; } const Alerter = ({ children }: AlerterProps) => { return (
{children}
); }; const Title = ({ children }: AlertTitleProps) => { return

{children}

; }; const Content = ({ children }: AlertContentProps) => { return
{children}
; }; const AlertBase = ({ children, type }: AlertBaseProps) => { const [showAlert, setShowAlert] = useState(true); const AlertTypes = { success: { icon: CheckCircleIcon, text: 'text-green-600', bg: 'bg-green-50', }, warning: { icon: ShieldExclamationIcon, text: 'text-yellow-600', bg: 'bg-yellow-50', }, error: { icon: ExclamationCircleIcon, text: 'text-cu-red-600', bg: 'bg-cu-red-50', }, info: { icon: InformationCircleIcon, text: 'text-blue-600', bg: 'bg-blue-50', }, }; return (
{React.createElement(AlertTypes[type].icon, { className: `h-5 w-5 ${AlertTypes[type].text}`, 'aria-hidden': 'true', })}
{children}
); }; AlertBase.displayName = 'Alert'; Title.displayName = 'Alert.Title'; Content.displayName = 'Alert.Content'; export const Alert = Object.assign(AlertBase, { Alerter, Title, Content, });