@redsift/popovers 9.2.3 → 9.2.4-muiv5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -2
- package/coverage/clover.xml +0 -763
- package/coverage/coverage-final.json +0 -53
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/dialog/Dialog.tsx.html +0 -271
- package/coverage/lcov-report/dialog/context.ts.html +0 -97
- package/coverage/lcov-report/dialog/index.html +0 -191
- package/coverage/lcov-report/dialog/index.ts.html +0 -100
- package/coverage/lcov-report/dialog/types.ts.html +0 -241
- package/coverage/lcov-report/dialog/useDialog.tsx.html +0 -346
- package/coverage/lcov-report/dialog/useDialogContext.tsx.html +0 -121
- package/coverage/lcov-report/dialog-content/DialogContent.tsx.html +0 -484
- package/coverage/lcov-report/dialog-content/index.html +0 -146
- package/coverage/lcov-report/dialog-content/index.ts.html +0 -91
- package/coverage/lcov-report/dialog-content/intl/index.html +0 -116
- package/coverage/lcov-report/dialog-content/intl/index.ts.html +0 -106
- package/coverage/lcov-report/dialog-content/styles.ts.html +0 -256
- package/coverage/lcov-report/dialog-content-actions/DialogContentActions.tsx.html +0 -205
- package/coverage/lcov-report/dialog-content-actions/index.html +0 -146
- package/coverage/lcov-report/dialog-content-actions/index.ts.html +0 -91
- package/coverage/lcov-report/dialog-content-actions/styles.ts.html +0 -139
- package/coverage/lcov-report/dialog-content-body/DialogContentBody.tsx.html +0 -232
- package/coverage/lcov-report/dialog-content-body/index.html +0 -146
- package/coverage/lcov-report/dialog-content-body/index.ts.html +0 -91
- package/coverage/lcov-report/dialog-content-body/styles.ts.html +0 -259
- package/coverage/lcov-report/dialog-content-header/DialogContentHeader.tsx.html +0 -280
- package/coverage/lcov-report/dialog-content-header/index.html +0 -146
- package/coverage/lcov-report/dialog-content-header/index.ts.html +0 -91
- package/coverage/lcov-report/dialog-content-header/styles.ts.html +0 -193
- package/coverage/lcov-report/dialog-trigger/DialogTrigger.tsx.html +0 -217
- package/coverage/lcov-report/dialog-trigger/index.html +0 -131
- package/coverage/lcov-report/dialog-trigger/index.ts.html +0 -91
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -341
- package/coverage/lcov-report/popover/Popover.tsx.html +0 -295
- package/coverage/lcov-report/popover/context.ts.html +0 -97
- package/coverage/lcov-report/popover/index.html +0 -191
- package/coverage/lcov-report/popover/index.ts.html +0 -100
- package/coverage/lcov-report/popover/types.ts.html +0 -283
- package/coverage/lcov-report/popover/usePopover.tsx.html +0 -415
- package/coverage/lcov-report/popover/usePopoverContext.tsx.html +0 -121
- package/coverage/lcov-report/popover-content/PopoverContent.tsx.html +0 -229
- package/coverage/lcov-report/popover-content/index.html +0 -146
- package/coverage/lcov-report/popover-content/index.ts.html +0 -94
- package/coverage/lcov-report/popover-content/styles.ts.html +0 -370
- package/coverage/lcov-report/popover-trigger/PopoverTrigger.tsx.html +0 -202
- package/coverage/lcov-report/popover-trigger/index.html +0 -131
- package/coverage/lcov-report/popover-trigger/index.ts.html +0 -91
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
- package/coverage/lcov-report/toast/Toast.tsx.html +0 -373
- package/coverage/lcov-report/toast/index.html +0 -161
- package/coverage/lcov-report/toast/index.ts.html +0 -91
- package/coverage/lcov-report/toast/intl/index.html +0 -116
- package/coverage/lcov-report/toast/intl/index.ts.html +0 -106
- package/coverage/lcov-report/toast/styles.ts.html +0 -193
- package/coverage/lcov-report/toast/types.ts.html +0 -217
- package/coverage/lcov-report/toast-container/ToastContainer.tsx.html +0 -217
- package/coverage/lcov-report/toast-container/index.html +0 -161
- package/coverage/lcov-report/toast-container/index.ts.html +0 -94
- package/coverage/lcov-report/toast-container/styles.ts.html +0 -2284
- package/coverage/lcov-report/toast-container/useToast.tsx.html +0 -469
- package/coverage/lcov-report/tooltip/Tooltip.tsx.html +0 -250
- package/coverage/lcov-report/tooltip/context.ts.html +0 -97
- package/coverage/lcov-report/tooltip/index.html +0 -191
- package/coverage/lcov-report/tooltip/index.ts.html +0 -100
- package/coverage/lcov-report/tooltip/types.ts.html +0 -250
- package/coverage/lcov-report/tooltip/useTooltip.tsx.html +0 -358
- package/coverage/lcov-report/tooltip/useTooltipContext.tsx.html +0 -121
- package/coverage/lcov-report/tooltip-content/TooltipContent.tsx.html +0 -313
- package/coverage/lcov-report/tooltip-content/index.html +0 -146
- package/coverage/lcov-report/tooltip-content/index.ts.html +0 -91
- package/coverage/lcov-report/tooltip-content/styles.ts.html +0 -337
- package/coverage/lcov-report/tooltip-trigger/TooltipTrigger.tsx.html +0 -211
- package/coverage/lcov-report/tooltip-trigger/index.html +0 -131
- package/coverage/lcov-report/tooltip-trigger/index.ts.html +0 -91
- package/coverage/lcov.info +0 -1510
- package/coverage/storybook/coverage-storybook.json +0 -58724
- package/dist/package.json +0 -96
- package/index.ts +0 -1
- package/jest.config.js +0 -3
- package/rollup.config.js +0 -13
- package/src/components/dialog/Dialog.stories.tsx +0 -264
- package/src/components/dialog/Dialog.test.tsx +0 -116
- package/src/components/dialog/Dialog.tsx +0 -62
- package/src/components/dialog/context.ts +0 -4
- package/src/components/dialog/index.ts +0 -5
- package/src/components/dialog/types.ts +0 -52
- package/src/components/dialog/useDialog.tsx +0 -87
- package/src/components/dialog/useDialogContext.tsx +0 -12
- package/src/components/dialog-content/DialogContent.stories.tsx +0 -348
- package/src/components/dialog-content/DialogContent.tsx +0 -133
- package/src/components/dialog-content/index.ts +0 -2
- package/src/components/dialog-content/intl/en-US.json +0 -3
- package/src/components/dialog-content/intl/fr-FR.json +0 -3
- package/src/components/dialog-content/intl/index.ts +0 -7
- package/src/components/dialog-content/styles.ts +0 -57
- package/src/components/dialog-content/types.ts +0 -10
- package/src/components/dialog-content-actions/DialogContentActions.test.tsx +0 -68
- package/src/components/dialog-content-actions/DialogContentActions.tsx +0 -40
- package/src/components/dialog-content-actions/index.ts +0 -2
- package/src/components/dialog-content-actions/styles.ts +0 -18
- package/src/components/dialog-content-actions/types.ts +0 -11
- package/src/components/dialog-content-body/DialogContentBody.test.tsx +0 -63
- package/src/components/dialog-content-body/DialogContentBody.tsx +0 -49
- package/src/components/dialog-content-body/index.ts +0 -2
- package/src/components/dialog-content-body/styles.ts +0 -58
- package/src/components/dialog-content-body/types.ts +0 -14
- package/src/components/dialog-content-header/DialogContentHeader.test.tsx +0 -63
- package/src/components/dialog-content-header/DialogContentHeader.tsx +0 -65
- package/src/components/dialog-content-header/index.ts +0 -2
- package/src/components/dialog-content-header/styles.ts +0 -36
- package/src/components/dialog-content-header/types.ts +0 -21
- package/src/components/dialog-trigger/DialogTrigger.tsx +0 -44
- package/src/components/dialog-trigger/index.ts +0 -2
- package/src/components/dialog-trigger/types.ts +0 -9
- package/src/components/popover/Popover.stories.tsx +0 -129
- package/src/components/popover/Popover.test.tsx +0 -102
- package/src/components/popover/Popover.tsx +0 -70
- package/src/components/popover/context.ts +0 -4
- package/src/components/popover/index.ts +0 -5
- package/src/components/popover/types.ts +0 -66
- package/src/components/popover/usePopover.tsx +0 -110
- package/src/components/popover/usePopoverContext.tsx +0 -12
- package/src/components/popover-content/PopoverContent.tsx +0 -48
- package/src/components/popover-content/index.ts +0 -3
- package/src/components/popover-content/styles.ts +0 -95
- package/src/components/popover-content/types.ts +0 -11
- package/src/components/popover-trigger/PopoverTrigger.tsx +0 -39
- package/src/components/popover-trigger/index.ts +0 -2
- package/src/components/popover-trigger/types.ts +0 -9
- package/src/components/toast/Toast.stories.tsx +0 -68
- package/src/components/toast/Toast.test.tsx +0 -63
- package/src/components/toast/Toast.tsx +0 -96
- package/src/components/toast/index.ts +0 -2
- package/src/components/toast/intl/en-US.json +0 -3
- package/src/components/toast/intl/fr-FR.json +0 -3
- package/src/components/toast/intl/index.ts +0 -7
- package/src/components/toast/styles.ts +0 -36
- package/src/components/toast/types.ts +0 -44
- package/src/components/toast-container/ToastContainer.stories.tsx +0 -349
- package/src/components/toast-container/ToastContainer.tsx +0 -44
- package/src/components/toast-container/index.ts +0 -3
- package/src/components/toast-container/styles.ts +0 -733
- package/src/components/toast-container/types.ts +0 -110
- package/src/components/toast-container/useToast.test.tsx +0 -111
- package/src/components/toast-container/useToast.tsx +0 -128
- package/src/components/tooltip/Tooltip.stories.tsx +0 -196
- package/src/components/tooltip/Tooltip.test.tsx +0 -119
- package/src/components/tooltip/Tooltip.tsx +0 -55
- package/src/components/tooltip/context.ts +0 -4
- package/src/components/tooltip/index.ts +0 -5
- package/src/components/tooltip/types.ts +0 -55
- package/src/components/tooltip/useTooltip.tsx +0 -93
- package/src/components/tooltip/useTooltipContext.tsx +0 -12
- package/src/components/tooltip-content/TooltipContent.tsx +0 -76
- package/src/components/tooltip-content/index.ts +0 -2
- package/src/components/tooltip-content/styles.ts +0 -84
- package/src/components/tooltip-content/types.ts +0 -14
- package/src/components/tooltip-trigger/TooltipTrigger.tsx +0 -42
- package/src/components/tooltip-trigger/index.ts +0 -2
- package/src/components/tooltip-trigger/types.ts +0 -9
- package/src/index.ts +0 -16
- package/tsconfig.json +0 -3
- /package/{dist/CONTRIBUTING.md → CONTRIBUTING.md} +0 -0
- /package/{dist/index.d.ts → index.d.ts} +0 -0
- /package/{dist/index.js → index.js} +0 -0
- /package/{dist/index.js.map → index.js.map} +0 -0
|
@@ -1,349 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import { ToastContainer, useToast } from '.';
|
|
4
|
-
import { Button, Flexbox } from '@redsift/design-system';
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
title: 'Popovers/Toast/ToastContainer',
|
|
8
|
-
component: ToastContainer,
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export const Simple = () => {
|
|
12
|
-
const { notify } = useToast();
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<>
|
|
16
|
-
<Flexbox>
|
|
17
|
-
<Button
|
|
18
|
-
onClick={() =>
|
|
19
|
-
notify({
|
|
20
|
-
content: 'This is a success',
|
|
21
|
-
variant: 'success',
|
|
22
|
-
})
|
|
23
|
-
}
|
|
24
|
-
>
|
|
25
|
-
Success
|
|
26
|
-
</Button>
|
|
27
|
-
<Button
|
|
28
|
-
onClick={() =>
|
|
29
|
-
notify({
|
|
30
|
-
title: 'This is a warning',
|
|
31
|
-
content: 'Cupcake ipsum dolor sit amet.',
|
|
32
|
-
variant: 'warning',
|
|
33
|
-
})
|
|
34
|
-
}
|
|
35
|
-
>
|
|
36
|
-
Warning
|
|
37
|
-
</Button>
|
|
38
|
-
<Button
|
|
39
|
-
onClick={() =>
|
|
40
|
-
notify({
|
|
41
|
-
title: 'This is an error',
|
|
42
|
-
content:
|
|
43
|
-
'Cupcake ipsum dolor sit amet. Cookie chocolate cake muffin chocolate bar powder cake chupa chups. Gummies chocolate cake cupcake chupa chups sesame snaps soufflé soufflé gingerbread blueie. Caramels chocolate bar soufflé sesame snaps tiramisu. Cookie muffin pie cake cupcake sweet.',
|
|
44
|
-
variant: 'error',
|
|
45
|
-
})
|
|
46
|
-
}
|
|
47
|
-
>
|
|
48
|
-
Error
|
|
49
|
-
</Button>
|
|
50
|
-
<Button
|
|
51
|
-
onClick={() =>
|
|
52
|
-
notify({
|
|
53
|
-
title: 'This is an info',
|
|
54
|
-
content:
|
|
55
|
-
'Cupcake ipsum dolor sit amet. Cookie chocolate cake muffin chocolate bar powder cake chupa chups.',
|
|
56
|
-
variant: 'info',
|
|
57
|
-
})
|
|
58
|
-
}
|
|
59
|
-
>
|
|
60
|
-
Info
|
|
61
|
-
</Button>
|
|
62
|
-
</Flexbox>
|
|
63
|
-
<ToastContainer />
|
|
64
|
-
</>
|
|
65
|
-
);
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export const AllVariants = () => {
|
|
69
|
-
const { notify, success, warning, error, info, loading } = useToast();
|
|
70
|
-
|
|
71
|
-
return (
|
|
72
|
-
<>
|
|
73
|
-
<Flexbox
|
|
74
|
-
flexDirection="row"
|
|
75
|
-
flexWrap="wrap"
|
|
76
|
-
justifyContent="center"
|
|
77
|
-
alignItems="flex-start"
|
|
78
|
-
marginTop="96px"
|
|
79
|
-
>
|
|
80
|
-
<Button
|
|
81
|
-
variant="secondary"
|
|
82
|
-
onClick={() =>
|
|
83
|
-
notify({
|
|
84
|
-
content: 'Default',
|
|
85
|
-
})
|
|
86
|
-
}
|
|
87
|
-
>
|
|
88
|
-
Default
|
|
89
|
-
</Button>
|
|
90
|
-
<Button
|
|
91
|
-
variant="secondary"
|
|
92
|
-
onClick={() =>
|
|
93
|
-
success({
|
|
94
|
-
content: 'Success',
|
|
95
|
-
})
|
|
96
|
-
}
|
|
97
|
-
>
|
|
98
|
-
Success
|
|
99
|
-
</Button>
|
|
100
|
-
<Button
|
|
101
|
-
variant="secondary"
|
|
102
|
-
onClick={() =>
|
|
103
|
-
warning({
|
|
104
|
-
content: 'Warning',
|
|
105
|
-
})
|
|
106
|
-
}
|
|
107
|
-
>
|
|
108
|
-
Warning
|
|
109
|
-
</Button>
|
|
110
|
-
<Button
|
|
111
|
-
variant="secondary"
|
|
112
|
-
onClick={() =>
|
|
113
|
-
error({
|
|
114
|
-
content: 'Error',
|
|
115
|
-
})
|
|
116
|
-
}
|
|
117
|
-
>
|
|
118
|
-
Error
|
|
119
|
-
</Button>
|
|
120
|
-
<Button
|
|
121
|
-
variant="secondary"
|
|
122
|
-
onClick={() =>
|
|
123
|
-
info({
|
|
124
|
-
content: 'Info',
|
|
125
|
-
})
|
|
126
|
-
}
|
|
127
|
-
>
|
|
128
|
-
Info
|
|
129
|
-
</Button>
|
|
130
|
-
<Button
|
|
131
|
-
variant="secondary"
|
|
132
|
-
onClick={() =>
|
|
133
|
-
loading({
|
|
134
|
-
content: 'Loading',
|
|
135
|
-
})
|
|
136
|
-
}
|
|
137
|
-
>
|
|
138
|
-
Loading
|
|
139
|
-
</Button>
|
|
140
|
-
</Flexbox>
|
|
141
|
-
<ToastContainer />
|
|
142
|
-
</>
|
|
143
|
-
);
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
export const AllPlacements = () => {
|
|
147
|
-
const { notify } = useToast();
|
|
148
|
-
|
|
149
|
-
return (
|
|
150
|
-
<>
|
|
151
|
-
<Flexbox
|
|
152
|
-
flexDirection="row"
|
|
153
|
-
flexWrap="wrap"
|
|
154
|
-
justifyContent="center"
|
|
155
|
-
alignItems="flex-start"
|
|
156
|
-
marginTop="96px"
|
|
157
|
-
>
|
|
158
|
-
<Button
|
|
159
|
-
variant="secondary"
|
|
160
|
-
onClick={() =>
|
|
161
|
-
notify({
|
|
162
|
-
content: 'Top-left',
|
|
163
|
-
placement: 'top-left',
|
|
164
|
-
})
|
|
165
|
-
}
|
|
166
|
-
>
|
|
167
|
-
Top-left
|
|
168
|
-
</Button>
|
|
169
|
-
<Button
|
|
170
|
-
variant="secondary"
|
|
171
|
-
onClick={() =>
|
|
172
|
-
notify({
|
|
173
|
-
content: 'Top-center',
|
|
174
|
-
placement: 'top-center',
|
|
175
|
-
})
|
|
176
|
-
}
|
|
177
|
-
>
|
|
178
|
-
Top-center
|
|
179
|
-
</Button>
|
|
180
|
-
<Button
|
|
181
|
-
variant="secondary"
|
|
182
|
-
onClick={() =>
|
|
183
|
-
notify({
|
|
184
|
-
content: 'Top-right',
|
|
185
|
-
placement: 'top-right',
|
|
186
|
-
})
|
|
187
|
-
}
|
|
188
|
-
>
|
|
189
|
-
Top-right
|
|
190
|
-
</Button>
|
|
191
|
-
<Button
|
|
192
|
-
variant="secondary"
|
|
193
|
-
onClick={() =>
|
|
194
|
-
notify({
|
|
195
|
-
content: 'Bottom-left',
|
|
196
|
-
placement: 'bottom-left',
|
|
197
|
-
})
|
|
198
|
-
}
|
|
199
|
-
>
|
|
200
|
-
Bottom-left
|
|
201
|
-
</Button>
|
|
202
|
-
<Button
|
|
203
|
-
variant="secondary"
|
|
204
|
-
onClick={() =>
|
|
205
|
-
notify({
|
|
206
|
-
content: 'Bottom-center',
|
|
207
|
-
placement: 'bottom-center',
|
|
208
|
-
})
|
|
209
|
-
}
|
|
210
|
-
>
|
|
211
|
-
Bottom-center
|
|
212
|
-
</Button>
|
|
213
|
-
<Button
|
|
214
|
-
variant="secondary"
|
|
215
|
-
onClick={() =>
|
|
216
|
-
notify({
|
|
217
|
-
content: 'Bottom-right',
|
|
218
|
-
placement: 'bottom-right',
|
|
219
|
-
})
|
|
220
|
-
}
|
|
221
|
-
>
|
|
222
|
-
Bottom-right
|
|
223
|
-
</Button>
|
|
224
|
-
</Flexbox>
|
|
225
|
-
<ToastContainer />
|
|
226
|
-
</>
|
|
227
|
-
);
|
|
228
|
-
};
|
|
229
|
-
|
|
230
|
-
export const Dismiss = () => {
|
|
231
|
-
const toastId = React.useRef<number | string | null>(null);
|
|
232
|
-
const { notify, dismiss } = useToast();
|
|
233
|
-
|
|
234
|
-
return (
|
|
235
|
-
<>
|
|
236
|
-
<Flexbox>
|
|
237
|
-
<Button
|
|
238
|
-
onClick={() => {
|
|
239
|
-
toastId.current = notify({
|
|
240
|
-
content: 'Saved!',
|
|
241
|
-
autoClose: false,
|
|
242
|
-
closeButton: false,
|
|
243
|
-
});
|
|
244
|
-
}}
|
|
245
|
-
>
|
|
246
|
-
Notify
|
|
247
|
-
</Button>
|
|
248
|
-
<Button
|
|
249
|
-
onClick={() => {
|
|
250
|
-
if (toastId.current) {
|
|
251
|
-
dismiss(toastId.current);
|
|
252
|
-
}
|
|
253
|
-
}}
|
|
254
|
-
>
|
|
255
|
-
Dismiss
|
|
256
|
-
</Button>
|
|
257
|
-
<Button
|
|
258
|
-
onClick={() => {
|
|
259
|
-
dismiss();
|
|
260
|
-
}}
|
|
261
|
-
>
|
|
262
|
-
Dismiss all
|
|
263
|
-
</Button>
|
|
264
|
-
</Flexbox>
|
|
265
|
-
<ToastContainer />
|
|
266
|
-
</>
|
|
267
|
-
);
|
|
268
|
-
};
|
|
269
|
-
|
|
270
|
-
export const Update = () => {
|
|
271
|
-
const toastId = React.useRef<number | string | null>(null);
|
|
272
|
-
const { notify, update } = useToast();
|
|
273
|
-
|
|
274
|
-
return (
|
|
275
|
-
<>
|
|
276
|
-
<Flexbox>
|
|
277
|
-
<Button
|
|
278
|
-
onClick={() => {
|
|
279
|
-
toastId.current = notify({
|
|
280
|
-
content: 'Saving...',
|
|
281
|
-
variant: 'loading',
|
|
282
|
-
autoClose: false,
|
|
283
|
-
closeButton: false,
|
|
284
|
-
});
|
|
285
|
-
}}
|
|
286
|
-
>
|
|
287
|
-
Notify
|
|
288
|
-
</Button>
|
|
289
|
-
<Button
|
|
290
|
-
onClick={() => {
|
|
291
|
-
if (toastId.current) {
|
|
292
|
-
update(toastId.current, {
|
|
293
|
-
content: 'Saved!',
|
|
294
|
-
autoClose: 5000,
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
}}
|
|
298
|
-
>
|
|
299
|
-
Update
|
|
300
|
-
</Button>
|
|
301
|
-
</Flexbox>
|
|
302
|
-
<ToastContainer />
|
|
303
|
-
</>
|
|
304
|
-
);
|
|
305
|
-
};
|
|
306
|
-
|
|
307
|
-
export const WithPromise = () => {
|
|
308
|
-
const { promise } = useToast();
|
|
309
|
-
|
|
310
|
-
return (
|
|
311
|
-
<>
|
|
312
|
-
<Flexbox>
|
|
313
|
-
<Button
|
|
314
|
-
variant="secondary"
|
|
315
|
-
color="success"
|
|
316
|
-
onClick={() => {
|
|
317
|
-
const resolveAfter3Sec = new Promise((resolve) =>
|
|
318
|
-
setTimeout(resolve, 3000)
|
|
319
|
-
);
|
|
320
|
-
promise(resolveAfter3Sec, {
|
|
321
|
-
pending: { content: 'Promise is pending' },
|
|
322
|
-
success: { content: 'Promise resolved!' },
|
|
323
|
-
error: { content: 'Promise rejected!' },
|
|
324
|
-
});
|
|
325
|
-
}}
|
|
326
|
-
>
|
|
327
|
-
Successful promise
|
|
328
|
-
</Button>
|
|
329
|
-
<Button
|
|
330
|
-
variant="secondary"
|
|
331
|
-
color="error"
|
|
332
|
-
onClick={() => {
|
|
333
|
-
const failAfter3Sec = new Promise((_, reject) =>
|
|
334
|
-
setTimeout(reject, 3000)
|
|
335
|
-
);
|
|
336
|
-
promise(failAfter3Sec, {
|
|
337
|
-
pending: { content: 'Promise is pending' },
|
|
338
|
-
success: { content: 'Promise resolved!' },
|
|
339
|
-
error: { content: 'Promise rejected!' },
|
|
340
|
-
});
|
|
341
|
-
}}
|
|
342
|
-
>
|
|
343
|
-
Failing promise
|
|
344
|
-
</Button>
|
|
345
|
-
</Flexbox>
|
|
346
|
-
<ToastContainer />
|
|
347
|
-
</>
|
|
348
|
-
);
|
|
349
|
-
};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef, RefObject } from 'react';
|
|
2
|
-
import { Slide } from 'react-toastify';
|
|
3
|
-
|
|
4
|
-
import { Comp } from '@redsift/design-system';
|
|
5
|
-
import { ReactToastify, StyledToastContainer } from './styles';
|
|
6
|
-
import { ToastContainerProps } from './types';
|
|
7
|
-
|
|
8
|
-
const COMPONENT_NAME = 'ToastContainer';
|
|
9
|
-
const CLASSNAME = 'redsift-toast-container';
|
|
10
|
-
const DEFAULT_PROPS: Partial<ToastContainerProps> = {
|
|
11
|
-
autoClose: 5000,
|
|
12
|
-
closeOnClick: false,
|
|
13
|
-
draggable: true,
|
|
14
|
-
pauseOnFocusLoss: true,
|
|
15
|
-
pauseOnHover: true,
|
|
16
|
-
placement: 'top-right',
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* The ToastContainer component.
|
|
21
|
-
*/
|
|
22
|
-
export const ToastContainer: Comp<ToastContainerProps, HTMLDivElement> =
|
|
23
|
-
forwardRef((props, ref) => {
|
|
24
|
-
const { placement, ...forwardedProps } = props;
|
|
25
|
-
|
|
26
|
-
return (
|
|
27
|
-
<ReactToastify>
|
|
28
|
-
<StyledToastContainer
|
|
29
|
-
{...forwardedProps}
|
|
30
|
-
className={ToastContainer.className}
|
|
31
|
-
closeButton={false}
|
|
32
|
-
icon={false}
|
|
33
|
-
newestOnTop={placement!.includes('bottom')}
|
|
34
|
-
position={placement}
|
|
35
|
-
ref={ref as RefObject<HTMLDivElement>}
|
|
36
|
-
theme="colored"
|
|
37
|
-
transition={Slide}
|
|
38
|
-
/>
|
|
39
|
-
</ReactToastify>
|
|
40
|
-
);
|
|
41
|
-
});
|
|
42
|
-
ToastContainer.className = CLASSNAME;
|
|
43
|
-
ToastContainer.defaultProps = DEFAULT_PROPS;
|
|
44
|
-
ToastContainer.displayName = COMPONENT_NAME;
|