From fed5005bba69bb98bfbac03f4ef14d2cf497d74f Mon Sep 17 00:00:00 2001 From: Samuel Valdes Gutierrez Date: Tue, 31 Oct 2023 11:07:04 +0000 Subject: [PATCH] updating toast for small screens --- src/components/ContactToast.jsx | 28 +++++++++++++++++----------- src/contexts/ToastContext.jsx | 1 - 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/components/ContactToast.jsx b/src/components/ContactToast.jsx index e3c5842..332bd95 100644 --- a/src/components/ContactToast.jsx +++ b/src/components/ContactToast.jsx @@ -1,25 +1,31 @@ -import React, { useContext } from 'react'; -import { Toast } from 'flowbite-react'; -import { FaTelegramPlane, FaTimesCircle } from 'react-icons/fa'; -import ToastContext from '../contexts/ToastContext'; +import React, { useContext } from "react"; +import { Toast } from "flowbite-react"; +import { FaTelegramPlane, FaTimesCircle } from "react-icons/fa"; +import ToastContext from "../contexts/ToastContext"; const ContactToast = () => { const { toastInfo, setToastInfo } = useContext(ToastContext); - const backgroundColor = toastInfo.type === 'success' ? '!bg-green-200 dark:!bg-green-700' : '!bg-red-200 dark:!bg-red-700'; - const textColor = toastInfo.type === 'success' ? 'text-green-500 dark:text-green-200' : 'text-red-500 dark:text-red-200'; + const backgroundColor = + toastInfo.type === "success" ? "!bg-green-700" : "!bg-red-700"; + const textColor = + toastInfo.type === "success" ? "text-green-200" : "text-red-200"; return ( -
- setToastInfo(null)} className={backgroundColor}> -
- {toastInfo.type === 'success' ? ( +
+ setToastInfo(null)} className={`${backgroundColor} rounded-none sm:rounded-lg`}> +
+ {toastInfo.type === "success" ? ( ) : ( )}
-
{toastInfo.message}
+
+ {toastInfo.message} +
diff --git a/src/contexts/ToastContext.jsx b/src/contexts/ToastContext.jsx index 8eec551..3b7594c 100644 --- a/src/contexts/ToastContext.jsx +++ b/src/contexts/ToastContext.jsx @@ -5,7 +5,6 @@ const ToastContext = createContext(); export const ToastProvider = ({ children }) => { const [toastInfo, setToastInfo] = useState({ message:"", type:"", visible: false }); - const showToast = (message, type, duration = 5000) => { setToastInfo({ message, type, visible: true });