mango-v4-ui/components/shared/InlineNotification.tsx

74 lines
2.0 KiB
TypeScript
Raw Normal View History

2022-12-19 16:08:46 -08:00
import { FunctionComponent, ReactElement } from 'react'
2022-07-20 21:50:56 -07:00
import {
CheckCircleIcon,
ExclamationCircleIcon,
2022-09-06 21:36:35 -07:00
ExclamationTriangleIcon,
2022-07-20 21:50:56 -07:00
InformationCircleIcon,
2022-09-06 21:36:35 -07:00
} from '@heroicons/react/20/solid'
2022-07-20 21:50:56 -07:00
interface InlineNotificationProps {
2022-12-19 16:08:46 -08:00
desc?: string | ReactElement
title?: string | ReactElement
2022-07-20 21:50:56 -07:00
type: 'error' | 'info' | 'success' | 'warning'
2022-08-25 20:46:23 -07:00
hideBorder?: boolean
hidePadding?: boolean
2022-07-20 21:50:56 -07:00
}
const InlineNotification: FunctionComponent<InlineNotificationProps> = ({
desc,
title,
type,
2022-08-25 20:46:23 -07:00
hideBorder,
hidePadding,
2023-04-25 05:41:23 -07:00
}) => {
const iconClasses = `mr-1.5 ${
hidePadding ? 'h-4 w-4' : 'h-5 w-5'
} flex-shrink-0`
return (
<div
className={`${
!hideBorder
? `border text-th-fgd-3 ${
type === 'error'
? 'border-th-error'
: type === 'success'
? 'border-th-success'
: type === 'info'
? 'border-th-bkg-4'
: 'border-th-warning'
}`
: type === 'error'
? 'text-th-error'
: type === 'success'
? 'text-th-success'
: type === 'info'
? 'text-th-bkg-4'
: 'text-th-warning'
} flex items-center rounded-md ${!hidePadding ? 'p-2' : ''}`}
>
{type === 'error' ? (
<ExclamationCircleIcon className={`${iconClasses} text-th-error`} />
) : null}
{type === 'success' ? (
<CheckCircleIcon className={`${iconClasses} text-th-success`} />
) : null}
{type === 'warning' ? (
<ExclamationTriangleIcon className={`${iconClasses} text-th-warning`} />
) : null}
{type === 'info' ? (
<InformationCircleIcon className={`${iconClasses} text-th-fgd-4`} />
) : null}
<div>
<div className="text-th-fgd-2">{title}</div>
<div
className={`${title && desc && 'pt-1'} text-left text-xs font-normal`}
>
{desc}
</div>
2022-07-20 21:50:56 -07:00
</div>
</div>
2023-04-25 05:41:23 -07:00
)
}
2022-07-20 21:50:56 -07:00
export default InlineNotification