File tree Expand file tree Collapse file tree 6 files changed +65
-0
lines changed
Expand file tree Collapse file tree 6 files changed +65
-0
lines changed Original file line number Diff line number Diff line change 1+
2+ import { toast } from "react-toastify" ;
3+ import { TOASTR_OPTIONS } from "../constants/toastr" ;
4+
5+ const ToastrComponent = ( { message } ) => {
6+ return (
7+ < div className = "flex flex-row items-start justify-start" >
8+ < p className = "text-medium text-black dark:text-white" > { message } </ p >
9+ </ div >
10+ )
11+ }
12+
13+ const showToastr = message => {
14+ toast ( < ToastrComponent message = { message } /> , TOASTR_OPTIONS )
15+ }
16+
17+ const isError = e => e && e . stack && e . message ;
18+
19+ const showErrorToastr = error => {
20+ const errorMessage = isError ( error ) ? error . message : error ;
21+ toast . error ( < ToastrComponent message = { errorMessage } /> , TOASTR_OPTIONS )
22+ }
23+
24+ const Toastr = {
25+ success : showToastr ,
26+ error : showErrorToastr
27+ }
28+
29+ export default Toastr ;
Original file line number Diff line number Diff line change 1+ import { toast , Slide } from "react-toastify" ;
2+
3+ const TOASTR_OPTIONS = {
4+ position : toast . POSITION . TOP_CENTER ,
5+ transition : Slide ,
6+ autoClose : 5000 ,
7+ hideProgressBar : false ,
8+ newestOnTop : false ,
9+ closeOnClick : true ,
10+ rtl : false ,
11+ pauseOnFocusLoss : true ,
12+ draggable : true ,
13+ pauseOnHover : true
14+ } ;
15+
16+ export { TOASTR_OPTIONS } ;
Original file line number Diff line number Diff line change 2020 "next" : " 13.0.6" ,
2121 "react" : " 18.2.0" ,
2222 "react-dom" : " 18.2.0" ,
23+ "react-toastify" : " ^9.1.1" ,
2324 "sass" : " ^1.57.1"
2425 },
2526 "devDependencies" : {
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { createTheme } from "@uiw/codemirror-themes";
55import { EditorView } from "@codemirror/view" ;
66
77import Head from "next/head" ;
8+ import { ToastContainer } from 'react-toastify' ;
89import Button from "../components/Button" ;
910
1011import { CODE_EDITOR_THEME } from "../constants/theme" ;
@@ -31,6 +32,11 @@ export default function Home() {
3132 </ Head >
3233
3334 < main >
35+ < ToastContainer
36+ // @Shreya defining this here instead of TOAST_OPTIONS to make implementing dark mode easier
37+ // Global state pole vekkam ivide
38+ theme = "dark"
39+ />
3440 < p className = "text-2xl text-center" > JSON STYLE</ p >
3541 < div className = "space-y-3 flex-col" >
3642 < div className = "flex space-x-3 h-90" >
Original file line number Diff line number Diff line change 88// components
99@import " ./components/button" ;
1010@import " ./components/textarea" ;
11+ @import " react-toastify/dist/ReactToastify.min.css" ;
Original file line number Diff line number Diff line change @@ -689,6 +689,11 @@ client-only@0.0.1:
689689 resolved "https://registry.yarnpkg.com/client-only/-/client-only-0.0.1.tgz#38bba5d403c41ab150bff64a95c85013cf73bca1"
690690 integrity sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA==
691691
692+ clsx@^1.1.1 :
693+ version "1.2.1"
694+ resolved "https://registry.yarnpkg.com/clsx/-/clsx-1.2.1.tgz#0ddc4a20a549b59c93a4116bb26f5294ca17dc12"
695+ integrity sha512-EcR6r5a8bj6pu3ycsa/E/cKVGuTgZJZdsyUYHOksG/UHIiKfjxzRxYJpyVBwYaQeOvghal9fcc4PidlgzugAQg==
696+
692697codemirror@^6.0.0 :
693698 version "6.0.1"
694699 resolved "https://registry.yarnpkg.com/codemirror/-/codemirror-6.0.1.tgz#62b91142d45904547ee3e0e0e4c1a79158035a29"
@@ -2003,6 +2008,13 @@ react-is@^16.13.1:
20032008 resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
20042009 integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==
20052010
2011+ react-toastify@^9.1.1 :
2012+ version "9.1.1"
2013+ resolved "https://registry.yarnpkg.com/react-toastify/-/react-toastify-9.1.1.tgz#9280caea4a13dc1739c350d90660a630807bf10b"
2014+ integrity sha512-pkFCla1z3ve045qvjEmn2xOJOy4ZciwRXm1oMPULVkELi5aJdHCN/FHnuqXq8IwGDLB7PPk2/J6uP9D8ejuiRw==
2015+ dependencies :
2016+ clsx "^1.1.1"
2017+
20062018react@18.2.0 :
20072019 version "18.2.0"
20082020 resolved "https://registry.yarnpkg.com/react/-/react-18.2.0.tgz#555bd98592883255fa00de14f1151a917b5d77d5"
You can’t perform that action at this time.
0 commit comments