-
Notifications
You must be signed in to change notification settings - Fork 0
/
toasts.js
45 lines (44 loc) · 1.07 KB
/
toasts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const options = {
anchorOrigin: {
vertical: 'top',
horizontal: 'right',
},
}
/**
* There is no global state management in Gatsby. So I cannot create a toast message in, say, the contact form
* container then expect it to persist onto other pages if a navigation occurs immediately after.
*
* Using url query params, we can navigate to a page with ?toasts=contact-success,subscribe-success and then in the
* useEffect of that page, issue those toasts on the new page then pop them out of the query params.
*
*/
export const toastMessages = {
'contact-success': [
"Thanks, we'll get back to you soon!",
{
...options,
variant: 'success',
},
],
'contact-failure': [
'Something went wrong... can you try again later?',
{
...options,
variant: 'error',
},
],
'subscribe-success': [
"Thanks, you'll be hearing from us!",
{
...options,
variant: 'success',
},
],
'subscribe-failure': [
'Something went wrong... can you try again later?',
{
...options,
variant: 'error',
},
],
}