@snack-uikit/alert 0.6.1 → 0.7.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 +11 -0
- package/README.md +5 -5
- package/dist/components/Alert/Alert.d.ts +1 -4
- package/dist/components/Alert/Alert.js +3 -4
- package/dist/components/AlertTop/AlertTop.d.ts +1 -4
- package/dist/components/AlertTop/AlertTop.js +3 -4
- package/dist/components/AlertTop/constants.d.ts +5 -12
- package/dist/components/AlertTop/constants.js +13 -14
- package/dist/constants.d.ts +12 -13
- package/dist/constants.js +13 -14
- package/dist/helperComponents/AlertTopButton/AlertTopButton.d.ts +1 -1
- package/dist/types.d.ts +3 -0
- package/dist/types.js +1 -0
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +6 -6
- package/package.json +5 -5
- package/src/components/Alert/Alert.tsx +5 -6
- package/src/components/AlertTop/AlertTop.tsx +5 -6
- package/src/components/AlertTop/constants.ts +13 -13
- package/src/constants.ts +13 -13
- package/src/helperComponents/AlertTopButton/AlertTopButton.tsx +1 -1
- package/src/types.ts +5 -0
- package/src/utils.tsx +7 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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.7.0 (2023-12-14)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### BREAKING CHANGES
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
* **FF-3729:** replace enum with unions ([910db4a](https://github.com/cloud-ru-tech/snack-uikit/commit/910db4aa8231ccbc58e538e5c5c1f461b1dec275))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## 0.6.1 (2023-12-06)
|
|
7
18
|
|
|
8
19
|
### Only dependencies have been changed
|
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ import { InfoFilledSVG } from '@snack-uikit/icons';
|
|
|
16
16
|
// It can be used to provide information, warnings, errors, or success messages.
|
|
17
17
|
|
|
18
18
|
<Alert
|
|
19
|
-
appearance=
|
|
19
|
+
appearance='neutral'
|
|
20
20
|
link='Link Text'
|
|
21
21
|
href='https://cloud.ru/'
|
|
22
22
|
icon={true}
|
|
@@ -29,7 +29,7 @@ import { InfoFilledSVG } from '@snack-uikit/icons';
|
|
|
29
29
|
// It can have an additional button with customizable text, icon, and click handler.
|
|
30
30
|
|
|
31
31
|
<AlertTop
|
|
32
|
-
appearance=
|
|
32
|
+
appearance='neutral'
|
|
33
33
|
link='Link Text'
|
|
34
34
|
href='https://cloud.ru/'
|
|
35
35
|
closeable={true}
|
|
@@ -56,7 +56,7 @@ import { InfoFilledSVG } from '@snack-uikit/icons';
|
|
|
56
56
|
| link | `string` | - | Текст ссылки |
|
|
57
57
|
| href | `string` | - | Ссылка |
|
|
58
58
|
| onClose | `() => void` | - | Колбек закрытия |
|
|
59
|
-
| appearance | enum Appearance: `"neutral"`, `"primary"`, `"error"`, `"warning"`, `"success"` |
|
|
59
|
+
| appearance | enum Appearance: `"neutral"`, `"primary"`, `"error"`, `"warning"`, `"success"` | neutral | Внешний вид |
|
|
60
60
|
| className | `string` | - | CSS-класс |
|
|
61
61
|
## AlertTop
|
|
62
62
|
Компонент для отображения уведомления вверху экрана.
|
|
@@ -69,11 +69,11 @@ import { InfoFilledSVG } from '@snack-uikit/icons';
|
|
|
69
69
|
| link | `string` | - | Текст ссылки |
|
|
70
70
|
| href | `string` | - | Ссылка |
|
|
71
71
|
| onClose | `() => void` | - | Колбек закрытия |
|
|
72
|
-
| appearance | enum Appearance: `"neutral"`, `"primary"`, `"error"`, `"warning"`, `"success"` |
|
|
72
|
+
| appearance | enum Appearance: `"neutral"`, `"primary"`, `"error"`, `"warning"`, `"success"` | neutral | Внешний вид |
|
|
73
73
|
| buttonText | `string` | - | Текст кнопки |
|
|
74
74
|
| buttonOnClick | `() => void` | - | Колбек клика по кнопке |
|
|
75
75
|
| buttonIcon | `ReactElement<any, string \| JSXElementConstructor<any>>` | - | Иконка в кнопке |
|
|
76
76
|
| className | `string` | - | CSS-класс |
|
|
77
77
|
|
|
78
78
|
|
|
79
|
-
[//]: DOCUMENTATION_SECTION_END
|
|
79
|
+
[//]: DOCUMENTATION_SECTION_END
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WithSupportProps } from '@snack-uikit/utils';
|
|
2
|
-
import { Appearance } from '../../
|
|
2
|
+
import { Appearance } from '../../types';
|
|
3
3
|
export type AlertProps = WithSupportProps<{
|
|
4
4
|
/** Отображать иконку */
|
|
5
5
|
icon?: boolean;
|
|
@@ -22,6 +22,3 @@ export type AlertProps = WithSupportProps<{
|
|
|
22
22
|
* Компонент для отображения уведомления.
|
|
23
23
|
*/
|
|
24
24
|
export declare function Alert({ icon, title, href, link, description, onClose, appearance, className, ...rest }: AlertProps): import("react/jsx-runtime").JSX.Element;
|
|
25
|
-
export declare namespace Alert {
|
|
26
|
-
var appearances: typeof Appearance;
|
|
27
|
-
}
|
|
@@ -15,14 +15,13 @@ import { CrossSVG } from '@snack-uikit/icons';
|
|
|
15
15
|
import { Link } from '@snack-uikit/link';
|
|
16
16
|
import { TruncateString } from '@snack-uikit/truncate-string';
|
|
17
17
|
import { extractSupportProps } from '@snack-uikit/utils';
|
|
18
|
-
import {
|
|
18
|
+
import { APPEARANCE, APPEARANCE_TO_COLOR_MAP } from '../../constants';
|
|
19
19
|
import { getIcon } from '../../utils';
|
|
20
20
|
import styles from './styles.module.css';
|
|
21
21
|
/**
|
|
22
22
|
* Компонент для отображения уведомления.
|
|
23
23
|
*/
|
|
24
24
|
export function Alert(_a) {
|
|
25
|
-
var { icon = true, title, href, link, description, onClose, appearance =
|
|
26
|
-
return (_jsxs("div", Object.assign({ className: cn(styles.alert, className) }, extractSupportProps(rest), { "data-color": APPEARANCE_TO_COLOR_MAP[appearance] }, { children: [icon && (_jsx("div", Object.assign({ className: styles.icon, "data-color": APPEARANCE_TO_COLOR_MAP[appearance], "data-test-id": 'alert__icon' }, { children: getIcon(appearance) }))), _jsxs("div", Object.assign({ className: styles.content }, { children: [_jsxs("div", Object.assign({ className: styles.textlayout }, { children: [title && _jsx(TruncateString, { text: title, maxLines: 1, className: styles.title, "data-test-id": 'alert__title' }), _jsx("span", Object.assign({ "data-test-id": 'alert__description', className: styles.description }, { children: description }))] })), link && (_jsx("span", { children: _jsx(Link, { href: href, text: link, onSurface:
|
|
25
|
+
var { icon = true, title, href, link, description, onClose, appearance = APPEARANCE.Neutral, className } = _a, rest = __rest(_a, ["icon", "title", "href", "link", "description", "onClose", "appearance", "className"]);
|
|
26
|
+
return (_jsxs("div", Object.assign({ className: cn(styles.alert, className) }, extractSupportProps(rest), { "data-color": APPEARANCE_TO_COLOR_MAP[appearance] }, { children: [icon && (_jsx("div", Object.assign({ className: styles.icon, "data-color": APPEARANCE_TO_COLOR_MAP[appearance], "data-test-id": 'alert__icon' }, { children: getIcon(appearance) }))), _jsxs("div", Object.assign({ className: styles.content }, { children: [_jsxs("div", Object.assign({ className: styles.textlayout }, { children: [title && _jsx(TruncateString, { text: title, maxLines: 1, className: styles.title, "data-test-id": 'alert__title' }), _jsx("span", Object.assign({ "data-test-id": 'alert__description', className: styles.description }, { children: description }))] })), link && (_jsx("span", { children: _jsx(Link, { href: href, text: link, onSurface: 'decor', external: true, onColor: APPEARANCE_TO_COLOR_MAP[appearance], size: 'm', "data-test-id": 'alert__link' }) }))] })), onClose && (_jsx("button", Object.assign({ onClick: onClose, className: styles.closeButton, "data-color": APPEARANCE_TO_COLOR_MAP[appearance], "data-test-id": 'alert__close-button' }, { children: _jsx(CrossSVG, {}) })))] })));
|
|
27
27
|
}
|
|
28
|
-
Alert.appearances = Appearance;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
2
|
import { WithSupportProps } from '@snack-uikit/utils';
|
|
3
|
-
import { Appearance } from '../../
|
|
3
|
+
import { Appearance } from '../../types';
|
|
4
4
|
export type AlertTopProps = WithSupportProps<{
|
|
5
5
|
/** Отображать иконку */
|
|
6
6
|
icon?: boolean;
|
|
@@ -29,6 +29,3 @@ export type AlertTopProps = WithSupportProps<{
|
|
|
29
29
|
* Компонент для отображения уведомления вверху экрана.
|
|
30
30
|
*/
|
|
31
31
|
export declare function AlertTop({ icon, title, description, link, href, onClose, appearance, buttonText, buttonOnClick, buttonIcon, className, ...rest }: AlertTopProps): import("react/jsx-runtime").JSX.Element;
|
|
32
|
-
export declare namespace AlertTop {
|
|
33
|
-
var appearances: typeof Appearance;
|
|
34
|
-
}
|
|
@@ -15,7 +15,7 @@ import { CrossSVG } from '@snack-uikit/icons';
|
|
|
15
15
|
import { Link } from '@snack-uikit/link';
|
|
16
16
|
import { TruncateString } from '@snack-uikit/truncate-string';
|
|
17
17
|
import { extractSupportProps } from '@snack-uikit/utils';
|
|
18
|
-
import {
|
|
18
|
+
import { APPEARANCE, APPEARANCE_TO_COLOR_MAP } from '../../constants';
|
|
19
19
|
import { AlertTopButton } from '../../helperComponents';
|
|
20
20
|
import { getIcon } from '../../utils';
|
|
21
21
|
import { APPEARANCE_TO_COLOR_MAP_INVERT } from './constants';
|
|
@@ -24,7 +24,6 @@ import styles from './styles.module.css';
|
|
|
24
24
|
* Компонент для отображения уведомления вверху экрана.
|
|
25
25
|
*/
|
|
26
26
|
export function AlertTop(_a) {
|
|
27
|
-
var { icon = true, title, description, link, href, onClose, appearance =
|
|
28
|
-
return (_jsxs("div", Object.assign({ className: cn(styles.alertTop, className) }, extractSupportProps(rest), { "data-color": APPEARANCE_TO_COLOR_MAP_INVERT[appearance] }, { children: [_jsxs("div", Object.assign({ className: styles.contentWrapper }, { children: [icon && (_jsx("div", Object.assign({ className: styles.icon, "data-color": APPEARANCE_TO_COLOR_MAP_INVERT[appearance], "data-test-id": 'alert-top__icon' }, { children: getIcon(appearance) }))), _jsxs("div", Object.assign({ className: styles.contentLayout }, { children: [_jsxs("div", Object.assign({ className: styles.textLayout }, { children: [title && (_jsx("div", Object.assign({ className: styles.title, "data-color": APPEARANCE_TO_COLOR_MAP_INVERT[appearance], "data-test-id": 'alert-top__title' }, { children: _jsx(TruncateString, { text: title, maxLines: 1 }) }))), _jsx("span", Object.assign({ className: styles.description, "data-color": APPEARANCE_TO_COLOR_MAP_INVERT[appearance], "data-test-id": 'alert-top__description' }, { children: description }))] })), link && (_jsx("span", { children: _jsx(Link, { onSurface:
|
|
27
|
+
var { icon = true, title, description, link, href, onClose, appearance = APPEARANCE.Neutral, buttonText, buttonOnClick, buttonIcon, className } = _a, rest = __rest(_a, ["icon", "title", "description", "link", "href", "onClose", "appearance", "buttonText", "buttonOnClick", "buttonIcon", "className"]);
|
|
28
|
+
return (_jsxs("div", Object.assign({ className: cn(styles.alertTop, className) }, extractSupportProps(rest), { "data-color": APPEARANCE_TO_COLOR_MAP_INVERT[appearance] }, { children: [_jsxs("div", Object.assign({ className: styles.contentWrapper }, { children: [icon && (_jsx("div", Object.assign({ className: styles.icon, "data-color": APPEARANCE_TO_COLOR_MAP_INVERT[appearance], "data-test-id": 'alert-top__icon' }, { children: getIcon(appearance) }))), _jsxs("div", Object.assign({ className: styles.contentLayout }, { children: [_jsxs("div", Object.assign({ className: styles.textLayout }, { children: [title && (_jsx("div", Object.assign({ className: styles.title, "data-color": APPEARANCE_TO_COLOR_MAP_INVERT[appearance], "data-test-id": 'alert-top__title' }, { children: _jsx(TruncateString, { text: title, maxLines: 1 }) }))), _jsx("span", Object.assign({ className: styles.description, "data-color": APPEARANCE_TO_COLOR_MAP_INVERT[appearance], "data-test-id": 'alert-top__description' }, { children: description }))] })), link && (_jsx("span", { children: _jsx(Link, { onSurface: 'accent', href: href, text: link, external: true, onColor: APPEARANCE_TO_COLOR_MAP[appearance], size: 'm', "data-test-id": 'alert-top__link' }) }))] }))] })), _jsxs("div", Object.assign({ className: styles.actions }, { children: [buttonText && (_jsx(AlertTopButton, { buttonIcon: buttonIcon, buttonOnClick: buttonOnClick, buttonText: buttonText, appearance: appearance })), onClose && (_jsx("button", Object.assign({ onClick: onClose, className: styles.closeButton, "data-color": APPEARANCE_TO_COLOR_MAP_INVERT[appearance], "data-test-id": 'alert-top__close-button' }, { children: _jsx(CrossSVG, {}) })))] }))] })));
|
|
29
29
|
}
|
|
30
|
-
AlertTop.appearances = Appearance;
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
export declare enum Color {
|
|
2
|
-
InvertNeutral = "invert-neutral",
|
|
3
|
-
Primary = "primary",
|
|
4
|
-
Red = "red",
|
|
5
|
-
Yellow = "yellow",
|
|
6
|
-
Green = "green"
|
|
7
|
-
}
|
|
8
1
|
export declare const APPEARANCE_TO_COLOR_MAP_INVERT: {
|
|
9
|
-
readonly neutral:
|
|
10
|
-
readonly primary:
|
|
11
|
-
readonly error:
|
|
12
|
-
readonly warning:
|
|
13
|
-
readonly success:
|
|
2
|
+
readonly neutral: "invert-neutral";
|
|
3
|
+
readonly primary: "primary";
|
|
4
|
+
readonly error: "red";
|
|
5
|
+
readonly warning: "yellow";
|
|
6
|
+
readonly success: "green";
|
|
14
7
|
};
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
})(Color || (Color = {}));
|
|
1
|
+
import { APPEARANCE } from '../../constants';
|
|
2
|
+
const COLOR = {
|
|
3
|
+
InvertNeutral: 'invert-neutral',
|
|
4
|
+
Primary: 'primary',
|
|
5
|
+
Red: 'red',
|
|
6
|
+
Yellow: 'yellow',
|
|
7
|
+
Green: 'green',
|
|
8
|
+
};
|
|
10
9
|
export const APPEARANCE_TO_COLOR_MAP_INVERT = {
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
10
|
+
[APPEARANCE.Neutral]: COLOR.InvertNeutral,
|
|
11
|
+
[APPEARANCE.Primary]: COLOR.Primary,
|
|
12
|
+
[APPEARANCE.Error]: COLOR.Red,
|
|
13
|
+
[APPEARANCE.Warning]: COLOR.Yellow,
|
|
14
|
+
[APPEARANCE.Success]: COLOR.Green,
|
|
16
15
|
};
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
1
|
+
export declare const APPEARANCE: {
|
|
2
|
+
readonly Neutral: "neutral";
|
|
3
|
+
readonly Primary: "primary";
|
|
4
|
+
readonly Error: "error";
|
|
5
|
+
readonly Warning: "warning";
|
|
6
|
+
readonly Success: "success";
|
|
7
|
+
};
|
|
9
8
|
export declare const APPEARANCE_TO_COLOR_MAP: {
|
|
10
|
-
readonly neutral:
|
|
11
|
-
readonly primary:
|
|
12
|
-
readonly error:
|
|
13
|
-
readonly warning:
|
|
14
|
-
readonly success:
|
|
9
|
+
readonly neutral: "neutral";
|
|
10
|
+
readonly primary: "primary";
|
|
11
|
+
readonly error: "red";
|
|
12
|
+
readonly warning: "yellow";
|
|
13
|
+
readonly success: "green";
|
|
15
14
|
};
|
package/dist/constants.js
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
})(Appearance || (Appearance = {}));
|
|
1
|
+
import { ON_COLOR } from '@snack-uikit/link';
|
|
2
|
+
export const APPEARANCE = {
|
|
3
|
+
Neutral: 'neutral',
|
|
4
|
+
Primary: 'primary',
|
|
5
|
+
Error: 'error',
|
|
6
|
+
Warning: 'warning',
|
|
7
|
+
Success: 'success',
|
|
8
|
+
};
|
|
10
9
|
export const APPEARANCE_TO_COLOR_MAP = {
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
10
|
+
[APPEARANCE.Neutral]: ON_COLOR.Neutral,
|
|
11
|
+
[APPEARANCE.Primary]: ON_COLOR.Primary,
|
|
12
|
+
[APPEARANCE.Error]: ON_COLOR.Red,
|
|
13
|
+
[APPEARANCE.Warning]: ON_COLOR.Yellow,
|
|
14
|
+
[APPEARANCE.Success]: ON_COLOR.Green,
|
|
16
15
|
};
|
package/dist/types.d.ts
ADDED
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Appearance } from './
|
|
1
|
+
import { Appearance } from './types';
|
|
2
2
|
export declare function getIcon(appearance: Appearance): import("react/jsx-runtime").JSX.Element;
|
package/dist/utils.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { AlarmFilledSVG, CheckFilledSVG, CrossFilledSVG, InfoFilledSVG } from '@snack-uikit/icons';
|
|
3
|
-
import {
|
|
3
|
+
import { APPEARANCE } from './constants';
|
|
4
4
|
export function getIcon(appearance) {
|
|
5
5
|
switch (appearance) {
|
|
6
|
-
case
|
|
6
|
+
case APPEARANCE.Success:
|
|
7
7
|
return _jsx(CheckFilledSVG, {});
|
|
8
|
-
case
|
|
8
|
+
case APPEARANCE.Error:
|
|
9
9
|
return _jsx(CrossFilledSVG, {});
|
|
10
|
-
case
|
|
10
|
+
case APPEARANCE.Warning:
|
|
11
11
|
return _jsx(AlarmFilledSVG, {});
|
|
12
|
-
case
|
|
13
|
-
case
|
|
12
|
+
case APPEARANCE.Primary:
|
|
13
|
+
case APPEARANCE.Neutral:
|
|
14
14
|
default:
|
|
15
15
|
return _jsx(InfoFilledSVG, {});
|
|
16
16
|
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Alert",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.7.0",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"scripts": {},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@snack-uikit/icons": "0.19.0",
|
|
36
|
-
"@snack-uikit/link": "0.
|
|
37
|
-
"@snack-uikit/truncate-string": "0.
|
|
38
|
-
"@snack-uikit/utils": "3.
|
|
36
|
+
"@snack-uikit/link": "0.9.0",
|
|
37
|
+
"@snack-uikit/truncate-string": "0.4.0",
|
|
38
|
+
"@snack-uikit/utils": "3.2.0",
|
|
39
39
|
"classnames": "2.3.2"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "bd39c5e674f3b91b0e2487782a04b15034cf3d8b"
|
|
42
42
|
}
|
|
@@ -5,7 +5,8 @@ import { Link } from '@snack-uikit/link';
|
|
|
5
5
|
import { TruncateString } from '@snack-uikit/truncate-string';
|
|
6
6
|
import { extractSupportProps, WithSupportProps } from '@snack-uikit/utils';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { APPEARANCE, APPEARANCE_TO_COLOR_MAP } from '../../constants';
|
|
9
|
+
import { Appearance } from '../../types';
|
|
9
10
|
import { getIcon } from '../../utils';
|
|
10
11
|
import styles from './styles.module.scss';
|
|
11
12
|
|
|
@@ -38,7 +39,7 @@ export function Alert({
|
|
|
38
39
|
link,
|
|
39
40
|
description,
|
|
40
41
|
onClose,
|
|
41
|
-
appearance =
|
|
42
|
+
appearance = APPEARANCE.Neutral,
|
|
42
43
|
className,
|
|
43
44
|
...rest
|
|
44
45
|
}: AlertProps) {
|
|
@@ -66,10 +67,10 @@ export function Alert({
|
|
|
66
67
|
<Link
|
|
67
68
|
href={href}
|
|
68
69
|
text={link}
|
|
69
|
-
onSurface=
|
|
70
|
+
onSurface='decor'
|
|
70
71
|
external
|
|
71
72
|
onColor={APPEARANCE_TO_COLOR_MAP[appearance]}
|
|
72
|
-
size=
|
|
73
|
+
size='m'
|
|
73
74
|
data-test-id='alert__link'
|
|
74
75
|
/>
|
|
75
76
|
</span>
|
|
@@ -88,5 +89,3 @@ export function Alert({
|
|
|
88
89
|
</div>
|
|
89
90
|
);
|
|
90
91
|
}
|
|
91
|
-
|
|
92
|
-
Alert.appearances = Appearance;
|
|
@@ -6,8 +6,9 @@ import { Link } from '@snack-uikit/link';
|
|
|
6
6
|
import { TruncateString } from '@snack-uikit/truncate-string';
|
|
7
7
|
import { extractSupportProps, WithSupportProps } from '@snack-uikit/utils';
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import { APPEARANCE, APPEARANCE_TO_COLOR_MAP } from '../../constants';
|
|
10
10
|
import { AlertTopButton } from '../../helperComponents';
|
|
11
|
+
import { Appearance } from '../../types';
|
|
11
12
|
import { getIcon } from '../../utils';
|
|
12
13
|
import { APPEARANCE_TO_COLOR_MAP_INVERT } from './constants';
|
|
13
14
|
import styles from './styles.module.scss';
|
|
@@ -47,7 +48,7 @@ export function AlertTop({
|
|
|
47
48
|
link,
|
|
48
49
|
href,
|
|
49
50
|
onClose,
|
|
50
|
-
appearance =
|
|
51
|
+
appearance = APPEARANCE.Neutral,
|
|
51
52
|
buttonText,
|
|
52
53
|
buttonOnClick,
|
|
53
54
|
buttonIcon,
|
|
@@ -94,12 +95,12 @@ export function AlertTop({
|
|
|
94
95
|
{link && (
|
|
95
96
|
<span>
|
|
96
97
|
<Link
|
|
97
|
-
onSurface=
|
|
98
|
+
onSurface='accent'
|
|
98
99
|
href={href}
|
|
99
100
|
text={link}
|
|
100
101
|
external
|
|
101
102
|
onColor={APPEARANCE_TO_COLOR_MAP[appearance]}
|
|
102
|
-
size=
|
|
103
|
+
size='m'
|
|
103
104
|
data-test-id='alert-top__link'
|
|
104
105
|
/>
|
|
105
106
|
</span>
|
|
@@ -130,5 +131,3 @@ export function AlertTop({
|
|
|
130
131
|
</div>
|
|
131
132
|
);
|
|
132
133
|
}
|
|
133
|
-
|
|
134
|
-
AlertTop.appearances = Appearance;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { APPEARANCE } from '../../constants';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
InvertNeutral
|
|
5
|
-
Primary
|
|
6
|
-
Red
|
|
7
|
-
Yellow
|
|
8
|
-
Green
|
|
9
|
-
}
|
|
3
|
+
const COLOR = {
|
|
4
|
+
InvertNeutral: 'invert-neutral',
|
|
5
|
+
Primary: 'primary',
|
|
6
|
+
Red: 'red',
|
|
7
|
+
Yellow: 'yellow',
|
|
8
|
+
Green: 'green',
|
|
9
|
+
} as const;
|
|
10
10
|
|
|
11
11
|
export const APPEARANCE_TO_COLOR_MAP_INVERT = {
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
16
|
-
[
|
|
12
|
+
[APPEARANCE.Neutral]: COLOR.InvertNeutral,
|
|
13
|
+
[APPEARANCE.Primary]: COLOR.Primary,
|
|
14
|
+
[APPEARANCE.Error]: COLOR.Red,
|
|
15
|
+
[APPEARANCE.Warning]: COLOR.Yellow,
|
|
16
|
+
[APPEARANCE.Success]: COLOR.Green,
|
|
17
17
|
} as const;
|
package/src/constants.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ON_COLOR } from '@snack-uikit/link';
|
|
2
2
|
|
|
3
|
-
export
|
|
4
|
-
Neutral
|
|
5
|
-
Primary
|
|
6
|
-
Error
|
|
7
|
-
Warning
|
|
8
|
-
Success
|
|
9
|
-
}
|
|
3
|
+
export const APPEARANCE = {
|
|
4
|
+
Neutral: 'neutral',
|
|
5
|
+
Primary: 'primary',
|
|
6
|
+
Error: 'error',
|
|
7
|
+
Warning: 'warning',
|
|
8
|
+
Success: 'success',
|
|
9
|
+
} as const;
|
|
10
10
|
|
|
11
11
|
export const APPEARANCE_TO_COLOR_MAP = {
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
16
|
-
[
|
|
12
|
+
[APPEARANCE.Neutral]: ON_COLOR.Neutral,
|
|
13
|
+
[APPEARANCE.Primary]: ON_COLOR.Primary,
|
|
14
|
+
[APPEARANCE.Error]: ON_COLOR.Red,
|
|
15
|
+
[APPEARANCE.Warning]: ON_COLOR.Yellow,
|
|
16
|
+
[APPEARANCE.Success]: ON_COLOR.Green,
|
|
17
17
|
} as const;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
2
|
|
|
3
3
|
import { APPEARANCE_TO_COLOR_MAP_INVERT } from '../../components/AlertTop/constants';
|
|
4
|
-
import { Appearance } from '../../
|
|
4
|
+
import { Appearance } from '../../types';
|
|
5
5
|
import styles from './styles.module.scss';
|
|
6
6
|
|
|
7
7
|
export type AlertTopButtonProps = {
|
package/src/types.ts
ADDED
package/src/utils.tsx
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { AlarmFilledSVG, CheckFilledSVG, CrossFilledSVG, InfoFilledSVG } from '@snack-uikit/icons';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { APPEARANCE } from './constants';
|
|
4
|
+
import { Appearance } from './types';
|
|
4
5
|
|
|
5
6
|
export function getIcon(appearance: Appearance) {
|
|
6
7
|
switch (appearance) {
|
|
7
|
-
case
|
|
8
|
+
case APPEARANCE.Success:
|
|
8
9
|
return <CheckFilledSVG />;
|
|
9
|
-
case
|
|
10
|
+
case APPEARANCE.Error:
|
|
10
11
|
return <CrossFilledSVG />;
|
|
11
|
-
case
|
|
12
|
+
case APPEARANCE.Warning:
|
|
12
13
|
return <AlarmFilledSVG />;
|
|
13
|
-
case
|
|
14
|
-
case
|
|
14
|
+
case APPEARANCE.Primary:
|
|
15
|
+
case APPEARANCE.Neutral:
|
|
15
16
|
default:
|
|
16
17
|
return <InfoFilledSVG />;
|
|
17
18
|
}
|