mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-24 17:51:14 +02:00
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
import { Portal, Snackbar } from '@material-ui/core';
|
|
import { Alert } from '@material-ui/lab';
|
|
import { useCommonStyles } from '../../../common.styles';
|
|
import { IToast } from '../../../hooks/useToast';
|
|
import AnimateOnMount from '../AnimateOnMount/AnimateOnMount';
|
|
|
|
interface IToastProps extends IToast {
|
|
onClose: () => void;
|
|
autoHideDuration?: number;
|
|
}
|
|
|
|
const Toast = ({
|
|
show,
|
|
onClose,
|
|
type,
|
|
text,
|
|
autoHideDuration = 6000,
|
|
}: IToastProps) => {
|
|
const styles = useCommonStyles();
|
|
|
|
return (
|
|
<Portal>
|
|
<AnimateOnMount
|
|
mounted={show}
|
|
start={styles.fadeInBottomStartWithoutFixed}
|
|
enter={styles.fadeInBottomEnter}
|
|
leave={styles.fadeInBottomLeave}
|
|
container={styles.fullWidth}
|
|
>
|
|
<Snackbar
|
|
open={show}
|
|
onClose={onClose}
|
|
autoHideDuration={autoHideDuration}
|
|
style={{ bottom: '40px' }}
|
|
>
|
|
<Alert variant="filled" severity={type} onClose={onClose}>
|
|
{text}
|
|
</Alert>
|
|
</Snackbar>
|
|
</AnimateOnMount>
|
|
</Portal>
|
|
);
|
|
};
|
|
|
|
export default Toast;
|