2022-11-25 20:25:03 +00:00
|
|
|
import { useContext, useEffect } from 'react';
|
2022-06-12 19:07:52 +00:00
|
|
|
import { CheckIcon, ExclamationIcon, InformationCircleIcon, ShieldExclamationIcon } from '@heroicons/react/outline';
|
|
|
|
import classNames from 'classnames';
|
2022-07-03 17:29:23 +00:00
|
|
|
import { DialogContext, DialogIconProps, styles } from './';
|
2022-06-12 19:07:52 +00:00
|
|
|
|
2022-07-02 21:24:12 +00:00
|
|
|
const icons = {
|
|
|
|
danger: ShieldExclamationIcon,
|
|
|
|
warning: ExclamationIcon,
|
|
|
|
success: CheckIcon,
|
|
|
|
info: InformationCircleIcon,
|
|
|
|
};
|
|
|
|
|
2022-07-03 17:29:23 +00:00
|
|
|
export default ({ type, position, className }: DialogIconProps) => {
|
2022-07-02 22:27:22 +00:00
|
|
|
const { setIcon, setIconPosition } = useContext(DialogContext);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
const Icon = icons[type];
|
2022-06-12 19:07:52 +00:00
|
|
|
|
2022-07-02 22:27:22 +00:00
|
|
|
setIcon(
|
|
|
|
<div className={classNames(styles.dialog_icon, styles[type], className)}>
|
|
|
|
<Icon className={'w-6 h-6'} />
|
2022-11-25 20:25:03 +00:00
|
|
|
</div>,
|
2022-07-02 22:27:22 +00:00
|
|
|
);
|
|
|
|
}, [type, className]);
|
2022-07-02 21:24:12 +00:00
|
|
|
|
2022-07-02 22:27:22 +00:00
|
|
|
useEffect(() => {
|
|
|
|
setIconPosition(position);
|
|
|
|
}, [position]);
|
2022-07-02 21:24:12 +00:00
|
|
|
|
2022-07-02 22:27:22 +00:00
|
|
|
return null;
|
2022-06-12 19:07:52 +00:00
|
|
|
};
|