From a3bde45ccd1c36b7aa39d1ca42a5a7f2aa538f0c Mon Sep 17 00:00:00 2001 From: KimiaMontazeri Date: Tue, 28 Nov 2023 00:53:15 +0330 Subject: [PATCH 1/2] feat: add success and info colors to theme --- frontend/src/css/Theme.css | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frontend/src/css/Theme.css b/frontend/src/css/Theme.css index 6baa538..0d73f72 100644 --- a/frontend/src/css/Theme.css +++ b/frontend/src/css/Theme.css @@ -10,6 +10,8 @@ /*warn color*/ --warn-color: #ec6803; --error-color: #ff3333; + --success-color: #197f3c; + --info-color: #19517f; /*background*/ --background-color: #0a0f26; From 9da223a3340c8c7d61a7af482fed3157219d27a2 Mon Sep 17 00:00:00 2001 From: KimiaMontazeri Date: Tue, 28 Nov 2023 00:53:25 +0330 Subject: [PATCH 2/2] 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)' }} + /> + + ); +}