@snack-uikit/toaster 0.3.21-preview-85c5f47b.0
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/CHANGELOG.md +317 -0
- package/LICENSE +201 -0
- package/README.md +84 -0
- package/dist/components/ToastSystemEvent/ToastSystemEvent.d.ts +23 -0
- package/dist/components/ToastSystemEvent/ToastSystemEvent.js +36 -0
- package/dist/components/ToastSystemEvent/constants.d.ts +15 -0
- package/dist/components/ToastSystemEvent/constants.js +16 -0
- package/dist/components/ToastSystemEvent/index.d.ts +1 -0
- package/dist/components/ToastSystemEvent/index.js +1 -0
- package/dist/components/ToastSystemEvent/styles.module.css +183 -0
- package/dist/components/ToastSystemEvent/utils.d.ts +2 -0
- package/dist/components/ToastSystemEvent/utils.js +17 -0
- package/dist/components/ToastUserAction/ToastUserAction.d.ts +19 -0
- package/dist/components/ToastUserAction/ToastUserAction.js +26 -0
- package/dist/components/ToastUserAction/constants.d.ts +10 -0
- package/dist/components/ToastUserAction/constants.js +12 -0
- package/dist/components/ToastUserAction/index.d.ts +1 -0
- package/dist/components/ToastUserAction/index.js +1 -0
- package/dist/components/ToastUserAction/styles.module.css +56 -0
- package/dist/components/ToastUserAction/utils.d.ts +2 -0
- package/dist/components/ToastUserAction/utils.js +16 -0
- package/dist/components/ToasterContainer/ToasterContainer.d.ts +21 -0
- package/dist/components/ToasterContainer/ToasterContainer.js +36 -0
- package/dist/components/ToasterContainer/index.d.ts +1 -0
- package/dist/components/ToasterContainer/index.js +1 -0
- package/dist/components/ToasterContainer/styles.module.css +78 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.js +3 -0
- package/dist/constants.d.ts +9 -0
- package/dist/constants.js +22 -0
- package/dist/helpers.d.ts +6 -0
- package/dist/helpers.js +199 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/testIds.d.ts +16 -0
- package/dist/testIds.js +18 -0
- package/dist/types.d.ts +67 -0
- package/dist/types.js +5 -0
- package/package.json +43 -0
- package/src/components/ToastSystemEvent/ToastSystemEvent.tsx +119 -0
- package/src/components/ToastSystemEvent/constants.ts +17 -0
- package/src/components/ToastSystemEvent/index.ts +1 -0
- package/src/components/ToastSystemEvent/styles.module.scss +194 -0
- package/src/components/ToastSystemEvent/utils.tsx +18 -0
- package/src/components/ToastUserAction/ToastUserAction.tsx +68 -0
- package/src/components/ToastUserAction/constants.tsx +11 -0
- package/src/components/ToastUserAction/index.ts +1 -0
- package/src/components/ToastUserAction/styles.module.scss +66 -0
- package/src/components/ToastUserAction/utils.tsx +17 -0
- package/src/components/ToasterContainer/ToasterContainer.tsx +93 -0
- package/src/components/ToasterContainer/index.ts +1 -0
- package/src/components/ToasterContainer/styles.module.scss +81 -0
- package/src/components/index.ts +3 -0
- package/src/constants.ts +25 -0
- package/src/helpers.tsx +293 -0
- package/src/index.ts +3 -0
- package/src/testIds.ts +21 -0
- package/src/types.ts +82 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { OnColor } from '@snack-uikit/link';
|
|
2
|
+
export var ToastSystemEventAppearance;
|
|
3
|
+
(function (ToastSystemEventAppearance) {
|
|
4
|
+
ToastSystemEventAppearance["Neutral"] = "neutral";
|
|
5
|
+
ToastSystemEventAppearance["Error"] = "error";
|
|
6
|
+
ToastSystemEventAppearance["ErrorCritical"] = "errorCritical";
|
|
7
|
+
ToastSystemEventAppearance["Warning"] = "warning";
|
|
8
|
+
ToastSystemEventAppearance["Success"] = "success";
|
|
9
|
+
})(ToastSystemEventAppearance || (ToastSystemEventAppearance = {}));
|
|
10
|
+
export const APPEARANCE_TO_ON_COLOR_MAP = {
|
|
11
|
+
[ToastSystemEventAppearance.Neutral]: OnColor.InvertNeutral,
|
|
12
|
+
[ToastSystemEventAppearance.Error]: OnColor.InvertNeutral,
|
|
13
|
+
[ToastSystemEventAppearance.ErrorCritical]: OnColor.Red,
|
|
14
|
+
[ToastSystemEventAppearance.Warning]: OnColor.InvertNeutral,
|
|
15
|
+
[ToastSystemEventAppearance.Success]: OnColor.InvertNeutral,
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ToastSystemEvent';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ToastSystemEvent';
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
.icon svg{
|
|
2
|
+
width:var(--dimension-3m, 24px) !important;
|
|
3
|
+
height:var(--dimension-3m, 24px) !important;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.buttonClose{
|
|
7
|
+
width:var(--size-toaster-toast-system-event-button-close, 24px);
|
|
8
|
+
height:var(--size-toaster-toast-system-event-button-close, 24px);
|
|
9
|
+
border-radius:var(--radius-toaster-toast-system-event-button-close, 8px);
|
|
10
|
+
cursor:pointer;
|
|
11
|
+
display:flex;
|
|
12
|
+
align-items:center;
|
|
13
|
+
justify-content:center;
|
|
14
|
+
box-sizing:border-box;
|
|
15
|
+
margin:0;
|
|
16
|
+
padding:0;
|
|
17
|
+
color:var(--sys-invert-neutral-text-light, #898989);
|
|
18
|
+
background-color:transparent;
|
|
19
|
+
border:none;
|
|
20
|
+
}
|
|
21
|
+
.buttonClose svg{
|
|
22
|
+
width:var(--dimension-3m, 24px) !important;
|
|
23
|
+
height:var(--dimension-3m, 24px) !important;
|
|
24
|
+
}
|
|
25
|
+
.buttonClose:hover{
|
|
26
|
+
color:var(--sys-invert-neutral-text-main, #e7e7e7);
|
|
27
|
+
}
|
|
28
|
+
.buttonClose:focus, .buttonClose:active{
|
|
29
|
+
color:var(--sys-invert-neutral-accent-pressed, #9e9e9e);
|
|
30
|
+
}
|
|
31
|
+
.buttonClose:focus-visible{
|
|
32
|
+
outline-width:var(--border-state-focus-s-border-width, 2px);
|
|
33
|
+
outline-style:var(--border-state-focus-s-border-style, solid);
|
|
34
|
+
outline-color:var(--border-state-focus-s-border-color, );
|
|
35
|
+
color:var(--sys-invert-neutral-text-main, #e7e7e7);
|
|
36
|
+
outline-color:var(--sys-available-on-complementary, #fdfdfd);
|
|
37
|
+
outline-offset:var(--spacing-state-focus-offset, 2px);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.content{
|
|
41
|
+
gap:var(--space-toaster-toast-system-event-container-content-gap, 8px);
|
|
42
|
+
padding-top:var(--space-toaster-toast-system-event-container-content-padding-top, 2px);
|
|
43
|
+
display:flex;
|
|
44
|
+
flex:1;
|
|
45
|
+
flex-direction:column;
|
|
46
|
+
word-break:break-word;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.title{
|
|
50
|
+
font-family:var(--sans-title-s-font-family, SB Sans Interface);
|
|
51
|
+
font-weight:var(--sans-title-s-font-weight, Semibold);
|
|
52
|
+
line-height:var(--sans-title-s-line-height, 20px);
|
|
53
|
+
font-size:var(--sans-title-s-font-size, 14px);
|
|
54
|
+
letter-spacing:var(--sans-title-s-letter-spacing, 0.15px);
|
|
55
|
+
paragraph-spacing:var(--sans-title-s-paragraph-spacing, 7.7px);
|
|
56
|
+
display:grid;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.description{
|
|
60
|
+
font-family:var(--sans-body-m-font-family, SB Sans Interface);
|
|
61
|
+
font-weight:var(--sans-body-m-font-weight, Regular);
|
|
62
|
+
line-height:var(--sans-body-m-line-height, 20px);
|
|
63
|
+
font-size:var(--sans-body-m-font-size, 14px);
|
|
64
|
+
letter-spacing:var(--sans-body-m-letter-spacing, 0.1px);
|
|
65
|
+
paragraph-spacing:var(--sans-body-m-paragraph-spacing, 7.7px);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@keyframes progressBarAnimation{
|
|
69
|
+
0%{
|
|
70
|
+
width:100%;
|
|
71
|
+
}
|
|
72
|
+
100%{
|
|
73
|
+
width:0;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
.progress{
|
|
77
|
+
height:var(--size-toaster-toast-system-event-progress-bar, 4px);
|
|
78
|
+
position:absolute;
|
|
79
|
+
bottom:0;
|
|
80
|
+
left:0;
|
|
81
|
+
width:0;
|
|
82
|
+
animation:progressBarAnimation linear 1 forwards;
|
|
83
|
+
animation-play-state:active;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.container{
|
|
87
|
+
padding:var(--space-toaster-toast-system-event-container-padding, 16px);
|
|
88
|
+
border-radius:var(--radius-toaster-toast-system-event-container, 16px);
|
|
89
|
+
gap:var(--space-toaster-toast-system-event-container-gap, 16px);
|
|
90
|
+
cursor:default;
|
|
91
|
+
position:relative;
|
|
92
|
+
overflow:hidden;
|
|
93
|
+
display:flex;
|
|
94
|
+
box-sizing:border-box;
|
|
95
|
+
}
|
|
96
|
+
.container:hover .progress{
|
|
97
|
+
animation-play-state:paused;
|
|
98
|
+
}
|
|
99
|
+
.container[data-appearance=neutral]{
|
|
100
|
+
background-color:var(--sys-invert-neutral-background, #232323);
|
|
101
|
+
}
|
|
102
|
+
.container[data-appearance=neutral] .icon{
|
|
103
|
+
color:var(--sys-invert-neutral-accent-default, #d2d2d2);
|
|
104
|
+
}
|
|
105
|
+
.container[data-appearance=neutral] .title{
|
|
106
|
+
color:var(--sys-invert-neutral-text-main, #e7e7e7);
|
|
107
|
+
}
|
|
108
|
+
.container[data-appearance=neutral] .description{
|
|
109
|
+
color:var(--sys-invert-neutral-text-support, #b8b8b8);
|
|
110
|
+
}
|
|
111
|
+
.container[data-appearance=neutral] .progress{
|
|
112
|
+
background-color:var(--sys-neutral-accent-default, #757575);
|
|
113
|
+
}
|
|
114
|
+
.container[data-appearance=error]{
|
|
115
|
+
background-color:var(--sys-invert-neutral-background, #232323);
|
|
116
|
+
}
|
|
117
|
+
.container[data-appearance=error] .icon{
|
|
118
|
+
color:var(--sys-red-accent-default, #d93f2f);
|
|
119
|
+
}
|
|
120
|
+
.container[data-appearance=error] .title{
|
|
121
|
+
color:var(--sys-invert-neutral-text-main, #e7e7e7);
|
|
122
|
+
}
|
|
123
|
+
.container[data-appearance=error] .description{
|
|
124
|
+
color:var(--sys-invert-neutral-text-support, #b8b8b8);
|
|
125
|
+
}
|
|
126
|
+
.container[data-appearance=error] .progress{
|
|
127
|
+
background-color:var(--sys-red-accent-default, #d93f2f);
|
|
128
|
+
}
|
|
129
|
+
.container[data-appearance=errorCritical]{
|
|
130
|
+
background-color:var(--sys-red-accent-default, #d93f2f);
|
|
131
|
+
}
|
|
132
|
+
.container[data-appearance=errorCritical] .icon{
|
|
133
|
+
color:var(--sys-red-on-accent, #fffbfa);
|
|
134
|
+
}
|
|
135
|
+
.container[data-appearance=errorCritical] .title{
|
|
136
|
+
color:var(--sys-red-on-accent, #fffbfa);
|
|
137
|
+
}
|
|
138
|
+
.container[data-appearance=errorCritical] .description{
|
|
139
|
+
color:var(--sys-red-on-accent, #fffbfa);
|
|
140
|
+
}
|
|
141
|
+
.container[data-appearance=errorCritical] .progress{
|
|
142
|
+
background-color:var(--sys-red-decor-activated, #ffa491);
|
|
143
|
+
}
|
|
144
|
+
.container[data-appearance=errorCritical] .buttonClose{
|
|
145
|
+
color:var(--sys-red-on-accent, #fffbfa);
|
|
146
|
+
opacity:var(--opacity-a064, 0.64);
|
|
147
|
+
}
|
|
148
|
+
.container[data-appearance=errorCritical] .buttonClose:hover, .container[data-appearance=errorCritical] .buttonClose:focus-visible{
|
|
149
|
+
opacity:1;
|
|
150
|
+
}
|
|
151
|
+
.container[data-appearance=errorCritical] .buttonClose:active{
|
|
152
|
+
opacity:var(--opacity-a048, 0.48);
|
|
153
|
+
}
|
|
154
|
+
.container[data-appearance=warning]{
|
|
155
|
+
background-color:var(--sys-invert-neutral-background, #232323);
|
|
156
|
+
}
|
|
157
|
+
.container[data-appearance=warning] .icon{
|
|
158
|
+
color:var(--sys-yellow-accent-default, #feb528);
|
|
159
|
+
}
|
|
160
|
+
.container[data-appearance=warning] .title{
|
|
161
|
+
color:var(--sys-invert-neutral-text-main, #e7e7e7);
|
|
162
|
+
}
|
|
163
|
+
.container[data-appearance=warning] .description{
|
|
164
|
+
color:var(--sys-invert-neutral-text-support, #b8b8b8);
|
|
165
|
+
}
|
|
166
|
+
.container[data-appearance=warning] .progress{
|
|
167
|
+
background-color:var(--sys-yellow-accent-default, #feb528);
|
|
168
|
+
}
|
|
169
|
+
.container[data-appearance=success]{
|
|
170
|
+
background-color:var(--sys-invert-neutral-background, #232323);
|
|
171
|
+
}
|
|
172
|
+
.container[data-appearance=success] .icon{
|
|
173
|
+
color:var(--sys-green-accent-default, #0bbe8f);
|
|
174
|
+
}
|
|
175
|
+
.container[data-appearance=success] .title{
|
|
176
|
+
color:var(--sys-invert-neutral-text-main, #e7e7e7);
|
|
177
|
+
}
|
|
178
|
+
.container[data-appearance=success] .description{
|
|
179
|
+
color:var(--sys-invert-neutral-text-support, #b8b8b8);
|
|
180
|
+
}
|
|
181
|
+
.container[data-appearance=success] .progress{
|
|
182
|
+
background-color:var(--sys-green-accent-default, #0bbe8f);
|
|
183
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { AlarmFilledSVG, CheckFilledSVG, CrossFilledSVG, InfoFilledSVG } from '@snack-uikit/icons';
|
|
3
|
+
import { ToastSystemEventAppearance } from './constants';
|
|
4
|
+
export function getIcon(appearance) {
|
|
5
|
+
switch (appearance) {
|
|
6
|
+
case ToastSystemEventAppearance.Success:
|
|
7
|
+
return _jsx(CheckFilledSVG, {});
|
|
8
|
+
case ToastSystemEventAppearance.Error:
|
|
9
|
+
case ToastSystemEventAppearance.ErrorCritical:
|
|
10
|
+
return _jsx(CrossFilledSVG, {});
|
|
11
|
+
case ToastSystemEventAppearance.Warning:
|
|
12
|
+
return _jsx(AlarmFilledSVG, {});
|
|
13
|
+
case ToastSystemEventAppearance.Neutral:
|
|
14
|
+
default:
|
|
15
|
+
return _jsx(InfoFilledSVG, {});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { MouseEvent } from 'react';
|
|
2
|
+
import { ToastContentProps as RtToastContentProps } from 'react-toastify';
|
|
3
|
+
import { WithSupportProps } from '@snack-uikit/utils';
|
|
4
|
+
import { ToastUserActionAppearance } from './constants';
|
|
5
|
+
export type ToastUserActionLink = {
|
|
6
|
+
text: string;
|
|
7
|
+
href: string;
|
|
8
|
+
onClick?(e: MouseEvent<HTMLAnchorElement>): void;
|
|
9
|
+
};
|
|
10
|
+
export type ToastUserActionProps = Partial<RtToastContentProps> & WithSupportProps<{
|
|
11
|
+
label: string;
|
|
12
|
+
appearance?: ToastUserActionAppearance;
|
|
13
|
+
link?: ToastUserActionLink;
|
|
14
|
+
className?: string;
|
|
15
|
+
}>;
|
|
16
|
+
export declare function ToastUserAction({ appearance, label, link, className, ...rest }: ToastUserActionProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export declare namespace ToastUserAction {
|
|
18
|
+
var appearances: typeof ToastUserActionAppearance;
|
|
19
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import cn from 'classnames';
|
|
14
|
+
import { useMemo } from 'react';
|
|
15
|
+
import { Link } from '@snack-uikit/link';
|
|
16
|
+
import { extractSupportProps } from '@snack-uikit/utils';
|
|
17
|
+
import { TOAST_USER_ACTION_TEST_IDS } from '../../testIds';
|
|
18
|
+
import { ToastUserActionAppearance, Variant } from './constants';
|
|
19
|
+
import styles from './styles.module.css';
|
|
20
|
+
import { getIcon } from './utils';
|
|
21
|
+
export function ToastUserAction(_a) {
|
|
22
|
+
var { appearance = ToastUserActionAppearance.Neutral, label, link, className } = _a, rest = __rest(_a, ["appearance", "label", "link", "className"]);
|
|
23
|
+
const icon = useMemo(() => getIcon(appearance), [appearance]);
|
|
24
|
+
return (_jsxs("div", Object.assign({ className: cn(styles.container, className) }, extractSupportProps(rest), { "data-appearance": appearance, "data-variant": icon ? Variant.WithIcon : Variant.LabelOnly }, { children: [_jsxs("div", Object.assign({ className: styles.content }, { children: [icon && (_jsx("span", Object.assign({ className: styles.icon, "data-test-id": TOAST_USER_ACTION_TEST_IDS.icon }, { children: icon }))), _jsx("span", Object.assign({ className: styles.label, "data-test-id": TOAST_USER_ACTION_TEST_IDS.label }, { children: label }))] })), link && (_jsx(Link, { size: Link.sizes.M, text: link.text, href: link.href, onClick: link.onClick, onColor: Link.onColors.InvertNeutral, "data-test-id": TOAST_USER_ACTION_TEST_IDS.link }))] })));
|
|
25
|
+
}
|
|
26
|
+
ToastUserAction.appearances = ToastUserActionAppearance;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export var ToastUserActionAppearance;
|
|
2
|
+
(function (ToastUserActionAppearance) {
|
|
3
|
+
ToastUserActionAppearance["Neutral"] = "neutral";
|
|
4
|
+
ToastUserActionAppearance["Success"] = "success";
|
|
5
|
+
ToastUserActionAppearance["Error"] = "error";
|
|
6
|
+
ToastUserActionAppearance["Warning"] = "warning";
|
|
7
|
+
})(ToastUserActionAppearance || (ToastUserActionAppearance = {}));
|
|
8
|
+
export var Variant;
|
|
9
|
+
(function (Variant) {
|
|
10
|
+
Variant["WithIcon"] = "with-icon";
|
|
11
|
+
Variant["LabelOnly"] = "label-only";
|
|
12
|
+
})(Variant || (Variant = {}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ToastUserAction';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ToastUserAction';
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
.icon{
|
|
2
|
+
display:flex;
|
|
3
|
+
align-items:center;
|
|
4
|
+
justify-content:center;
|
|
5
|
+
}
|
|
6
|
+
.icon svg{
|
|
7
|
+
width:var(--dimension-3m, 24px) !important;
|
|
8
|
+
height:var(--dimension-3m, 24px) !important;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.label{
|
|
12
|
+
font-family:var(--sans-label-l-font-family, SB Sans Interface);
|
|
13
|
+
font-weight:var(--sans-label-l-font-weight, Semibold);
|
|
14
|
+
line-height:var(--sans-label-l-line-height, 20px);
|
|
15
|
+
font-size:var(--sans-label-l-font-size, 14px);
|
|
16
|
+
letter-spacing:var(--sans-label-l-letter-spacing, -0.1px);
|
|
17
|
+
paragraph-spacing:var(--sans-label-l-paragraph-spacing, 7.7px);
|
|
18
|
+
color:var(--sys-invert-neutral-text-main, #e7e7e7);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.content{
|
|
22
|
+
gap:var(--space-toaster-toast-user-action-content-gap, 8px);
|
|
23
|
+
display:flex;
|
|
24
|
+
align-items:center;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.container{
|
|
28
|
+
display:flex;
|
|
29
|
+
align-items:center;
|
|
30
|
+
justify-content:center;
|
|
31
|
+
box-sizing:border-box;
|
|
32
|
+
background-color:var(--sys-invert-neutral-background, #232323);
|
|
33
|
+
}
|
|
34
|
+
.container[data-variant=label-only]{
|
|
35
|
+
height:var(--size-toaster-toast-user-action-container, 40px);
|
|
36
|
+
gap:var(--space-toaster-toast-user-action-gap, 16px);
|
|
37
|
+
padding-left:var(--space-toaster-toast-user-action-from-label, 16px);
|
|
38
|
+
padding-right:var(--space-toaster-toast-user-action-from-label, 16px);
|
|
39
|
+
border-radius:var(--radius-toaster-toast-user-action-container, 16px);
|
|
40
|
+
}
|
|
41
|
+
.container[data-variant=with-icon]{
|
|
42
|
+
height:var(--size-toaster-toast-user-action-container, 40px);
|
|
43
|
+
gap:var(--space-toaster-toast-user-action-gap, 16px);
|
|
44
|
+
padding-left:var(--space-toaster-toast-user-action-from-icon, 8px);
|
|
45
|
+
padding-right:var(--space-toaster-toast-user-action-from-label, 16px);
|
|
46
|
+
border-radius:var(--radius-toaster-toast-user-action-container, 16px);
|
|
47
|
+
}
|
|
48
|
+
.container[data-appearance=error] .icon{
|
|
49
|
+
color:var(--sys-red-accent-default, #d93f2f);
|
|
50
|
+
}
|
|
51
|
+
.container[data-appearance=warning] .icon{
|
|
52
|
+
color:var(--sys-yellow-accent-default, #feb528);
|
|
53
|
+
}
|
|
54
|
+
.container[data-appearance=success] .icon{
|
|
55
|
+
color:var(--sys-green-accent-default, #0bbe8f);
|
|
56
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { AlarmFilledSVG, CheckFilledSVG, CrossFilledSVG } from '@snack-uikit/icons';
|
|
3
|
+
import { ToastUserActionAppearance } from './constants';
|
|
4
|
+
export function getIcon(appearance) {
|
|
5
|
+
switch (appearance) {
|
|
6
|
+
case ToastUserActionAppearance.Success:
|
|
7
|
+
return _jsx(CheckFilledSVG, {});
|
|
8
|
+
case ToastUserActionAppearance.Error:
|
|
9
|
+
return _jsx(CrossFilledSVG, {});
|
|
10
|
+
case ToastUserActionAppearance.Warning:
|
|
11
|
+
return _jsx(AlarmFilledSVG, {});
|
|
12
|
+
case ToastUserActionAppearance.Neutral:
|
|
13
|
+
default:
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import 'react-toastify/dist/ReactToastify.css';
|
|
2
|
+
import { ToastContainerProps as RtToastContainerProps, ToastPosition } from 'react-toastify';
|
|
3
|
+
import { ToasterType } from '../../types';
|
|
4
|
+
export type ToasterContainerProps = {
|
|
5
|
+
position?: ToastPosition;
|
|
6
|
+
limit?: number;
|
|
7
|
+
containerId?: RtToastContainerProps['containerId'];
|
|
8
|
+
displayCloseAllButton?: boolean;
|
|
9
|
+
type?: ToasterType;
|
|
10
|
+
};
|
|
11
|
+
export declare function ToasterContainer({ position, limit, containerId, displayCloseAllButton, type, }: ToasterContainerProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare namespace ToasterContainer {
|
|
13
|
+
var position: {
|
|
14
|
+
TOP_LEFT: ToastPosition;
|
|
15
|
+
TOP_RIGHT: ToastPosition;
|
|
16
|
+
TOP_CENTER: ToastPosition;
|
|
17
|
+
BOTTOM_LEFT: ToastPosition;
|
|
18
|
+
BOTTOM_RIGHT: ToastPosition;
|
|
19
|
+
BOTTOM_CENTER: ToastPosition;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import 'react-toastify/dist/ReactToastify.css';
|
|
3
|
+
import cn from 'classnames';
|
|
4
|
+
import { useEffect, useState } from 'react';
|
|
5
|
+
import { toast, ToastContainer as RtToastContainer, } from 'react-toastify';
|
|
6
|
+
import { TOASTER_CONTAINER_PREFIX } from '../../constants';
|
|
7
|
+
import { TOAST_SYSTEM_EVENT_TEST_IDS } from '../../testIds';
|
|
8
|
+
import { ToasterType } from '../../types';
|
|
9
|
+
import styles from './styles.module.css';
|
|
10
|
+
export function ToasterContainer({ position = toast.POSITION.BOTTOM_RIGHT, limit = 5, containerId, displayCloseAllButton, type = ToasterType.SystemEvent, }) {
|
|
11
|
+
const [notificationCounter, setNotificationCounter] = useState(0);
|
|
12
|
+
const [isCloseAllButtonHidden, setIsCloseAllButtonHidden] = useState(false);
|
|
13
|
+
const closeAll = () => {
|
|
14
|
+
toast.dismiss();
|
|
15
|
+
setIsCloseAllButtonHidden(true);
|
|
16
|
+
};
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
const unsubscribe = toast.onChange(({ status, containerId }) => {
|
|
19
|
+
if (containerId === `${TOASTER_CONTAINER_PREFIX}${ToasterType.SystemEvent}`) {
|
|
20
|
+
if (status === 'added') {
|
|
21
|
+
setIsCloseAllButtonHidden(false);
|
|
22
|
+
setNotificationCounter(prev => prev + 1);
|
|
23
|
+
}
|
|
24
|
+
if (status === 'removed') {
|
|
25
|
+
setNotificationCounter(prev => prev - 1);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
return unsubscribe;
|
|
30
|
+
}, []);
|
|
31
|
+
const hasCloseAllButton = displayCloseAllButton && notificationCounter > 2 && !isCloseAllButtonHidden;
|
|
32
|
+
return (_jsxs(_Fragment, { children: [_jsx(RtToastContainer, { hideProgressBar: true, closeOnClick: false, autoClose: false, closeButton: false, draggable: false, className: cn(styles[`container-${type}`], styles[position], {
|
|
33
|
+
[styles.containerWithCloseAllButton]: hasCloseAllButton,
|
|
34
|
+
}), toastClassName: styles.toaster, bodyClassName: styles.toaster, position: position, limit: limit, containerId: containerId, enableMultiContainer: Boolean(containerId) }), hasCloseAllButton && (_jsx("div", Object.assign({ className: cn(styles.buttonCloseColumnWrapper, styles[position]) }, { children: _jsx("button", Object.assign({ className: styles.buttonCloseColumn, onClick: closeAll, "data-test-id": TOAST_SYSTEM_EVENT_TEST_IDS.buttonCloseColumn }, { children: "\u0417\u0430\u043A\u0440\u044B\u0442\u044C \u0432\u0441\u0435" })) })))] }));
|
|
35
|
+
}
|
|
36
|
+
ToasterContainer.position = toast.POSITION;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ToasterContainer';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ToasterContainer';
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
.buttonCloseColumnWrapper{
|
|
2
|
+
gap:var(--space-toaster-system-event-gap, 8px);
|
|
3
|
+
padding:var(--space-toaster-system-event-padding, 8px);
|
|
4
|
+
width:var(--size-toaster-toast-system-event-container, 320px);
|
|
5
|
+
position:fixed;
|
|
6
|
+
box-sizing:border-box;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.buttonCloseColumn{
|
|
10
|
+
height:var(--size-toaster-button-close-column, 40px);
|
|
11
|
+
border-radius:var(--radius-toaster-system-event-button-close-column, 16px);
|
|
12
|
+
font-family:var(--sans-body-m-font-family, SB Sans Interface);
|
|
13
|
+
font-weight:var(--sans-body-m-font-weight, Regular);
|
|
14
|
+
line-height:var(--sans-body-m-line-height, 20px);
|
|
15
|
+
font-size:var(--sans-body-m-font-size, 14px);
|
|
16
|
+
letter-spacing:var(--sans-body-m-letter-spacing, 0.1px);
|
|
17
|
+
paragraph-spacing:var(--sans-body-m-paragraph-spacing, 7.7px);
|
|
18
|
+
cursor:pointer;
|
|
19
|
+
box-sizing:border-box;
|
|
20
|
+
width:100%;
|
|
21
|
+
color:var(--sys-invert-neutral-text-main, #e7e7e7);
|
|
22
|
+
background-color:var(--sys-invert-neutral-background, #232323);
|
|
23
|
+
border:none;
|
|
24
|
+
outline:none;
|
|
25
|
+
}
|
|
26
|
+
.buttonCloseColumn:hover{
|
|
27
|
+
background-color:var(--sys-invert-neutral-decor-hovered, #494949);
|
|
28
|
+
}
|
|
29
|
+
.buttonCloseColumn:focus-visible{
|
|
30
|
+
outline-width:var(--border-state-focus-s-border-width, 2px);
|
|
31
|
+
outline-style:var(--border-state-focus-s-border-style, solid);
|
|
32
|
+
outline-color:var(--border-state-focus-s-border-color, );
|
|
33
|
+
background-color:var(--sys-invert-neutral-decor-hovered, #494949);
|
|
34
|
+
outline-color:var(--sys-available-complementary, #131313);
|
|
35
|
+
outline-offset:var(--spacing-state-focus-offset, 2px);
|
|
36
|
+
}
|
|
37
|
+
.buttonCloseColumn:active{
|
|
38
|
+
color:var(--sys-invert-neutral-text-light, #898989);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.container-system-event{
|
|
42
|
+
gap:var(--space-toaster-system-event-gap, 8px);
|
|
43
|
+
padding:var(--space-toaster-system-event-padding, 8px);
|
|
44
|
+
width:var(--size-toaster-toast-system-event-container, 320px);
|
|
45
|
+
display:flex;
|
|
46
|
+
flex-direction:column;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.container-user-action{
|
|
50
|
+
padding-bottom:var(--space-toaster-user-action-padding-bottom, 8px);
|
|
51
|
+
gap:var(--space-toaster-user-action-gap, 8px);
|
|
52
|
+
display:flex;
|
|
53
|
+
flex-direction:column;
|
|
54
|
+
align-items:center;
|
|
55
|
+
width:-moz-fit-content;
|
|
56
|
+
width:fit-content;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.bottom-right{
|
|
60
|
+
right:0;
|
|
61
|
+
bottom:0;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.bottom-center{
|
|
65
|
+
bottom:0;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.toaster{
|
|
69
|
+
min-height:0;
|
|
70
|
+
margin:0;
|
|
71
|
+
padding:0;
|
|
72
|
+
background-color:transparent;
|
|
73
|
+
box-shadow:none;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.containerWithCloseAllButton{
|
|
77
|
+
margin-bottom:calc(var(--size-toaster-button-close-column, 40px) + var(--space-toaster-system-event-gap, 8px));
|
|
78
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ToasterContainerProps } from './components';
|
|
2
|
+
import { ToasterType } from './types';
|
|
3
|
+
export declare const TOASTER_CONTAINER_DEFAULT_PROPS: Record<ToasterType, ToasterContainerProps>;
|
|
4
|
+
export declare const AUTO_CLOSE_TIME: {
|
|
5
|
+
"system-event": number;
|
|
6
|
+
"user-action": number;
|
|
7
|
+
};
|
|
8
|
+
export declare const TOASTER_ROOT_ID = "toaster-root";
|
|
9
|
+
export declare const TOASTER_CONTAINER_PREFIX = "toaster-container__";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ToasterContainer } from './components';
|
|
2
|
+
import { ToasterType } from './types';
|
|
3
|
+
export const TOASTER_CONTAINER_DEFAULT_PROPS = {
|
|
4
|
+
[ToasterType.SystemEvent]: {
|
|
5
|
+
limit: 5,
|
|
6
|
+
position: ToasterContainer.position.BOTTOM_RIGHT,
|
|
7
|
+
displayCloseAllButton: true,
|
|
8
|
+
type: ToasterType.SystemEvent,
|
|
9
|
+
},
|
|
10
|
+
[ToasterType.UserAction]: {
|
|
11
|
+
limit: 2,
|
|
12
|
+
position: ToasterContainer.position.BOTTOM_CENTER,
|
|
13
|
+
displayCloseAllButton: false,
|
|
14
|
+
type: ToasterType.UserAction,
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
export const AUTO_CLOSE_TIME = {
|
|
18
|
+
[ToasterType.SystemEvent]: 5000,
|
|
19
|
+
[ToasterType.UserAction]: 2000,
|
|
20
|
+
};
|
|
21
|
+
export const TOASTER_ROOT_ID = 'toaster-root';
|
|
22
|
+
export const TOASTER_CONTAINER_PREFIX = 'toaster-container__';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { OpenToast, Toaster, UpdateToast } from './types';
|
|
2
|
+
export declare const openToast: OpenToast;
|
|
3
|
+
export declare const updateToast: UpdateToast;
|
|
4
|
+
export declare const dismissToast: (id?: import("react-toastify").Id | undefined) => void;
|
|
5
|
+
export declare const isToastActive: (id: import("react-toastify").Id) => boolean;
|
|
6
|
+
export declare const toaster: Toaster;
|