diff --git a/src/components/App/App.jsx b/src/components/App/App.jsx index 2b29851..d70156e 100644 --- a/src/components/App/App.jsx +++ b/src/components/App/App.jsx @@ -7,7 +7,8 @@ import { Route, Switch, useHistory, withRouter } from "react-router-dom"; import SharePage from "../SharePage/SharePage"; import style from "./App.module.css"; import ToggleDarkMode from "../ToggleDarkMode/ToggleDarkMode"; -import { ToastContainer, toast } from 'react-toastify'; +import { toast } from 'react-toastify'; +import AppToastContainer from "../AppToastContainer/AppToastContainer"; // Dark mode custom import useDarkMode from 'use-dark-mode'; @@ -57,21 +58,7 @@ const App = () => { - + diff --git a/src/components/AppToastContainer/AppToastContainer.jsx b/src/components/AppToastContainer/AppToastContainer.jsx new file mode 100644 index 0000000..76679c2 --- /dev/null +++ b/src/components/AppToastContainer/AppToastContainer.jsx @@ -0,0 +1,33 @@ +import React from "react"; +import { ToastContainer } from "react-toastify"; +import "react-toastify/dist/ReactToastify.css"; + +const AppToastContainer = ({ + color, + paddingLeft, + newestOnTop = false, + ...props +}) => { + const toastStyle = { + ...(color ? { color } : {}), + ...(paddingLeft ? { paddingLeft } : {}), + }; + + return ( + + ); +}; + +export default AppToastContainer; diff --git a/src/components/Modal/Modal.jsx b/src/components/Modal/Modal.jsx index e2e90f0..330ecf8 100644 --- a/src/components/Modal/Modal.jsx +++ b/src/components/Modal/Modal.jsx @@ -1,9 +1,9 @@ import React from "react"; import "./Modal.css"; -import { ToastContainer, toast } from "react-toastify"; -import "react-toastify/dist/ReactToastify.css"; +import { toast } from "react-toastify"; import { CopyToClipboard } from "react-copy-to-clipboard"; import Button from '../Button/Button'; +import AppToastContainer from "../AppToastContainer/AppToastContainer"; const MODAL_STYLES = { position: "fixed", // display: 'flex', @@ -40,20 +40,7 @@ export default function Modal({ id, open, children, onClose }) { const notify = () => toast("Link Copiedđź“‹"); return ( <> - +
diff --git a/src/components/SharePage/SharePage.jsx b/src/components/SharePage/SharePage.jsx index 3770edc..9f10c72 100644 --- a/src/components/SharePage/SharePage.jsx +++ b/src/components/SharePage/SharePage.jsx @@ -5,10 +5,10 @@ import Modal from '../Modal/Modal' import axios from "axios"; import copy from "copy-to-clipboard"; import style from "./SharePage.module.css"; -import { ToastContainer, toast } from 'react-toastify'; +import { toast } from 'react-toastify'; import xss from 'xss'; -import 'react-toastify/dist/ReactToastify.css'; import 'highlight.js/styles/atom-one-light.css'; +import AppToastContainer from "../AppToastContainer/AppToastContainer"; const SharePage = () => { const {id} = useParams(); @@ -63,21 +63,7 @@ const SharePage = () => {
setIsOpen(false)}/>