misc_pterodactyl-panel/resources/scripts/components/elements/dialog/DialogIcon.tsx

32 lines
907 B
TypeScript
Raw Normal View History

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';
import { DialogContext, DialogIconProps, styles } from './';
2022-06-12 19:07:52 +00:00
const icons = {
danger: ShieldExclamationIcon,
warning: ExclamationIcon,
success: CheckIcon,
info: InformationCircleIcon,
};
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 22:27:22 +00:00
useEffect(() => {
setIconPosition(position);
}, [position]);
2022-07-02 22:27:22 +00:00
return null;
2022-06-12 19:07:52 +00:00
};