From 9da223a3340c8c7d61a7af482fed3157219d27a2 Mon Sep 17 00:00:00 2001 From: KimiaMontazeri Date: Tue, 28 Nov 2023 00:53:25 +0330 Subject: [PATCH] refactor: restyle toast --- frontend/src/components/toast/Toast.jsx | 76 ++++++++++++++----------- 1 file changed, 43 insertions(+), 33 deletions(-) diff --git a/frontend/src/components/toast/Toast.jsx b/frontend/src/components/toast/Toast.jsx index 82d8fc0..ad2681a 100644 --- a/frontend/src/components/toast/Toast.jsx +++ b/frontend/src/components/toast/Toast.jsx @@ -1,38 +1,48 @@ -import {useCallback} from "react"; -import {Alert, Snackbar} from "@mui/material"; +import { useCallback } from 'react'; +import { Close } from '@mui/icons-material'; +import { IconButton, Snackbar, SnackbarContent } from '@mui/material'; import Slide from '@mui/material/Slide'; -export default function Toast({ - duration = 6000, - vertical = "top", //'top', 'bottom' - horizontal = "right", //'left', 'center', 'right' - message = "fill me", - alertType = "success",//'error', 'warning', 'info', 'success', - open, - setOpen, - }) { +const CloseButton = ({ onClick }) => ( + + + +); +const alertTypeColorMapping = { + error: 'var(--error-color)', + warning: 'var(--warn-color)', + info: 'var(--info-color)', + success: 'var(--success-color)', +}; - const onClose = useCallback(() => { - setOpen(false) - }, []) +export default function Toast({ + duration = 6000, + vertical = 'top', //'top', 'bottom' + horizontal = 'right', //'left', 'center', 'right' + message = 'fill me', + alertType = 'success', //'error', 'warning', 'info', 'success', + open, + setOpen, +}) { + const onClose = useCallback(() => { + setOpen(false); + }, []); - return ( - } - > - - {message} - - - ) -} \ No newline at end of file + return ( + } + action={} + > + setOpen(false)} />} + sx={{ bgcolor: alertTypeColorMapping[alertType], color: 'var(--light-text-color)' }} + /> + + ); +}