@@ -2,63 +2,132 @@ import React from "react"
22import {
33 ToastContainer as RTToastContainer ,
44 ToastContainerProps ,
5- toast as _toast ,
5+ toast as rtToast ,
66 Slide ,
77 ToastOptions as RTToastOptions ,
8+ ToastContent ,
89} from "react-toastify"
910import { useNotificationCenter as RTNotificationCenter } from "react-toastify/addons/use-notification-center"
1011import { NotificationCenterItem as RNotificationCenterItem } from "react-toastify/addons/use-notification-center/useNotificationCenter"
1112import { BadgeType } from "../../scenes/Import/ImportCSVFiles/types"
1213import {
13- Check ,
1414 CloseCircle ,
1515 ErrorWarning ,
1616 Information ,
1717} from "@styled-icons/remix-line"
18+ import { CheckmarkOutline } from "@styled-icons/evaicons-outline"
1819import { theme } from "../../theme"
1920
2021import "react-toastify/dist/ReactToastify.css"
22+ import "../../styles/_toast.scss"
2123
2224interface StyledIconProps
2325 extends React . PropsWithRef < React . SVGProps < SVGSVGElement > > {
2426 size ?: number | string
2527 title ?: string | null
2628}
2729
28- export const toast = _toast
30+ export type ToastOptions = RTToastOptions
2931
3032export const useNotificationCenter = RTNotificationCenter
3133
3234export type NotificationCenterItem < Data > = RNotificationCenterItem < Data >
3335
34- export type ToastOptions = RTToastOptions
35-
3636export const ToastIcon = ( {
3737 type,
38+ size = 18 ,
3839 ...props
3940} : StyledIconProps & {
4041 type : BadgeType
4142} ) => {
4243 switch ( type ) {
4344 case BadgeType . SUCCESS :
44- return < Check { ...props } color = { theme . color . green } />
45+ return < CheckmarkOutline { ...props } size = { size } color = { theme . color . green } />
4546 case BadgeType . WARNING :
46- return < ErrorWarning { ...props } color = { theme . color . orange } />
47+ return < ErrorWarning { ...props } size = { size } color = { theme . color . orange } />
4748 case BadgeType . ERROR :
48- return < CloseCircle { ...props } color = { theme . color . red } />
49+ return < CloseCircle { ...props } size = { size } color = { theme . color . red } />
4950 case BadgeType . INFO :
5051 default :
51- return < Information { ...props } color = { theme . color . cyan } />
52+ return < Information { ...props } size = { size } color = { theme . color . cyan } />
5253 }
5354}
5455
56+ const toast = {
57+ info : ( content : ToastContent , options ?: ToastOptions ) => {
58+ return rtToast . info ( content , {
59+ icon : < ToastIcon type = { BadgeType . INFO } /> ,
60+ className : "toast-info-container" ,
61+ progressStyle : {
62+ background : theme . color . cyan ,
63+ } ,
64+ style : {
65+ borderColor : theme . color . cyan ,
66+ background : theme . color . backgroundLighter ,
67+ } ,
68+ ...options ,
69+ } )
70+ } ,
71+ success : ( content : ToastContent , options ?: ToastOptions ) => {
72+ return rtToast . success ( content , {
73+ icon : < ToastIcon type = { BadgeType . SUCCESS } /> ,
74+ className : "toast-success-container" ,
75+ progressStyle : {
76+ background : theme . color . green ,
77+ } ,
78+ style : {
79+ borderColor : theme . color . green ,
80+ background : theme . color . backgroundLighter ,
81+ } ,
82+ ...options ,
83+ } )
84+ } ,
85+ warning : ( content : ToastContent , options ?: ToastOptions ) => {
86+ return rtToast . warning ( content , {
87+ icon : < ToastIcon type = { BadgeType . WARNING } /> ,
88+ className : "toast-warning-container" ,
89+ progressStyle : {
90+ background : theme . color . orange ,
91+ } ,
92+ style : {
93+ borderColor : theme . color . orange ,
94+ background : theme . color . backgroundLighter ,
95+ } ,
96+ ...options ,
97+ } )
98+ } ,
99+ error : ( content : ToastContent , options ?: ToastOptions ) => {
100+ return rtToast . error ( content , {
101+ icon : < ToastIcon type = { BadgeType . ERROR } /> ,
102+ progressStyle : {
103+ background : theme . color . red ,
104+ } ,
105+ className : "toast-error-container" ,
106+ style : {
107+ borderColor : theme . color . red ,
108+ background : theme . color . backgroundLighter ,
109+ } ,
110+ ...options ,
111+ } )
112+ } ,
113+ dismiss : rtToast . dismiss ,
114+ isActive : rtToast . isActive ,
115+ }
116+
117+ export { toast }
118+
55119export const ToastContainer = ( props ?: ToastContainerProps ) => {
56120 const mergedProps : ToastContainerProps = {
57121 autoClose : 3000 ,
58122 draggable : false ,
59123 position : "top-right" ,
60124 theme : "dark" ,
61125 transition : Slide ,
126+ hideProgressBar : false ,
127+ closeButton : true ,
128+ closeOnClick : true ,
129+ pauseOnHover : true ,
130+ pauseOnFocusLoss : false ,
62131 ...props ,
63132 }
64133
0 commit comments