@snack-uikit/toaster 0.5.3 → 0.5.4
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 +12 -0
- package/dist/components/ToastSystemEvent/ToastSystemEvent.d.ts +5 -5
- package/dist/components/ToastSystemEvent/ToastSystemEvent.js +4 -4
- package/dist/components/ToastSystemEvent/constants.d.ts +9 -13
- package/dist/components/ToastSystemEvent/constants.js +12 -14
- package/dist/components/ToastSystemEvent/styles.module.css +26 -4
- package/dist/components/ToastSystemEvent/types.d.ts +3 -0
- package/dist/components/ToastSystemEvent/types.js +1 -0
- package/dist/components/ToastSystemEvent/utils.d.ts +1 -1
- package/dist/components/ToastSystemEvent/utils.js +5 -6
- package/dist/components/ToastUserAction/ToastUserAction.d.ts +3 -5
- package/dist/components/ToastUserAction/ToastUserAction.js +3 -4
- package/dist/components/ToastUserAction/constants.d.ts +10 -10
- package/dist/components/ToastUserAction/constants.js +10 -12
- package/dist/components/ToastUserAction/styles.module.css +19 -20
- package/dist/components/ToastUserAction/types.d.ts +3 -0
- package/dist/components/ToastUserAction/types.js +1 -0
- package/dist/components/ToastUserAction/utils.d.ts +1 -1
- package/dist/components/ToastUserAction/utils.js +5 -5
- package/dist/helperComponents/ButtonAction/ButtonAction.d.ts +7 -0
- package/dist/helperComponents/ButtonAction/ButtonAction.js +6 -0
- package/dist/helperComponents/ButtonAction/index.d.ts +1 -0
- package/dist/helperComponents/ButtonAction/index.js +1 -0
- package/dist/helperComponents/ButtonAction/styles.module.css +43 -0
- package/dist/helpers.js +20 -20
- package/dist/testIds.d.ts +2 -0
- package/dist/testIds.js +2 -0
- package/package.json +5 -4
- package/src/components/ToastSystemEvent/ToastSystemEvent.tsx +54 -41
- package/src/components/ToastSystemEvent/constants.ts +18 -14
- package/src/components/ToastSystemEvent/styles.module.scss +28 -3
- package/src/components/ToastSystemEvent/types.ts +5 -0
- package/src/components/ToastSystemEvent/utils.tsx +6 -6
- package/src/components/ToastUserAction/ToastUserAction.tsx +26 -24
- package/src/components/ToastUserAction/constants.tsx +10 -10
- package/src/components/ToastUserAction/styles.module.scss +15 -16
- package/src/components/ToastUserAction/types.ts +5 -0
- package/src/components/ToastUserAction/utils.tsx +6 -5
- package/src/helperComponents/ButtonAction/ButtonAction.tsx +24 -0
- package/src/helperComponents/ButtonAction/index.ts +1 -0
- package/src/helperComponents/ButtonAction/styles.module.scss +50 -0
- package/src/helpers.tsx +20 -19
- package/src/testIds.ts +2 -0
package/dist/testIds.js
CHANGED
|
@@ -5,6 +5,7 @@ export const TOAST_SYSTEM_EVENT_TEST_IDS = {
|
|
|
5
5
|
title: `${TOAST_SYSTEM_EVENT_TEST_ID}__title`,
|
|
6
6
|
description: `${TOAST_SYSTEM_EVENT_TEST_ID}__description`,
|
|
7
7
|
buttonClose: `${TOAST_SYSTEM_EVENT_TEST_ID}__button-close`,
|
|
8
|
+
buttonAction: `${TOAST_SYSTEM_EVENT_TEST_ID}__button-action`,
|
|
8
9
|
link: `${TOAST_SYSTEM_EVENT_TEST_ID}__link`,
|
|
9
10
|
progressbar: `${TOAST_SYSTEM_EVENT_TEST_ID}__progressbar`,
|
|
10
11
|
buttonCloseColumn: `${TOAST_SYSTEM_EVENT_TEST_ID}button-close-column`,
|
|
@@ -14,5 +15,6 @@ export const TOAST_USER_ACTION_TEST_IDS = {
|
|
|
14
15
|
main: TOAST_USER_ACTION_TEST_ID,
|
|
15
16
|
label: `${TOAST_USER_ACTION_TEST_ID}__label`,
|
|
16
17
|
icon: `${TOAST_USER_ACTION_TEST_ID}__icon`,
|
|
18
|
+
loader: `${TOAST_USER_ACTION_TEST_ID}__loader`,
|
|
17
19
|
link: `${TOAST_USER_ACTION_TEST_ID}__link`,
|
|
18
20
|
};
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Toaster",
|
|
7
|
-
"version": "0.5.
|
|
7
|
+
"version": "0.5.4",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -33,11 +33,12 @@
|
|
|
33
33
|
"scripts": {},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@snack-uikit/icons": "0.19.2",
|
|
36
|
-
"@snack-uikit/link": "0.
|
|
37
|
-
"@snack-uikit/
|
|
36
|
+
"@snack-uikit/link": "0.10.0",
|
|
37
|
+
"@snack-uikit/loaders": "0.5.0",
|
|
38
|
+
"@snack-uikit/truncate-string": "0.4.4",
|
|
38
39
|
"@snack-uikit/utils": "3.2.0",
|
|
39
40
|
"classnames": "2.3.2",
|
|
40
41
|
"react-toastify": "9.1.3"
|
|
41
42
|
},
|
|
42
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "57c597a3eebaf6528c0c61b6b27dd244753de1cf"
|
|
43
44
|
}
|
|
@@ -8,10 +8,12 @@ import { TruncateString } from '@snack-uikit/truncate-string';
|
|
|
8
8
|
import { extractSupportProps, WithSupportProps } from '@snack-uikit/utils';
|
|
9
9
|
|
|
10
10
|
import { AUTO_CLOSE_TIME } from '../../constants';
|
|
11
|
+
import { ButtonAction, ButtonActionProps } from '../../helperComponents/ButtonAction';
|
|
11
12
|
import { TOAST_SYSTEM_EVENT_TEST_IDS } from '../../testIds';
|
|
12
13
|
import { ToasterType } from '../../types';
|
|
13
|
-
import { APPEARANCE_TO_ON_COLOR_MAP
|
|
14
|
+
import { APPEARANCE_TO_ON_COLOR_MAP } from './constants';
|
|
14
15
|
import styles from './styles.module.scss';
|
|
16
|
+
import { ToastSystemEventAppearance } from './types';
|
|
15
17
|
import { getIcon } from './utils';
|
|
16
18
|
|
|
17
19
|
export type ToastSystemEventLink = {
|
|
@@ -30,10 +32,12 @@ export type ToastSystemEventProps = Partial<RtToastContentProps> &
|
|
|
30
32
|
closable?: boolean;
|
|
31
33
|
className?: string;
|
|
32
34
|
onCloseClick?(e: MouseEvent<HTMLButtonElement>, close?: () => void): void;
|
|
35
|
+
action?: ButtonActionProps[];
|
|
36
|
+
loading?: never;
|
|
33
37
|
}>;
|
|
34
38
|
|
|
35
39
|
export function ToastSystemEvent({
|
|
36
|
-
appearance =
|
|
40
|
+
appearance = 'neutral',
|
|
37
41
|
onCloseClick,
|
|
38
42
|
progressBar = true,
|
|
39
43
|
closable = true,
|
|
@@ -42,6 +46,7 @@ export function ToastSystemEvent({
|
|
|
42
46
|
link,
|
|
43
47
|
closeToast,
|
|
44
48
|
className,
|
|
49
|
+
action,
|
|
45
50
|
...rest
|
|
46
51
|
}: ToastSystemEventProps) {
|
|
47
52
|
const handleCloseClick = (e: MouseEvent<HTMLButtonElement>) => {
|
|
@@ -53,51 +58,53 @@ export function ToastSystemEvent({
|
|
|
53
58
|
|
|
54
59
|
return (
|
|
55
60
|
<div className={cn(styles.container, className)} {...extractSupportProps(rest)} data-appearance={appearance}>
|
|
56
|
-
<div className={styles.
|
|
61
|
+
<div className={styles.body}>
|
|
62
|
+
<div className={styles.icon}>{icon}</div>
|
|
57
63
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
</span>
|
|
63
|
-
|
|
64
|
-
{description && (
|
|
65
|
-
<span className={styles.description}>
|
|
66
|
-
<TruncateString
|
|
67
|
-
maxLines={4}
|
|
68
|
-
text={description}
|
|
69
|
-
hideTooltip
|
|
70
|
-
data-test-id={TOAST_SYSTEM_EVENT_TEST_IDS.description}
|
|
71
|
-
/>
|
|
64
|
+
<div className={styles.contentLayout}>
|
|
65
|
+
<div>
|
|
66
|
+
<span className={styles.title}>
|
|
67
|
+
<TruncateString text={title} maxLines={2} hideTooltip data-test-id={TOAST_SYSTEM_EVENT_TEST_IDS.title} />
|
|
72
68
|
</span>
|
|
69
|
+
|
|
70
|
+
{description && (
|
|
71
|
+
<span className={styles.description}>
|
|
72
|
+
<TruncateString
|
|
73
|
+
maxLines={4}
|
|
74
|
+
text={description}
|
|
75
|
+
hideTooltip
|
|
76
|
+
data-test-id={TOAST_SYSTEM_EVENT_TEST_IDS.description}
|
|
77
|
+
/>
|
|
78
|
+
</span>
|
|
79
|
+
)}
|
|
80
|
+
</div>
|
|
81
|
+
|
|
82
|
+
{link && (
|
|
83
|
+
<Link
|
|
84
|
+
text={link.text}
|
|
85
|
+
href={link.href}
|
|
86
|
+
size='m'
|
|
87
|
+
onClick={link.onClick}
|
|
88
|
+
appearance={APPEARANCE_TO_ON_COLOR_MAP[appearance]}
|
|
89
|
+
data-test-id={TOAST_SYSTEM_EVENT_TEST_IDS.link}
|
|
90
|
+
textMode={appearance === 'errorCritical' ? 'on-accent' : 'accent'}
|
|
91
|
+
/>
|
|
73
92
|
)}
|
|
74
93
|
</div>
|
|
75
94
|
|
|
76
|
-
{
|
|
77
|
-
<
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
95
|
+
{closable && (
|
|
96
|
+
<button
|
|
97
|
+
className={styles.buttonClose}
|
|
98
|
+
onClick={handleCloseClick}
|
|
99
|
+
data-test-id={TOAST_SYSTEM_EVENT_TEST_IDS.buttonClose}
|
|
100
|
+
// TODO add translations
|
|
101
|
+
aria-label='close notification'
|
|
102
|
+
>
|
|
103
|
+
<CrossSVG />
|
|
104
|
+
</button>
|
|
86
105
|
)}
|
|
87
106
|
</div>
|
|
88
107
|
|
|
89
|
-
{closable && (
|
|
90
|
-
<button
|
|
91
|
-
className={styles.buttonClose}
|
|
92
|
-
onClick={handleCloseClick}
|
|
93
|
-
data-test-id={TOAST_SYSTEM_EVENT_TEST_IDS.buttonClose}
|
|
94
|
-
// TODO add translations
|
|
95
|
-
aria-label='close notification'
|
|
96
|
-
>
|
|
97
|
-
<CrossSVG />
|
|
98
|
-
</button>
|
|
99
|
-
)}
|
|
100
|
-
|
|
101
108
|
{progressBar && (
|
|
102
109
|
<div
|
|
103
110
|
role='progressbar'
|
|
@@ -108,8 +115,14 @@ export function ToastSystemEvent({
|
|
|
108
115
|
style={{ animationDuration: `${AUTO_CLOSE_TIME[ToasterType.SystemEvent]}ms` }}
|
|
109
116
|
/>
|
|
110
117
|
)}
|
|
118
|
+
|
|
119
|
+
{Array.isArray(action) && action.length > 0 && (
|
|
120
|
+
<div className={styles.footer}>
|
|
121
|
+
{action.map(buttonProps => (
|
|
122
|
+
<ButtonAction key={buttonProps.label} {...buttonProps} critical={appearance === 'errorCritical'} />
|
|
123
|
+
))}
|
|
124
|
+
</div>
|
|
125
|
+
)}
|
|
111
126
|
</div>
|
|
112
127
|
);
|
|
113
128
|
}
|
|
114
|
-
|
|
115
|
-
ToastSystemEvent.appearances = ToastSystemEventAppearance;
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LinkProps } from '@snack-uikit/link';
|
|
2
|
+
import { ValueOf } from '@snack-uikit/utils';
|
|
2
3
|
|
|
3
|
-
export
|
|
4
|
-
Neutral
|
|
5
|
-
Error
|
|
6
|
-
ErrorCritical
|
|
7
|
-
Warning
|
|
8
|
-
Success
|
|
9
|
-
}
|
|
4
|
+
export const TOAST_SYSTEM_EVENT_APPEARANCE = {
|
|
5
|
+
Neutral: 'neutral',
|
|
6
|
+
Error: 'error',
|
|
7
|
+
ErrorCritical: 'errorCritical',
|
|
8
|
+
Warning: 'warning',
|
|
9
|
+
Success: 'success',
|
|
10
|
+
} as const;
|
|
10
11
|
|
|
11
|
-
export const APPEARANCE_TO_ON_COLOR_MAP
|
|
12
|
-
|
|
13
|
-
[
|
|
14
|
-
|
|
15
|
-
[
|
|
16
|
-
[
|
|
12
|
+
export const APPEARANCE_TO_ON_COLOR_MAP: Record<
|
|
13
|
+
ValueOf<typeof TOAST_SYSTEM_EVENT_APPEARANCE>,
|
|
14
|
+
LinkProps['appearance']
|
|
15
|
+
> = {
|
|
16
|
+
[TOAST_SYSTEM_EVENT_APPEARANCE.Neutral]: 'invert-neutral',
|
|
17
|
+
[TOAST_SYSTEM_EVENT_APPEARANCE.Error]: 'invert-neutral',
|
|
18
|
+
[TOAST_SYSTEM_EVENT_APPEARANCE.ErrorCritical]: 'red',
|
|
19
|
+
[TOAST_SYSTEM_EVENT_APPEARANCE.Warning]: 'invert-neutral',
|
|
20
|
+
[TOAST_SYSTEM_EVENT_APPEARANCE.Success]: 'invert-neutral',
|
|
17
21
|
} as const;
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
.buttonClose {
|
|
33
|
-
@include composite-var($toaster-system-event-toast-button-close);
|
|
33
|
+
@include composite-var($toaster-system-event-toast-button-button-close);
|
|
34
34
|
|
|
35
35
|
cursor: pointer;
|
|
36
36
|
|
|
@@ -70,8 +70,8 @@
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
.
|
|
74
|
-
@include composite-var($toaster-system-event-toast-content);
|
|
73
|
+
.contentLayout {
|
|
74
|
+
@include composite-var($toaster-system-event-toast-content-layout);
|
|
75
75
|
|
|
76
76
|
display: flex;
|
|
77
77
|
flex: 1;
|
|
@@ -111,6 +111,23 @@
|
|
|
111
111
|
animation-play-state: active;
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
+
.body {
|
|
115
|
+
@include composite-var($toaster-system-event-toast-body);
|
|
116
|
+
|
|
117
|
+
display: flex;
|
|
118
|
+
width: 100%;
|
|
119
|
+
overflow-wrap: break-word;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.footer {
|
|
123
|
+
@include composite-var($toaster-system-event-toast-footer);
|
|
124
|
+
|
|
125
|
+
position: relative;
|
|
126
|
+
display: flex;
|
|
127
|
+
flex-direction: row-reverse;
|
|
128
|
+
width: 100%;
|
|
129
|
+
}
|
|
130
|
+
|
|
114
131
|
.container {
|
|
115
132
|
@include composite-var($toaster-system-event-toast-container);
|
|
116
133
|
|
|
@@ -120,6 +137,7 @@
|
|
|
120
137
|
|
|
121
138
|
overflow: hidden;
|
|
122
139
|
display: flex;
|
|
140
|
+
flex-direction: column;
|
|
123
141
|
|
|
124
142
|
box-sizing: border-box;
|
|
125
143
|
|
|
@@ -192,3 +210,10 @@
|
|
|
192
210
|
);
|
|
193
211
|
}
|
|
194
212
|
}
|
|
213
|
+
|
|
214
|
+
.loader {
|
|
215
|
+
display: flex;
|
|
216
|
+
align-items: center;
|
|
217
|
+
justify-content: center;
|
|
218
|
+
color: $sys-invert-neutral-text-main;
|
|
219
|
+
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { AlarmFilledSVG, CheckFilledSVG, CrossFilledSVG, InfoFilledSVG } from '@snack-uikit/icons';
|
|
2
2
|
|
|
3
|
-
import { ToastSystemEventAppearance } from './
|
|
3
|
+
import { ToastSystemEventAppearance } from './types';
|
|
4
4
|
|
|
5
5
|
export function getIcon(appearance: ToastSystemEventAppearance) {
|
|
6
6
|
switch (appearance) {
|
|
7
|
-
case
|
|
7
|
+
case 'success':
|
|
8
8
|
return <CheckFilledSVG />;
|
|
9
|
-
case
|
|
10
|
-
case
|
|
9
|
+
case 'error':
|
|
10
|
+
case 'errorCritical':
|
|
11
11
|
return <CrossFilledSVG />;
|
|
12
|
-
case
|
|
12
|
+
case 'warning':
|
|
13
13
|
return <AlarmFilledSVG />;
|
|
14
|
-
case
|
|
14
|
+
case 'neutral':
|
|
15
15
|
default:
|
|
16
16
|
return <InfoFilledSVG />;
|
|
17
17
|
}
|
|
@@ -3,11 +3,12 @@ import { MouseEvent, useMemo } from 'react';
|
|
|
3
3
|
import { ToastContentProps as RtToastContentProps } from 'react-toastify';
|
|
4
4
|
|
|
5
5
|
import { Link } from '@snack-uikit/link';
|
|
6
|
+
import { Sun } from '@snack-uikit/loaders';
|
|
6
7
|
import { extractSupportProps, WithSupportProps } from '@snack-uikit/utils';
|
|
7
8
|
|
|
8
9
|
import { TOAST_USER_ACTION_TEST_IDS } from '../../testIds';
|
|
9
|
-
import { ToastUserActionAppearance, Variant } from './constants';
|
|
10
10
|
import styles from './styles.module.scss';
|
|
11
|
+
import { ToastUserActionAppearance } from './types';
|
|
11
12
|
import { getIcon } from './utils';
|
|
12
13
|
|
|
13
14
|
export type ToastUserActionLink = {
|
|
@@ -22,47 +23,48 @@ export type ToastUserActionProps = Partial<RtToastContentProps> &
|
|
|
22
23
|
appearance?: ToastUserActionAppearance;
|
|
23
24
|
link?: ToastUserActionLink;
|
|
24
25
|
className?: string;
|
|
26
|
+
loading?: boolean;
|
|
25
27
|
}>;
|
|
26
28
|
|
|
27
29
|
export function ToastUserAction({
|
|
28
|
-
appearance =
|
|
30
|
+
appearance = 'neutral',
|
|
29
31
|
label,
|
|
30
32
|
link,
|
|
31
33
|
className,
|
|
34
|
+
loading = false,
|
|
32
35
|
...rest
|
|
33
36
|
}: ToastUserActionProps) {
|
|
34
37
|
const icon = useMemo(() => getIcon(appearance), [appearance]);
|
|
35
38
|
|
|
36
39
|
return (
|
|
37
|
-
<div
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
{icon && (
|
|
40
|
+
<div className={cn(styles.container, className)} {...extractSupportProps(rest)} data-appearance={appearance}>
|
|
41
|
+
{loading ? (
|
|
42
|
+
<span className={styles.loader} data-test-id={TOAST_USER_ACTION_TEST_IDS.loader}>
|
|
43
|
+
<Sun size='s' />
|
|
44
|
+
</span>
|
|
45
|
+
) : (
|
|
46
|
+
icon && (
|
|
45
47
|
<span className={styles.icon} data-test-id={TOAST_USER_ACTION_TEST_IDS.icon}>
|
|
46
48
|
{icon}
|
|
47
49
|
</span>
|
|
48
|
-
)
|
|
50
|
+
)
|
|
51
|
+
)}
|
|
52
|
+
<div className={styles.contentLayout}>
|
|
49
53
|
<span className={styles.label} data-test-id={TOAST_USER_ACTION_TEST_IDS.label}>
|
|
50
54
|
{label}
|
|
51
55
|
</span>
|
|
52
|
-
</div>
|
|
53
56
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
57
|
+
{link && (
|
|
58
|
+
<Link
|
|
59
|
+
size='m'
|
|
60
|
+
text={link.text}
|
|
61
|
+
href={link.href}
|
|
62
|
+
onClick={link.onClick}
|
|
63
|
+
appearance='invert-neutral'
|
|
64
|
+
data-test-id={TOAST_USER_ACTION_TEST_IDS.link}
|
|
65
|
+
/>
|
|
66
|
+
)}
|
|
67
|
+
</div>
|
|
64
68
|
</div>
|
|
65
69
|
);
|
|
66
70
|
}
|
|
67
|
-
|
|
68
|
-
ToastUserAction.appearances = ToastUserActionAppearance;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export
|
|
2
|
-
Neutral
|
|
3
|
-
Success
|
|
4
|
-
Error
|
|
5
|
-
Warning
|
|
6
|
-
}
|
|
1
|
+
export const TOAST_USER_ACTION_APPEARANCE = {
|
|
2
|
+
Neutral: 'neutral',
|
|
3
|
+
Success: 'success',
|
|
4
|
+
Error: 'error',
|
|
5
|
+
Warning: 'warning',
|
|
6
|
+
} as const;
|
|
7
7
|
|
|
8
|
-
export
|
|
9
|
-
WithIcon
|
|
10
|
-
LabelOnly
|
|
11
|
-
}
|
|
8
|
+
export const VARIANT = {
|
|
9
|
+
WithIcon: 'with-icon',
|
|
10
|
+
LabelOnly: 'label-only',
|
|
11
|
+
} as const;
|
|
@@ -20,15 +20,9 @@
|
|
|
20
20
|
color: $sys-invert-neutral-text-main;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
.content {
|
|
24
|
-
@include composite-var($toaster-user-action-toast-content);
|
|
25
|
-
|
|
26
|
-
display: flex;
|
|
27
|
-
align-items: center
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
23
|
.container {
|
|
24
|
+
@include composite-var($toaster-user-action-toast-container);
|
|
25
|
+
|
|
32
26
|
display: flex;
|
|
33
27
|
align-items: center;
|
|
34
28
|
justify-content: center;
|
|
@@ -37,14 +31,6 @@
|
|
|
37
31
|
|
|
38
32
|
background-color: $sys-invert-neutral-background;
|
|
39
33
|
|
|
40
|
-
&[data-variant='label-only'] {
|
|
41
|
-
@include composite-var($toaster-user-action-toast-container-label-only);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
&[data-variant='with-icon'] {
|
|
45
|
-
@include composite-var($toaster-user-action-toast-container-with-icon);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
34
|
&[data-appearance='error'] {
|
|
49
35
|
.icon {
|
|
50
36
|
color: $sys-red-accent-default;
|
|
@@ -64,3 +50,16 @@
|
|
|
64
50
|
}
|
|
65
51
|
}
|
|
66
52
|
|
|
53
|
+
.loader {
|
|
54
|
+
display: flex;
|
|
55
|
+
align-items: center;
|
|
56
|
+
justify-content: center;
|
|
57
|
+
color: $sys-invert-neutral-text-main
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.contentLayout {
|
|
61
|
+
@include composite-var($toaster-user-action-toast-content-layout);
|
|
62
|
+
|
|
63
|
+
display: flex;
|
|
64
|
+
align-items: center
|
|
65
|
+
}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { AlarmFilledSVG, CheckFilledSVG, CrossFilledSVG } from '@snack-uikit/icons';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { TOAST_SYSTEM_EVENT_APPEARANCE } from '../ToastSystemEvent/constants';
|
|
4
|
+
import { ToastUserActionAppearance } from './types';
|
|
4
5
|
|
|
5
6
|
export function getIcon(appearance: ToastUserActionAppearance) {
|
|
6
7
|
switch (appearance) {
|
|
7
|
-
case
|
|
8
|
+
case TOAST_SYSTEM_EVENT_APPEARANCE.Success:
|
|
8
9
|
return <CheckFilledSVG />;
|
|
9
|
-
case
|
|
10
|
+
case TOAST_SYSTEM_EVENT_APPEARANCE.Error:
|
|
10
11
|
return <CrossFilledSVG />;
|
|
11
|
-
case
|
|
12
|
+
case TOAST_SYSTEM_EVENT_APPEARANCE.Warning:
|
|
12
13
|
return <AlarmFilledSVG />;
|
|
13
|
-
case
|
|
14
|
+
case TOAST_SYSTEM_EVENT_APPEARANCE.Neutral:
|
|
14
15
|
default:
|
|
15
16
|
return null;
|
|
16
17
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { MouseEvent } from 'react';
|
|
2
|
+
|
|
3
|
+
import { TOAST_SYSTEM_EVENT_TEST_IDS } from '../../testIds';
|
|
4
|
+
import styles from './styles.module.scss';
|
|
5
|
+
|
|
6
|
+
export type ButtonActionProps = {
|
|
7
|
+
label: string;
|
|
8
|
+
onClick(e: MouseEvent<HTMLButtonElement>): void;
|
|
9
|
+
critical?: boolean;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export function ButtonAction({ label, onClick, critical }: ButtonActionProps) {
|
|
13
|
+
return (
|
|
14
|
+
<button
|
|
15
|
+
className={styles.buttonAction}
|
|
16
|
+
onClick={onClick}
|
|
17
|
+
data-test-id={TOAST_SYSTEM_EVENT_TEST_IDS.buttonAction}
|
|
18
|
+
aria-label='action'
|
|
19
|
+
data-critical={critical || undefined}
|
|
20
|
+
>
|
|
21
|
+
{label}
|
|
22
|
+
</button>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ButtonAction';
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
@import '@snack-uikit/figma-tokens/build/scss/components/styles-tokens-toaster-toasterSystemEvent';
|
|
2
|
+
@import '@snack-uikit/figma-tokens/build/scss/components/styles-tokens-element';
|
|
3
|
+
|
|
4
|
+
.buttonAction {
|
|
5
|
+
@include composite-var($toaster-system-event-toast-button-button-action);
|
|
6
|
+
@include composite-var($sans-body-m);
|
|
7
|
+
|
|
8
|
+
cursor: pointer;
|
|
9
|
+
|
|
10
|
+
display: flex;
|
|
11
|
+
align-items: center;
|
|
12
|
+
justify-content: center;
|
|
13
|
+
|
|
14
|
+
box-sizing: border-box;
|
|
15
|
+
margin: 0;
|
|
16
|
+
|
|
17
|
+
color: $sys-invert-neutral-text-main;
|
|
18
|
+
|
|
19
|
+
background-color: $sys-invert-neutral-decor-default;
|
|
20
|
+
border: none;
|
|
21
|
+
|
|
22
|
+
&:hover,
|
|
23
|
+
&:focus-visible {
|
|
24
|
+
background-color: $sys-invert-neutral-decor-hovered;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&:active {
|
|
28
|
+
background-color: $sys-invert-neutral-decor-activated;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&:focus-visible {
|
|
32
|
+
@include outline-var($container-focused-s);
|
|
33
|
+
|
|
34
|
+
outline-color: $sys-available-on-complementary;
|
|
35
|
+
outline-offset: $spacing-state-focus-offset;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
&[data-critical] {
|
|
39
|
+
background-color: $sys-opacity-enabled;
|
|
40
|
+
|
|
41
|
+
&:hover,
|
|
42
|
+
&:focus-visible {
|
|
43
|
+
background-color: $sys-opacity-hovered;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
&:active {
|
|
47
|
+
background-color: $sys-opacity-activated;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|