@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/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 0.5.4 (2023-12-28)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **FF-3960:** support link props renaming ([990b35e](https://github.com/cloud-ru-tech/snack-uikit/commit/990b35e6f0ea091c499b337e721add2f1606a251))
|
|
12
|
+
* **FF-3960:** update inner structure, add loading prop, add action buttons ([8546108](https://github.com/cloud-ru-tech/snack-uikit/commit/854610855497e7df915c82768c3f907a449a9a36))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
6
18
|
## 0.5.3 (2023-12-25)
|
|
7
19
|
|
|
8
20
|
### Only dependencies have been changed
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { MouseEvent } from 'react';
|
|
2
2
|
import { ToastContentProps as RtToastContentProps } from 'react-toastify';
|
|
3
3
|
import { WithSupportProps } from '@snack-uikit/utils';
|
|
4
|
-
import {
|
|
4
|
+
import { ButtonActionProps } from '../../helperComponents/ButtonAction';
|
|
5
|
+
import { ToastSystemEventAppearance } from './types';
|
|
5
6
|
export type ToastSystemEventLink = {
|
|
6
7
|
text: string;
|
|
7
8
|
href: string;
|
|
@@ -16,8 +17,7 @@ export type ToastSystemEventProps = Partial<RtToastContentProps> & WithSupportPr
|
|
|
16
17
|
closable?: boolean;
|
|
17
18
|
className?: string;
|
|
18
19
|
onCloseClick?(e: MouseEvent<HTMLButtonElement>, close?: () => void): void;
|
|
20
|
+
action?: ButtonActionProps[];
|
|
21
|
+
loading?: never;
|
|
19
22
|
}>;
|
|
20
|
-
export declare function ToastSystemEvent({ appearance, onCloseClick, progressBar, closable, title, description, link, closeToast, className, ...rest }: ToastSystemEventProps): import("react/jsx-runtime").JSX.Element;
|
|
21
|
-
export declare namespace ToastSystemEvent {
|
|
22
|
-
var appearances: typeof ToastSystemEventAppearance;
|
|
23
|
-
}
|
|
23
|
+
export declare function ToastSystemEvent({ appearance, onCloseClick, progressBar, closable, title, description, link, closeToast, className, action, ...rest }: ToastSystemEventProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -17,18 +17,18 @@ import { Link } from '@snack-uikit/link';
|
|
|
17
17
|
import { TruncateString } from '@snack-uikit/truncate-string';
|
|
18
18
|
import { extractSupportProps } from '@snack-uikit/utils';
|
|
19
19
|
import { AUTO_CLOSE_TIME } from '../../constants';
|
|
20
|
+
import { ButtonAction } from '../../helperComponents/ButtonAction';
|
|
20
21
|
import { TOAST_SYSTEM_EVENT_TEST_IDS } from '../../testIds';
|
|
21
22
|
import { ToasterType } from '../../types';
|
|
22
|
-
import { APPEARANCE_TO_ON_COLOR_MAP
|
|
23
|
+
import { APPEARANCE_TO_ON_COLOR_MAP } from './constants';
|
|
23
24
|
import styles from './styles.module.css';
|
|
24
25
|
import { getIcon } from './utils';
|
|
25
26
|
export function ToastSystemEvent(_a) {
|
|
26
|
-
var { appearance =
|
|
27
|
+
var { appearance = 'neutral', onCloseClick, progressBar = true, closable = true, title, description, link, closeToast, className, action } = _a, rest = __rest(_a, ["appearance", "onCloseClick", "progressBar", "closable", "title", "description", "link", "closeToast", "className", "action"]);
|
|
27
28
|
const handleCloseClick = (e) => {
|
|
28
29
|
e.stopPropagation();
|
|
29
30
|
onCloseClick ? onCloseClick(e, closeToast) : closeToast === null || closeToast === void 0 ? void 0 : closeToast();
|
|
30
31
|
};
|
|
31
32
|
const icon = useMemo(() => getIcon(appearance), [appearance]);
|
|
32
|
-
return (_jsxs("div", Object.assign({ className: cn(styles.container, className) }, extractSupportProps(rest), { "data-appearance": appearance, children: [_jsx("div", { className: styles.icon, children: icon }), _jsxs("div", { className: styles.
|
|
33
|
+
return (_jsxs("div", Object.assign({ className: cn(styles.container, className) }, extractSupportProps(rest), { "data-appearance": appearance, children: [_jsxs("div", { className: styles.body, children: [_jsx("div", { className: styles.icon, children: icon }), _jsxs("div", { className: styles.contentLayout, children: [_jsxs("div", { children: [_jsx("span", { className: styles.title, children: _jsx(TruncateString, { text: title, maxLines: 2, hideTooltip: true, "data-test-id": TOAST_SYSTEM_EVENT_TEST_IDS.title }) }), description && (_jsx("span", { className: styles.description, children: _jsx(TruncateString, { maxLines: 4, text: description, hideTooltip: true, "data-test-id": TOAST_SYSTEM_EVENT_TEST_IDS.description }) }))] }), link && (_jsx(Link, { text: link.text, href: link.href, size: 'm', onClick: link.onClick, appearance: APPEARANCE_TO_ON_COLOR_MAP[appearance], "data-test-id": TOAST_SYSTEM_EVENT_TEST_IDS.link, textMode: appearance === 'errorCritical' ? 'on-accent' : 'accent' }))] }), closable && (_jsx("button", { className: styles.buttonClose, onClick: handleCloseClick, "data-test-id": TOAST_SYSTEM_EVENT_TEST_IDS.buttonClose, "aria-label": 'close notification', children: _jsx(CrossSVG, {}) }))] }), progressBar && (_jsx("div", { role: 'progressbar', "aria-label": 'progressbar', "data-test-id": TOAST_SYSTEM_EVENT_TEST_IDS.progressbar, className: styles.progress, style: { animationDuration: `${AUTO_CLOSE_TIME[ToasterType.SystemEvent]}ms` } })), Array.isArray(action) && action.length > 0 && (_jsx("div", { className: styles.footer, children: action.map(buttonProps => (_jsx(ButtonAction, Object.assign({}, buttonProps, { critical: appearance === 'errorCritical' }), buttonProps.label))) }))] })));
|
|
33
34
|
}
|
|
34
|
-
ToastSystemEvent.appearances = ToastSystemEventAppearance;
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
readonly neutral: "invert-neutral";
|
|
10
|
-
readonly error: "invert-neutral";
|
|
11
|
-
readonly errorCritical: "red";
|
|
12
|
-
readonly warning: "invert-neutral";
|
|
13
|
-
readonly success: "invert-neutral";
|
|
1
|
+
import { LinkProps } from '@snack-uikit/link';
|
|
2
|
+
import { ValueOf } from '@snack-uikit/utils';
|
|
3
|
+
export declare const TOAST_SYSTEM_EVENT_APPEARANCE: {
|
|
4
|
+
readonly Neutral: "neutral";
|
|
5
|
+
readonly Error: "error";
|
|
6
|
+
readonly ErrorCritical: "errorCritical";
|
|
7
|
+
readonly Warning: "warning";
|
|
8
|
+
readonly Success: "success";
|
|
14
9
|
};
|
|
10
|
+
export declare const APPEARANCE_TO_ON_COLOR_MAP: Record<ValueOf<typeof TOAST_SYSTEM_EVENT_APPEARANCE>, LinkProps['appearance']>;
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
ToastSystemEventAppearance["Success"] = "success";
|
|
9
|
-
})(ToastSystemEventAppearance || (ToastSystemEventAppearance = {}));
|
|
1
|
+
export const TOAST_SYSTEM_EVENT_APPEARANCE = {
|
|
2
|
+
Neutral: 'neutral',
|
|
3
|
+
Error: 'error',
|
|
4
|
+
ErrorCritical: 'errorCritical',
|
|
5
|
+
Warning: 'warning',
|
|
6
|
+
Success: 'success',
|
|
7
|
+
};
|
|
10
8
|
export const APPEARANCE_TO_ON_COLOR_MAP = {
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
9
|
+
[TOAST_SYSTEM_EVENT_APPEARANCE.Neutral]: 'invert-neutral',
|
|
10
|
+
[TOAST_SYSTEM_EVENT_APPEARANCE.Error]: 'invert-neutral',
|
|
11
|
+
[TOAST_SYSTEM_EVENT_APPEARANCE.ErrorCritical]: 'red',
|
|
12
|
+
[TOAST_SYSTEM_EVENT_APPEARANCE.Warning]: 'invert-neutral',
|
|
13
|
+
[TOAST_SYSTEM_EVENT_APPEARANCE.Success]: 'invert-neutral',
|
|
16
14
|
};
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
.buttonClose{
|
|
7
7
|
width:var(--size-toaster-toast-system-event-button-close, 24px);
|
|
8
8
|
height:var(--size-toaster-toast-system-event-button-close, 24px);
|
|
9
|
-
border-radius:var(--radius-toaster-toast-system-event-button
|
|
9
|
+
border-radius:var(--radius-toaster-toast-system-event-button, 8px);
|
|
10
10
|
cursor:pointer;
|
|
11
11
|
display:flex;
|
|
12
12
|
align-items:center;
|
|
@@ -37,9 +37,8 @@
|
|
|
37
37
|
outline-offset:var(--spacing-state-focus-offset, 2px);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
.
|
|
41
|
-
|
|
42
|
-
padding-top:var(--space-toaster-toast-system-event-container-content-padding-top, 2px);
|
|
40
|
+
.contentLayout{
|
|
41
|
+
padding-top:var(--space-toaster-toast-system-event-container-content-layout-padding-top, 2px);
|
|
43
42
|
display:flex;
|
|
44
43
|
flex:1;
|
|
45
44
|
flex-direction:column;
|
|
@@ -83,6 +82,21 @@
|
|
|
83
82
|
animation-play-state:active;
|
|
84
83
|
}
|
|
85
84
|
|
|
85
|
+
.body{
|
|
86
|
+
gap:var(--space-toaster-toast-system-event-container-body-gap, 16px);
|
|
87
|
+
display:flex;
|
|
88
|
+
width:100%;
|
|
89
|
+
overflow-wrap:break-word;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.footer{
|
|
93
|
+
gap:var(--space-toaster-toast-system-event-container-footer-gap, 8px);
|
|
94
|
+
position:relative;
|
|
95
|
+
display:flex;
|
|
96
|
+
flex-direction:row-reverse;
|
|
97
|
+
width:100%;
|
|
98
|
+
}
|
|
99
|
+
|
|
86
100
|
.container{
|
|
87
101
|
padding:var(--space-toaster-toast-system-event-container-padding, 16px);
|
|
88
102
|
border-radius:var(--radius-toaster-toast-system-event-container, 16px);
|
|
@@ -91,6 +105,7 @@
|
|
|
91
105
|
position:relative;
|
|
92
106
|
overflow:hidden;
|
|
93
107
|
display:flex;
|
|
108
|
+
flex-direction:column;
|
|
94
109
|
box-sizing:border-box;
|
|
95
110
|
}
|
|
96
111
|
.container:hover .progress{
|
|
@@ -180,4 +195,11 @@
|
|
|
180
195
|
}
|
|
181
196
|
.container[data-appearance=success] .progress{
|
|
182
197
|
background-color:var(--sys-green-accent-default, #0bbe8f);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.loader{
|
|
201
|
+
display:flex;
|
|
202
|
+
align-items:center;
|
|
203
|
+
justify-content:center;
|
|
204
|
+
color:var(--sys-invert-neutral-text-main, #e7e7e7);
|
|
183
205
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ToastSystemEventAppearance } from './
|
|
1
|
+
import { ToastSystemEventAppearance } from './types';
|
|
2
2
|
export declare function getIcon(appearance: ToastSystemEventAppearance): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { AlarmFilledSVG, CheckFilledSVG, CrossFilledSVG, InfoFilledSVG } from '@snack-uikit/icons';
|
|
3
|
-
import { ToastSystemEventAppearance } from './constants';
|
|
4
3
|
export function getIcon(appearance) {
|
|
5
4
|
switch (appearance) {
|
|
6
|
-
case
|
|
5
|
+
case 'success':
|
|
7
6
|
return _jsx(CheckFilledSVG, {});
|
|
8
|
-
case
|
|
9
|
-
case
|
|
7
|
+
case 'error':
|
|
8
|
+
case 'errorCritical':
|
|
10
9
|
return _jsx(CrossFilledSVG, {});
|
|
11
|
-
case
|
|
10
|
+
case 'warning':
|
|
12
11
|
return _jsx(AlarmFilledSVG, {});
|
|
13
|
-
case
|
|
12
|
+
case 'neutral':
|
|
14
13
|
default:
|
|
15
14
|
return _jsx(InfoFilledSVG, {});
|
|
16
15
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MouseEvent } from 'react';
|
|
2
2
|
import { ToastContentProps as RtToastContentProps } from 'react-toastify';
|
|
3
3
|
import { WithSupportProps } from '@snack-uikit/utils';
|
|
4
|
-
import { ToastUserActionAppearance } from './
|
|
4
|
+
import { ToastUserActionAppearance } from './types';
|
|
5
5
|
export type ToastUserActionLink = {
|
|
6
6
|
text: string;
|
|
7
7
|
href: string;
|
|
@@ -12,8 +12,6 @@ export type ToastUserActionProps = Partial<RtToastContentProps> & WithSupportPro
|
|
|
12
12
|
appearance?: ToastUserActionAppearance;
|
|
13
13
|
link?: ToastUserActionLink;
|
|
14
14
|
className?: string;
|
|
15
|
+
loading?: boolean;
|
|
15
16
|
}>;
|
|
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
|
-
}
|
|
17
|
+
export declare function ToastUserAction({ appearance, label, link, className, loading, ...rest }: ToastUserActionProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -13,14 +13,13 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
13
13
|
import cn from 'classnames';
|
|
14
14
|
import { useMemo } from 'react';
|
|
15
15
|
import { Link } from '@snack-uikit/link';
|
|
16
|
+
import { Sun } from '@snack-uikit/loaders';
|
|
16
17
|
import { extractSupportProps } from '@snack-uikit/utils';
|
|
17
18
|
import { TOAST_USER_ACTION_TEST_IDS } from '../../testIds';
|
|
18
|
-
import { ToastUserActionAppearance, Variant } from './constants';
|
|
19
19
|
import styles from './styles.module.css';
|
|
20
20
|
import { getIcon } from './utils';
|
|
21
21
|
export function ToastUserAction(_a) {
|
|
22
|
-
var { appearance =
|
|
22
|
+
var { appearance = 'neutral', label, link, className, loading = false } = _a, rest = __rest(_a, ["appearance", "label", "link", "className", "loading"]);
|
|
23
23
|
const icon = useMemo(() => getIcon(appearance), [appearance]);
|
|
24
|
-
return (_jsxs("div", Object.assign({ className: cn(styles.container, className) }, extractSupportProps(rest), { "data-appearance": appearance,
|
|
24
|
+
return (_jsxs("div", Object.assign({ className: cn(styles.container, className) }, extractSupportProps(rest), { "data-appearance": appearance, children: [loading ? (_jsx("span", { className: styles.loader, "data-test-id": TOAST_USER_ACTION_TEST_IDS.loader, children: _jsx(Sun, { size: 's' }) })) : (icon && (_jsx("span", { className: styles.icon, "data-test-id": TOAST_USER_ACTION_TEST_IDS.icon, children: icon }))), _jsxs("div", { className: styles.contentLayout, children: [_jsx("span", { className: styles.label, "data-test-id": TOAST_USER_ACTION_TEST_IDS.label, children: label }), link && (_jsx(Link, { size: 'm', text: link.text, href: link.href, onClick: link.onClick, appearance: 'invert-neutral', "data-test-id": TOAST_USER_ACTION_TEST_IDS.link }))] })] })));
|
|
25
25
|
}
|
|
26
|
-
ToastUserAction.appearances = ToastUserActionAppearance;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export declare
|
|
2
|
-
Neutral
|
|
3
|
-
Success
|
|
4
|
-
Error
|
|
5
|
-
Warning
|
|
6
|
-
}
|
|
7
|
-
export declare
|
|
8
|
-
WithIcon
|
|
9
|
-
LabelOnly
|
|
10
|
-
}
|
|
1
|
+
export declare const TOAST_USER_ACTION_APPEARANCE: {
|
|
2
|
+
readonly Neutral: "neutral";
|
|
3
|
+
readonly Success: "success";
|
|
4
|
+
readonly Error: "error";
|
|
5
|
+
readonly Warning: "warning";
|
|
6
|
+
};
|
|
7
|
+
export declare const VARIANT: {
|
|
8
|
+
readonly WithIcon: "with-icon";
|
|
9
|
+
readonly LabelOnly: "label-only";
|
|
10
|
+
};
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
Variant["LabelOnly"] = "label-only";
|
|
12
|
-
})(Variant || (Variant = {}));
|
|
1
|
+
export const TOAST_USER_ACTION_APPEARANCE = {
|
|
2
|
+
Neutral: 'neutral',
|
|
3
|
+
Success: 'success',
|
|
4
|
+
Error: 'error',
|
|
5
|
+
Warning: 'warning',
|
|
6
|
+
};
|
|
7
|
+
export const VARIANT = {
|
|
8
|
+
WithIcon: 'with-icon',
|
|
9
|
+
LabelOnly: 'label-only',
|
|
10
|
+
};
|
|
@@ -18,33 +18,17 @@
|
|
|
18
18
|
color:var(--sys-invert-neutral-text-main, #e7e7e7);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
.content{
|
|
22
|
-
gap:var(--space-toaster-toast-user-action-content-gap, 8px);
|
|
23
|
-
display:flex;
|
|
24
|
-
align-items:center;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
21
|
.container{
|
|
22
|
+
height:var(--size-toaster-toast-user-action-container, 40px);
|
|
23
|
+
padding-left:var(--space-toaster-toast-user-action-horizont-padding, 8px);
|
|
24
|
+
padding-right:var(--space-toaster-toast-user-action-horizont-padding, 8px);
|
|
25
|
+
border-radius:var(--radius-toaster-toast-user-action-container, 16px);
|
|
28
26
|
display:flex;
|
|
29
27
|
align-items:center;
|
|
30
28
|
justify-content:center;
|
|
31
29
|
box-sizing:border-box;
|
|
32
30
|
background-color:var(--sys-invert-neutral-background, #232323);
|
|
33
31
|
}
|
|
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
32
|
.container[data-appearance=error] .icon{
|
|
49
33
|
color:var(--sys-red-accent-default, #d93f2f);
|
|
50
34
|
}
|
|
@@ -53,4 +37,19 @@
|
|
|
53
37
|
}
|
|
54
38
|
.container[data-appearance=success] .icon{
|
|
55
39
|
color:var(--sys-green-accent-default, #0bbe8f);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.loader{
|
|
43
|
+
display:flex;
|
|
44
|
+
align-items:center;
|
|
45
|
+
justify-content:center;
|
|
46
|
+
color:var(--sys-invert-neutral-text-main, #e7e7e7);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.contentLayout{
|
|
50
|
+
gap:var(--space-toaster-toast-user-action-content-layout-gap, 8px);
|
|
51
|
+
padding-left:var(--space-toaster-toast-user-action-content-layout-horizont-padding, 8px);
|
|
52
|
+
padding-right:var(--space-toaster-toast-user-action-content-layout-horizont-padding, 8px);
|
|
53
|
+
display:flex;
|
|
54
|
+
align-items:center;
|
|
56
55
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ToastUserActionAppearance } from './
|
|
1
|
+
import { ToastUserActionAppearance } from './types';
|
|
2
2
|
export declare function getIcon(appearance: ToastUserActionAppearance): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { AlarmFilledSVG, CheckFilledSVG, CrossFilledSVG } from '@snack-uikit/icons';
|
|
3
|
-
import {
|
|
3
|
+
import { TOAST_SYSTEM_EVENT_APPEARANCE } from '../ToastSystemEvent/constants';
|
|
4
4
|
export function getIcon(appearance) {
|
|
5
5
|
switch (appearance) {
|
|
6
|
-
case
|
|
6
|
+
case TOAST_SYSTEM_EVENT_APPEARANCE.Success:
|
|
7
7
|
return _jsx(CheckFilledSVG, {});
|
|
8
|
-
case
|
|
8
|
+
case TOAST_SYSTEM_EVENT_APPEARANCE.Error:
|
|
9
9
|
return _jsx(CrossFilledSVG, {});
|
|
10
|
-
case
|
|
10
|
+
case TOAST_SYSTEM_EVENT_APPEARANCE.Warning:
|
|
11
11
|
return _jsx(AlarmFilledSVG, {});
|
|
12
|
-
case
|
|
12
|
+
case TOAST_SYSTEM_EVENT_APPEARANCE.Neutral:
|
|
13
13
|
default:
|
|
14
14
|
return null;
|
|
15
15
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MouseEvent } from 'react';
|
|
2
|
+
export type ButtonActionProps = {
|
|
3
|
+
label: string;
|
|
4
|
+
onClick(e: MouseEvent<HTMLButtonElement>): void;
|
|
5
|
+
critical?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare function ButtonAction({ label, onClick, critical }: ButtonActionProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { TOAST_SYSTEM_EVENT_TEST_IDS } from '../../testIds';
|
|
3
|
+
import styles from './styles.module.css';
|
|
4
|
+
export function ButtonAction({ label, onClick, critical }) {
|
|
5
|
+
return (_jsx("button", { className: styles.buttonAction, onClick: onClick, "data-test-id": TOAST_SYSTEM_EVENT_TEST_IDS.buttonAction, "aria-label": 'action', "data-critical": critical || undefined, children: label }));
|
|
6
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ButtonAction';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ButtonAction';
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
.buttonAction{
|
|
2
|
+
border-radius:var(--radius-toaster-toast-system-event-button, 8px);
|
|
3
|
+
height:var(--size-toaster-toast-system-event-button, 32px);
|
|
4
|
+
padding-left:var(--space-toaster-system-event-padding, 8px);
|
|
5
|
+
padding-right:var(--space-toaster-system-event-padding, 8px);
|
|
6
|
+
font-family:var(--sans-body-m-font-family, SB Sans Interface);
|
|
7
|
+
font-weight:var(--sans-body-m-font-weight, Regular);
|
|
8
|
+
line-height:var(--sans-body-m-line-height, 20px);
|
|
9
|
+
font-size:var(--sans-body-m-font-size, 14px);
|
|
10
|
+
letter-spacing:var(--sans-body-m-letter-spacing, 0.1px);
|
|
11
|
+
paragraph-spacing:var(--sans-body-m-paragraph-spacing, 7.7px);
|
|
12
|
+
cursor:pointer;
|
|
13
|
+
display:flex;
|
|
14
|
+
align-items:center;
|
|
15
|
+
justify-content:center;
|
|
16
|
+
box-sizing:border-box;
|
|
17
|
+
margin:0;
|
|
18
|
+
color:var(--sys-invert-neutral-text-main, #e7e7e7);
|
|
19
|
+
background-color:var(--sys-invert-neutral-decor-default, #333333);
|
|
20
|
+
border:none;
|
|
21
|
+
}
|
|
22
|
+
.buttonAction:hover, .buttonAction:focus-visible{
|
|
23
|
+
background-color:var(--sys-invert-neutral-decor-hovered, #494949);
|
|
24
|
+
}
|
|
25
|
+
.buttonAction:active{
|
|
26
|
+
background-color:var(--sys-invert-neutral-decor-activated, #494949);
|
|
27
|
+
}
|
|
28
|
+
.buttonAction:focus-visible{
|
|
29
|
+
outline-width:var(--border-state-focus-s-border-width, 2px);
|
|
30
|
+
outline-style:var(--border-state-focus-s-border-style, solid);
|
|
31
|
+
outline-color:var(--border-state-focus-s-border-color, );
|
|
32
|
+
outline-color:var(--sys-available-on-complementary, #fdfdfd);
|
|
33
|
+
outline-offset:var(--spacing-state-focus-offset, 2px);
|
|
34
|
+
}
|
|
35
|
+
.buttonAction[data-critical]{
|
|
36
|
+
background-color:var(--sys-opacity-enabled, rgba(253, 253, 253, 0.1607843137));
|
|
37
|
+
}
|
|
38
|
+
.buttonAction[data-critical]:hover, .buttonAction[data-critical]:focus-visible{
|
|
39
|
+
background-color:var(--sys-opacity-hovered, rgba(253, 253, 253, 0.2392156863));
|
|
40
|
+
}
|
|
41
|
+
.buttonAction[data-critical]:active{
|
|
42
|
+
background-color:var(--sys-opacity-activated, rgba(253, 253, 253, 0.3215686275));
|
|
43
|
+
}
|
package/dist/helpers.js
CHANGED
|
@@ -20,10 +20,10 @@ function getToasterContainer({ type, toasterParent, containerProps, }) {
|
|
|
20
20
|
toasterContainerProps,
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
function getToastOptions({ type, toastOptions, containerId, }) {
|
|
23
|
+
function getToastOptions({ type, toastOptions, containerId, toasterProps, }) {
|
|
24
24
|
return {
|
|
25
25
|
toastId: toastOptions === null || toastOptions === void 0 ? void 0 : toastOptions.id,
|
|
26
|
-
autoClose: AUTO_CLOSE_TIME[type],
|
|
26
|
+
autoClose: (toasterProps === null || toasterProps === void 0 ? void 0 : toasterProps.loading) ? false : AUTO_CLOSE_TIME[type],
|
|
27
27
|
containerId: containerId || `${TOASTER_CONTAINER_PREFIX}${type}`,
|
|
28
28
|
};
|
|
29
29
|
}
|
|
@@ -75,50 +75,50 @@ const userAction = {
|
|
|
75
75
|
success(options) {
|
|
76
76
|
return openToast({
|
|
77
77
|
type: ToasterType.UserAction,
|
|
78
|
-
toasterProps: Object.assign(Object.assign({}, options), { appearance:
|
|
78
|
+
toasterProps: Object.assign(Object.assign({}, options), { appearance: 'success' }),
|
|
79
79
|
});
|
|
80
80
|
},
|
|
81
81
|
neutral(options) {
|
|
82
82
|
return openToast({
|
|
83
83
|
type: ToasterType.UserAction,
|
|
84
|
-
toasterProps: Object.assign(Object.assign({}, options), { appearance:
|
|
84
|
+
toasterProps: Object.assign(Object.assign({}, options), { appearance: 'neutral' }),
|
|
85
85
|
});
|
|
86
86
|
},
|
|
87
87
|
error(options) {
|
|
88
88
|
return openToast({
|
|
89
89
|
type: ToasterType.UserAction,
|
|
90
|
-
toasterProps: Object.assign(Object.assign({}, options), { appearance:
|
|
90
|
+
toasterProps: Object.assign(Object.assign({}, options), { appearance: 'error' }),
|
|
91
91
|
});
|
|
92
92
|
},
|
|
93
93
|
warning(options) {
|
|
94
94
|
return openToast({
|
|
95
95
|
type: ToasterType.UserAction,
|
|
96
|
-
toasterProps: Object.assign(Object.assign({}, options), { appearance:
|
|
96
|
+
toasterProps: Object.assign(Object.assign({}, options), { appearance: 'warning' }),
|
|
97
97
|
});
|
|
98
98
|
},
|
|
99
99
|
update: {
|
|
100
100
|
success(id, options) {
|
|
101
101
|
updateToast(id, {
|
|
102
102
|
type: ToasterType.UserAction,
|
|
103
|
-
toasterProps: Object.assign(Object.assign({}, options), { appearance:
|
|
103
|
+
toasterProps: Object.assign(Object.assign({}, options), { appearance: 'success' }),
|
|
104
104
|
});
|
|
105
105
|
},
|
|
106
106
|
neutral(id, options) {
|
|
107
107
|
updateToast(id, {
|
|
108
108
|
type: ToasterType.UserAction,
|
|
109
|
-
toasterProps: Object.assign(Object.assign({}, options), { appearance:
|
|
109
|
+
toasterProps: Object.assign(Object.assign({}, options), { appearance: 'neutral' }),
|
|
110
110
|
});
|
|
111
111
|
},
|
|
112
112
|
warning(id, options) {
|
|
113
113
|
updateToast(id, {
|
|
114
114
|
type: ToasterType.UserAction,
|
|
115
|
-
toasterProps: Object.assign(Object.assign({}, options), { appearance:
|
|
115
|
+
toasterProps: Object.assign(Object.assign({}, options), { appearance: 'warning' }),
|
|
116
116
|
});
|
|
117
117
|
},
|
|
118
118
|
error(id, options) {
|
|
119
119
|
updateToast(id, {
|
|
120
120
|
type: ToasterType.UserAction,
|
|
121
|
-
toasterProps: Object.assign(Object.assign({}, options), { appearance:
|
|
121
|
+
toasterProps: Object.assign(Object.assign({}, options), { appearance: 'error' }),
|
|
122
122
|
});
|
|
123
123
|
},
|
|
124
124
|
},
|
|
@@ -130,62 +130,62 @@ const systemEvent = {
|
|
|
130
130
|
success(options) {
|
|
131
131
|
return openToast({
|
|
132
132
|
type: ToasterType.SystemEvent,
|
|
133
|
-
toasterProps: Object.assign(Object.assign({}, options), { appearance:
|
|
133
|
+
toasterProps: Object.assign(Object.assign({}, options), { appearance: 'success' }),
|
|
134
134
|
});
|
|
135
135
|
},
|
|
136
136
|
neutral(options) {
|
|
137
137
|
return openToast({
|
|
138
138
|
type: ToasterType.SystemEvent,
|
|
139
|
-
toasterProps: Object.assign(Object.assign({}, options), { appearance:
|
|
139
|
+
toasterProps: Object.assign(Object.assign({}, options), { appearance: 'neutral' }),
|
|
140
140
|
});
|
|
141
141
|
},
|
|
142
142
|
warning(options) {
|
|
143
143
|
return openToast({
|
|
144
144
|
type: ToasterType.SystemEvent,
|
|
145
|
-
toasterProps: Object.assign(Object.assign({}, options), { appearance:
|
|
145
|
+
toasterProps: Object.assign(Object.assign({}, options), { appearance: 'warning' }),
|
|
146
146
|
});
|
|
147
147
|
},
|
|
148
148
|
error(options) {
|
|
149
149
|
return openToast({
|
|
150
150
|
type: ToasterType.SystemEvent,
|
|
151
|
-
toasterProps: Object.assign(Object.assign({}, options), { appearance:
|
|
151
|
+
toasterProps: Object.assign(Object.assign({}, options), { appearance: 'error' }),
|
|
152
152
|
});
|
|
153
153
|
},
|
|
154
154
|
errorCritical(options) {
|
|
155
155
|
return openToast({
|
|
156
156
|
type: ToasterType.SystemEvent,
|
|
157
|
-
toasterProps: Object.assign(Object.assign({}, options), { appearance:
|
|
157
|
+
toasterProps: Object.assign(Object.assign({}, options), { appearance: 'errorCritical' }),
|
|
158
158
|
});
|
|
159
159
|
},
|
|
160
160
|
update: {
|
|
161
161
|
success(id, options) {
|
|
162
162
|
return updateToast(id, {
|
|
163
163
|
type: ToasterType.SystemEvent,
|
|
164
|
-
toasterProps: Object.assign(Object.assign({}, options), { appearance:
|
|
164
|
+
toasterProps: Object.assign(Object.assign({}, options), { appearance: 'success' }),
|
|
165
165
|
});
|
|
166
166
|
},
|
|
167
167
|
neutral(id, options) {
|
|
168
168
|
return updateToast(id, {
|
|
169
169
|
type: ToasterType.SystemEvent,
|
|
170
|
-
toasterProps: Object.assign(Object.assign({}, options), { appearance:
|
|
170
|
+
toasterProps: Object.assign(Object.assign({}, options), { appearance: 'neutral' }),
|
|
171
171
|
});
|
|
172
172
|
},
|
|
173
173
|
warning(id, options) {
|
|
174
174
|
return updateToast(id, {
|
|
175
175
|
type: ToasterType.SystemEvent,
|
|
176
|
-
toasterProps: Object.assign(Object.assign({}, options), { appearance:
|
|
176
|
+
toasterProps: Object.assign(Object.assign({}, options), { appearance: 'warning' }),
|
|
177
177
|
});
|
|
178
178
|
},
|
|
179
179
|
error(id, options) {
|
|
180
180
|
return updateToast(id, {
|
|
181
181
|
type: ToasterType.SystemEvent,
|
|
182
|
-
toasterProps: Object.assign(Object.assign({}, options), { appearance:
|
|
182
|
+
toasterProps: Object.assign(Object.assign({}, options), { appearance: 'error' }),
|
|
183
183
|
});
|
|
184
184
|
},
|
|
185
185
|
errorCritical(id, options) {
|
|
186
186
|
return updateToast(id, {
|
|
187
187
|
type: ToasterType.SystemEvent,
|
|
188
|
-
toasterProps: Object.assign(Object.assign({}, options), { appearance:
|
|
188
|
+
toasterProps: Object.assign(Object.assign({}, options), { appearance: 'errorCritical' }),
|
|
189
189
|
});
|
|
190
190
|
},
|
|
191
191
|
},
|
package/dist/testIds.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare const TOAST_SYSTEM_EVENT_TEST_IDS: {
|
|
|
4
4
|
title: string;
|
|
5
5
|
description: string;
|
|
6
6
|
buttonClose: string;
|
|
7
|
+
buttonAction: string;
|
|
7
8
|
link: string;
|
|
8
9
|
progressbar: string;
|
|
9
10
|
buttonCloseColumn: string;
|
|
@@ -12,5 +13,6 @@ export declare const TOAST_USER_ACTION_TEST_IDS: {
|
|
|
12
13
|
main: string;
|
|
13
14
|
label: string;
|
|
14
15
|
icon: string;
|
|
16
|
+
loader: string;
|
|
15
17
|
link: string;
|
|
16
18
|
};
|