@rango-dev/ui 0.28.2-next.6 → 0.28.2-next.7
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/dist/index.js +2 -2
- package/dist/index.js.map +4 -4
- package/dist/widget/ui/src/components/Toast/Toast.d.ts.map +1 -1
- package/dist/widget/ui/src/components/Toast/Toast.helpers.d.ts +4 -0
- package/dist/widget/ui/src/components/Toast/Toast.helpers.d.ts.map +1 -1
- package/dist/widget/ui/src/components/Toast/Toast.styles.d.ts +167 -1
- package/dist/widget/ui/src/components/Toast/Toast.styles.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/Toast/Toast.helpers.ts +5 -0
- package/src/components/Toast/Toast.styles.ts +209 -5
- package/src/components/Toast/Toast.tsx +59 -34
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toast.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Toast/Toast.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,
|
|
1
|
+
{"version":3,"file":"Toast.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Toast/Toast.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,KAA8B,MAAM,OAAO,CAAC;AAmBnD,eAAO,MAAM,KAAK,UAAW,UAAU,sBAyFtC,CAAC"}
|
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
export declare function idGenerator(): () => number;
|
|
2
|
+
export declare const TOAST_UNMOUNT_DELAY = 500;
|
|
3
|
+
export declare const TOAST_TRANSITION_DURATION = 300;
|
|
4
|
+
export declare const HOVER_TRANSITION_DURATION = 200;
|
|
5
|
+
export declare const TOAST_HIDE_DELAY = 200;
|
|
2
6
|
//# sourceMappingURL=Toast.helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toast.helpers.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Toast/Toast.helpers.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,iBAM1B"}
|
|
1
|
+
{"version":3,"file":"Toast.helpers.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Toast/Toast.helpers.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,iBAM1B;AAED,eAAO,MAAM,mBAAmB,MAAM,CAAC;AACvC,eAAO,MAAM,yBAAyB,MAAM,CAAC;AAC7C,eAAO,MAAM,yBAAyB,MAAM,CAAC;AAC7C,eAAO,MAAM,gBAAgB,MAAM,CAAC"}
|
|
@@ -1,5 +1,171 @@
|
|
|
1
1
|
import { Typography } from '../Typography';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const toastContentStyles: import("@stitches/react/types/styled-component").CssComponent<never, {}, {
|
|
3
|
+
xs: string;
|
|
4
|
+
sm: string;
|
|
5
|
+
md: string;
|
|
6
|
+
lg: string;
|
|
7
|
+
}, import("@stitches/react/types/css-util").CSS<{
|
|
8
|
+
xs: string;
|
|
9
|
+
sm: string;
|
|
10
|
+
md: string;
|
|
11
|
+
lg: string;
|
|
12
|
+
}, {
|
|
13
|
+
colors: {
|
|
14
|
+
primary: string;
|
|
15
|
+
primary500: string;
|
|
16
|
+
primary600: string;
|
|
17
|
+
secondary: string;
|
|
18
|
+
secondary100: string;
|
|
19
|
+
secondary200: string;
|
|
20
|
+
secondary300: string;
|
|
21
|
+
secondary400: string;
|
|
22
|
+
secondary500: string;
|
|
23
|
+
secondary600: string;
|
|
24
|
+
secondary700: string;
|
|
25
|
+
secondary800: string;
|
|
26
|
+
secondary900: string;
|
|
27
|
+
neutral: string;
|
|
28
|
+
neutral100: string;
|
|
29
|
+
neutral200: string;
|
|
30
|
+
neutral300: string;
|
|
31
|
+
neutral400: string;
|
|
32
|
+
neutral500: string;
|
|
33
|
+
neutral600: string;
|
|
34
|
+
neutral700: string;
|
|
35
|
+
neutral800: string;
|
|
36
|
+
neutral900: string;
|
|
37
|
+
error100: string;
|
|
38
|
+
error300: string;
|
|
39
|
+
error500: string;
|
|
40
|
+
error600: string;
|
|
41
|
+
error700: string;
|
|
42
|
+
warning100: string;
|
|
43
|
+
warning300: string;
|
|
44
|
+
warning500: string;
|
|
45
|
+
warning600: string;
|
|
46
|
+
warning700: string;
|
|
47
|
+
info: string;
|
|
48
|
+
info100: string;
|
|
49
|
+
info300: string;
|
|
50
|
+
info500: string;
|
|
51
|
+
info600: string;
|
|
52
|
+
info700: string;
|
|
53
|
+
success100: string;
|
|
54
|
+
success300: string;
|
|
55
|
+
success500: string;
|
|
56
|
+
success600: string;
|
|
57
|
+
success700: string;
|
|
58
|
+
background: string;
|
|
59
|
+
foreground: string;
|
|
60
|
+
};
|
|
61
|
+
space: {
|
|
62
|
+
0: string;
|
|
63
|
+
5: string;
|
|
64
|
+
10: string;
|
|
65
|
+
15: string;
|
|
66
|
+
20: string;
|
|
67
|
+
25: string;
|
|
68
|
+
30: string;
|
|
69
|
+
40: string;
|
|
70
|
+
46: string;
|
|
71
|
+
50: string;
|
|
72
|
+
60: string;
|
|
73
|
+
70: string;
|
|
74
|
+
80: string;
|
|
75
|
+
90: string;
|
|
76
|
+
100: string;
|
|
77
|
+
2: string;
|
|
78
|
+
4: string;
|
|
79
|
+
6: string;
|
|
80
|
+
8: string;
|
|
81
|
+
12: string;
|
|
82
|
+
16: string;
|
|
83
|
+
24: string;
|
|
84
|
+
28: string;
|
|
85
|
+
32: string;
|
|
86
|
+
};
|
|
87
|
+
radii: {
|
|
88
|
+
xs: string;
|
|
89
|
+
sm: string;
|
|
90
|
+
xm: string;
|
|
91
|
+
md: string;
|
|
92
|
+
xl: string;
|
|
93
|
+
lg: string;
|
|
94
|
+
primary: string;
|
|
95
|
+
secondary: string;
|
|
96
|
+
};
|
|
97
|
+
fontSizes: {
|
|
98
|
+
10: string;
|
|
99
|
+
12: string;
|
|
100
|
+
14: string;
|
|
101
|
+
16: string;
|
|
102
|
+
18: string;
|
|
103
|
+
20: string;
|
|
104
|
+
22: string;
|
|
105
|
+
24: string;
|
|
106
|
+
28: string;
|
|
107
|
+
32: string;
|
|
108
|
+
36: string;
|
|
109
|
+
40: string;
|
|
110
|
+
48: string;
|
|
111
|
+
};
|
|
112
|
+
fonts: {
|
|
113
|
+
primary: string;
|
|
114
|
+
widget: string;
|
|
115
|
+
};
|
|
116
|
+
fontWeights: {
|
|
117
|
+
regular: number;
|
|
118
|
+
medium: number;
|
|
119
|
+
semiBold: number;
|
|
120
|
+
bold: number;
|
|
121
|
+
};
|
|
122
|
+
lineHeights: {
|
|
123
|
+
12: string;
|
|
124
|
+
16: string;
|
|
125
|
+
20: string;
|
|
126
|
+
24: string;
|
|
127
|
+
26: string;
|
|
128
|
+
28: string;
|
|
129
|
+
30: string;
|
|
130
|
+
36: string;
|
|
131
|
+
40: string;
|
|
132
|
+
44: string;
|
|
133
|
+
52: string;
|
|
134
|
+
64: string;
|
|
135
|
+
};
|
|
136
|
+
letterSpacings: {};
|
|
137
|
+
sizes: {
|
|
138
|
+
4: string;
|
|
139
|
+
6: string;
|
|
140
|
+
8: string;
|
|
141
|
+
10: string;
|
|
142
|
+
12: string;
|
|
143
|
+
16: string;
|
|
144
|
+
18: string;
|
|
145
|
+
20: string;
|
|
146
|
+
24: string;
|
|
147
|
+
26: string;
|
|
148
|
+
28: string;
|
|
149
|
+
30: string;
|
|
150
|
+
32: string;
|
|
151
|
+
36: string;
|
|
152
|
+
40: string;
|
|
153
|
+
45: string;
|
|
154
|
+
48: string;
|
|
155
|
+
};
|
|
156
|
+
borderWidths: {};
|
|
157
|
+
borderStyles: {};
|
|
158
|
+
shadows: {
|
|
159
|
+
s: string;
|
|
160
|
+
};
|
|
161
|
+
zIndices: {};
|
|
162
|
+
transitions: {};
|
|
163
|
+
}, import("@stitches/react/types/config").DefaultThemeMap, {}>>;
|
|
164
|
+
export declare const ToastContentContainer: import("@stitches/react/types/styled-component").StyledComponent<"div", {
|
|
165
|
+
isActive?: boolean | "true" | undefined;
|
|
166
|
+
isVisible?: boolean | "true" | undefined;
|
|
167
|
+
position?: "right-top" | "right-bottom" | "left-top" | "left-bottom" | "center-top" | "center-bottom" | undefined;
|
|
168
|
+
}, {
|
|
3
169
|
xs: string;
|
|
4
170
|
sm: string;
|
|
5
171
|
md: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toast.styles.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Toast/Toast.styles.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAO3C,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"Toast.styles.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Toast/Toast.styles.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAO3C,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+DAK7B,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+DAmMhC,CAAC;AAEH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+DAwCzB,CAAC;AAEH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+DAwEnB,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+DAI7B,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+DAa3B,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+DAG9B,CAAC"}
|
package/package.json
CHANGED
|
@@ -5,3 +5,8 @@ export function idGenerator() {
|
|
|
5
5
|
return id;
|
|
6
6
|
};
|
|
7
7
|
}
|
|
8
|
+
|
|
9
|
+
export const TOAST_UNMOUNT_DELAY = 500; // the delay before the toast is unmounted
|
|
10
|
+
export const TOAST_TRANSITION_DURATION = 300; // the duration of the toast transition
|
|
11
|
+
export const HOVER_TRANSITION_DURATION = 200; // the duration of the toast transition hover
|
|
12
|
+
export const TOAST_HIDE_DELAY = 200; // the delay before the toast is invisible to shift remained toast smoothly
|
|
@@ -1,16 +1,217 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { css, darkTheme, lightTheme, styled } from '../../theme';
|
|
2
2
|
import { Typography } from '../Typography';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import {
|
|
5
|
+
HOVER_TRANSITION_DURATION,
|
|
6
|
+
TOAST_TRANSITION_DURATION,
|
|
7
|
+
} from './Toast.helpers';
|
|
8
|
+
|
|
9
|
+
export const toastContentStyles = css({
|
|
10
|
+
transition: `transform ${HOVER_TRANSITION_DURATION}ms ease-in-out`,
|
|
11
|
+
'&:hover': {
|
|
12
|
+
transform: 'scale(0.99)',
|
|
13
|
+
},
|
|
7
14
|
});
|
|
8
15
|
|
|
9
16
|
export const ToastContentContainer = styled('div', {
|
|
10
|
-
|
|
17
|
+
transition: `transform ${TOAST_TRANSITION_DURATION}ms cubic-bezier(0, 0, 0.75, 1.25)`,
|
|
18
|
+
cursor: 'pointer',
|
|
19
|
+
variants: {
|
|
20
|
+
isActive: {
|
|
21
|
+
true: {},
|
|
22
|
+
},
|
|
23
|
+
isVisible: {
|
|
24
|
+
true: {},
|
|
25
|
+
},
|
|
26
|
+
position: {
|
|
27
|
+
'right-top': {},
|
|
28
|
+
'right-bottom': {},
|
|
29
|
+
'left-top': {},
|
|
30
|
+
'left-bottom': {},
|
|
31
|
+
'center-top': {},
|
|
32
|
+
'center-bottom': {},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
compoundVariants: [
|
|
36
|
+
{
|
|
37
|
+
position: 'right-top',
|
|
38
|
+
isActive: true,
|
|
39
|
+
isVisible: true,
|
|
40
|
+
css: {
|
|
41
|
+
transform: 'translateX(0)',
|
|
42
|
+
maxHeight: '200px',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
position: 'right-top',
|
|
47
|
+
isActive: false,
|
|
48
|
+
isVisible: true,
|
|
49
|
+
css: {
|
|
50
|
+
maxHeight: '200px',
|
|
51
|
+
transform: 'translateX(100%)',
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
position: 'right-top',
|
|
56
|
+
isActive: false,
|
|
57
|
+
isVisible: false,
|
|
58
|
+
css: {
|
|
59
|
+
maxHeight: '0px',
|
|
60
|
+
transform: 'translateX(100%)',
|
|
61
|
+
transition: `max-height ${TOAST_TRANSITION_DURATION}ms ease-in-out`,
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
position: 'right-bottom',
|
|
66
|
+
isActive: true,
|
|
67
|
+
isVisible: true,
|
|
68
|
+
css: {
|
|
69
|
+
transform: 'translateX(0)',
|
|
70
|
+
maxHeight: '200px',
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
position: 'right-bottom',
|
|
75
|
+
isActive: false,
|
|
76
|
+
isVisible: true,
|
|
77
|
+
css: {
|
|
78
|
+
transform: 'translateX(100%)',
|
|
79
|
+
maxHeight: '200px',
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
position: 'right-bottom',
|
|
84
|
+
isActive: false,
|
|
85
|
+
isVisible: false,
|
|
86
|
+
css: {
|
|
87
|
+
transform: 'translateX(100%)',
|
|
88
|
+
maxHeight: '0px',
|
|
89
|
+
transition: `max-height ${TOAST_TRANSITION_DURATION}ms ease-in-out`,
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
position: 'left-top',
|
|
94
|
+
isActive: true,
|
|
95
|
+
isVisible: true,
|
|
96
|
+
css: {
|
|
97
|
+
transform: 'translateX(0)',
|
|
98
|
+
maxHeight: '200px',
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
position: 'left-top',
|
|
103
|
+
isActive: false,
|
|
104
|
+
isVisible: true,
|
|
105
|
+
css: {
|
|
106
|
+
transform: 'translateX(-100%)',
|
|
107
|
+
maxHeight: '200px',
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
position: 'left-top',
|
|
112
|
+
isActive: false,
|
|
113
|
+
isVisible: false,
|
|
114
|
+
css: {
|
|
115
|
+
transform: 'translateX(-100%)',
|
|
116
|
+
maxHeight: '0px',
|
|
117
|
+
transition: `max-height ${TOAST_TRANSITION_DURATION}ms ease-in-out`,
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
position: 'left-bottom',
|
|
122
|
+
isActive: true,
|
|
123
|
+
isVisible: true,
|
|
124
|
+
css: {
|
|
125
|
+
transform: 'translateX(0)',
|
|
126
|
+
maxHeight: '200px',
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
position: 'left-bottom',
|
|
131
|
+
isActive: false,
|
|
132
|
+
isVisible: true,
|
|
133
|
+
css: {
|
|
134
|
+
transform: 'translateX(-100%)',
|
|
135
|
+
maxHeight: '200px',
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
position: 'left-bottom',
|
|
140
|
+
isActive: false,
|
|
141
|
+
isVisible: false,
|
|
142
|
+
css: {
|
|
143
|
+
transform: 'translateX(-100%)',
|
|
144
|
+
maxHeight: '0px',
|
|
145
|
+
transition: `max-height ${TOAST_TRANSITION_DURATION}ms ease-in-out`,
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
position: 'center-top',
|
|
150
|
+
isActive: true,
|
|
151
|
+
isVisible: true,
|
|
152
|
+
css: {
|
|
153
|
+
maxHeight: '200px',
|
|
154
|
+
transform: 'translateY(0)',
|
|
155
|
+
opacity: 1,
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
position: 'center-top',
|
|
160
|
+
isActive: false,
|
|
161
|
+
isVisible: true,
|
|
162
|
+
css: {
|
|
163
|
+
maxHeight: '200px',
|
|
164
|
+
transform: 'translateY(-1000%)',
|
|
165
|
+
opacity: 0,
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
position: 'center-top',
|
|
170
|
+
isActive: false,
|
|
171
|
+
isVisible: false,
|
|
172
|
+
css: {
|
|
173
|
+
maxHeight: '0px',
|
|
174
|
+
opacity: 0,
|
|
175
|
+
transform: 'translateY(-1000%)',
|
|
176
|
+
transition: `max-height ${TOAST_TRANSITION_DURATION}ms ease-in-out`,
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
position: 'center-bottom',
|
|
181
|
+
isActive: true,
|
|
182
|
+
isVisible: true,
|
|
183
|
+
css: {
|
|
184
|
+
transform: 'translateY(0)',
|
|
185
|
+
maxHeight: '200px',
|
|
186
|
+
opacity: 1,
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
position: 'center-bottom',
|
|
191
|
+
isActive: false,
|
|
192
|
+
isVisible: true,
|
|
193
|
+
css: {
|
|
194
|
+
transform: 'translateY(1000%)',
|
|
195
|
+
maxHeight: '200px',
|
|
196
|
+
opacity: 0,
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
position: 'center-bottom',
|
|
201
|
+
isActive: false,
|
|
202
|
+
isVisible: false,
|
|
203
|
+
css: {
|
|
204
|
+
transform: 'translateY(1000%)',
|
|
205
|
+
maxHeight: '0px',
|
|
206
|
+
opacity: 0,
|
|
207
|
+
transition: `max-height ${TOAST_TRANSITION_DURATION}ms ease-in-out`,
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
],
|
|
11
211
|
});
|
|
12
212
|
|
|
13
213
|
export const ToastContainer = styled('div', {
|
|
214
|
+
overflow: 'hidden',
|
|
14
215
|
position: 'absolute',
|
|
15
216
|
zIndex: 9999,
|
|
16
217
|
display: 'flex',
|
|
@@ -25,6 +226,7 @@ export const ToastContainer = styled('div', {
|
|
|
25
226
|
'right-bottom': {
|
|
26
227
|
right: 12,
|
|
27
228
|
bottom: 2,
|
|
229
|
+
flexDirection: 'column-reverse',
|
|
28
230
|
},
|
|
29
231
|
'left-top': {
|
|
30
232
|
left: 12,
|
|
@@ -33,6 +235,7 @@ export const ToastContainer = styled('div', {
|
|
|
33
235
|
'left-bottom': {
|
|
34
236
|
left: 12,
|
|
35
237
|
bottom: 2,
|
|
238
|
+
flexDirection: 'column-reverse',
|
|
36
239
|
},
|
|
37
240
|
'center-top': {
|
|
38
241
|
left: '50%',
|
|
@@ -43,6 +246,7 @@ export const ToastContainer = styled('div', {
|
|
|
43
246
|
left: '50%',
|
|
44
247
|
transform: 'translateX(-50%)',
|
|
45
248
|
bottom: 2,
|
|
249
|
+
flexDirection: 'column-reverse',
|
|
46
250
|
},
|
|
47
251
|
},
|
|
48
252
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ToastProps } from './Toast.types';
|
|
2
2
|
|
|
3
|
-
import React, { useEffect } from 'react';
|
|
3
|
+
import React, { useEffect, useState } from 'react';
|
|
4
4
|
|
|
5
5
|
import { CloseIcon } from '../../icons';
|
|
6
6
|
import { Alert } from '../Alert';
|
|
@@ -9,12 +9,14 @@ import AlertIcon from '../Alert/AlertIcon';
|
|
|
9
9
|
import { Divider } from '../Divider';
|
|
10
10
|
import { IconButton } from '../IconButton';
|
|
11
11
|
|
|
12
|
+
import { TOAST_HIDE_DELAY, TOAST_UNMOUNT_DELAY } from './Toast.helpers';
|
|
12
13
|
import { useToast } from './Toast.Provider';
|
|
13
14
|
import {
|
|
14
15
|
AlertBox,
|
|
15
16
|
AlertFlexContainer,
|
|
16
17
|
StyledTypography,
|
|
17
18
|
ToastContentContainer,
|
|
19
|
+
toastContentStyles,
|
|
18
20
|
} from './Toast.styles';
|
|
19
21
|
|
|
20
22
|
export const Toast = (props: ToastProps) => {
|
|
@@ -29,6 +31,8 @@ export const Toast = (props: ToastProps) => {
|
|
|
29
31
|
hideOnTap = true,
|
|
30
32
|
variant = 'standard',
|
|
31
33
|
} = props;
|
|
34
|
+
const [isActive, setIsActive] = useState(false);
|
|
35
|
+
const [isVisible, setIsVisible] = useState(false);
|
|
32
36
|
const { removeToast } = useToast();
|
|
33
37
|
useEffect(() => {
|
|
34
38
|
let cleanup;
|
|
@@ -45,42 +49,63 @@ export const Toast = (props: ToastProps) => {
|
|
|
45
49
|
}, [id]);
|
|
46
50
|
|
|
47
51
|
const handleClose = () => {
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
setIsActive(false);
|
|
53
|
+
setTimeout(() => {
|
|
54
|
+
setIsVisible(false);
|
|
55
|
+
}, TOAST_HIDE_DELAY);
|
|
56
|
+
setTimeout(() => {
|
|
57
|
+
removeToast(id, position);
|
|
58
|
+
onClose?.();
|
|
59
|
+
}, TOAST_UNMOUNT_DELAY);
|
|
50
60
|
};
|
|
51
61
|
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
setIsVisible(true);
|
|
64
|
+
setTimeout(() => {
|
|
65
|
+
setIsActive(true);
|
|
66
|
+
}, 0);
|
|
67
|
+
}, []);
|
|
68
|
+
|
|
52
69
|
return (
|
|
53
|
-
<ToastContentContainer
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
<
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
70
|
+
<ToastContentContainer
|
|
71
|
+
isActive={isActive}
|
|
72
|
+
position={position}
|
|
73
|
+
isVisible={isVisible}>
|
|
74
|
+
<div className={toastContentStyles()}>
|
|
75
|
+
<AlertBox
|
|
76
|
+
onClick={hideOnTap ? handleClose : undefined}
|
|
77
|
+
variant={variant}
|
|
78
|
+
type={type}>
|
|
79
|
+
{variant === 'custom' ? (
|
|
80
|
+
<AlertFlexContainer>
|
|
81
|
+
<IconHighlight type={type} align="center">
|
|
82
|
+
<AlertIcon type={type} />
|
|
83
|
+
</IconHighlight>
|
|
84
|
+
<Divider direction="horizontal" size={10} />
|
|
85
|
+
<StyledTypography variant="body" size="small" align="left">
|
|
86
|
+
{props.title}
|
|
87
|
+
</StyledTypography>
|
|
88
|
+
</AlertFlexContainer>
|
|
89
|
+
) : (
|
|
90
|
+
<Alert
|
|
91
|
+
title={title}
|
|
92
|
+
type={type}
|
|
93
|
+
variant="alarm"
|
|
94
|
+
titleAlign="left"
|
|
95
|
+
action={
|
|
96
|
+
hasCloseIcon ? (
|
|
97
|
+
<IconButton
|
|
98
|
+
variant="ghost"
|
|
99
|
+
size="xsmall"
|
|
100
|
+
onClick={handleClose}>
|
|
101
|
+
<CloseIcon size={12} />
|
|
102
|
+
</IconButton>
|
|
103
|
+
) : undefined
|
|
104
|
+
}
|
|
105
|
+
/>
|
|
106
|
+
)}
|
|
107
|
+
</AlertBox>
|
|
108
|
+
</div>
|
|
84
109
|
</ToastContentContainer>
|
|
85
110
|
);
|
|
86
111
|
};
|