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

69 lines
1.8 KiB
TypeScript
Raw Normal View History

2022-07-20 21:50:56 -07:00
import { FunctionComponent } from 'react'
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 {
desc?: string
title?: string
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,
2022-07-20 21:50:56 -07:00
}) => (
<div
2022-08-25 20:46:23 -07:00
className={`${
!hideBorder
? `border text-th-fgd-3 ${
type === 'error'
2022-11-30 19:46:37 -08:00
? 'border-th-error'
2022-08-25 20:46:23 -07:00
: type === 'success'
2022-11-30 19:46:37 -08:00
? 'border-th-success'
2022-08-25 20:46:23 -07:00
: type === 'info'
? 'border-th-bkg-4'
2022-11-30 19:32:32 -08:00
: 'border-th-warning'
2022-08-25 20:46:23 -07:00
}`
: type === 'error'
2022-11-30 19:46:37 -08:00
? 'text-th-error'
2022-07-20 21:50:56 -07:00
: type === 'success'
2022-11-30 19:46:37 -08:00
? 'text-th-success'
2022-07-20 21:50:56 -07:00
: type === 'info'
2022-08-25 20:46:23 -07:00
? 'text-th-bkg-4'
2022-11-30 19:32:32 -08:00
: 'text-th-warning'
2022-08-25 20:46:23 -07:00
} flex items-center rounded-md ${!hidePadding ? 'p-2' : ''}`}
2022-07-20 21:50:56 -07:00
>
{type === 'error' ? (
2022-11-30 19:46:37 -08:00
<ExclamationCircleIcon className="mr-1.5 h-5 w-5 flex-shrink-0 text-th-error" />
2022-07-20 21:50:56 -07:00
) : null}
{type === 'success' ? (
2022-11-30 19:46:37 -08:00
<CheckCircleIcon className="mr-1.5 h-5 w-5 flex-shrink-0 text-th-success" />
2022-07-20 21:50:56 -07:00
) : null}
{type === 'warning' ? (
2022-11-30 19:46:37 -08:00
<ExclamationTriangleIcon className="mr-1.5 h-5 w-5 flex-shrink-0 text-th-warning" />
2022-07-20 21:50:56 -07:00
) : null}
{type === 'info' ? (
2022-08-25 20:46:23 -07:00
<InformationCircleIcon className="mr-1.5 h-5 w-5 flex-shrink-0 text-th-fgd-4" />
2022-07-20 21:50:56 -07:00
) : null}
<div>
2022-08-25 20:46:23 -07:00
<div>{title}</div>
2022-07-20 21:50:56 -07:00
<div
2022-08-25 20:46:23 -07:00
className={`${title && desc && 'pt-1'} text-left text-xs font-normal`}
2022-07-20 21:50:56 -07:00
>
{desc}
</div>
</div>
</div>
)
export default InlineNotification