@snack-uikit/alert 0.6.1 → 0.7.1

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 CHANGED
@@ -3,6 +3,28 @@
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.1 (2023-12-14)
7
+
8
+ ### Only dependencies have been changed
9
+ * [@snack-uikit/icons@0.19.1](https://git.sbercloud.tech/sbercloud-ui/tokens-design-system/snack-uikit/-/blob/master/packages/icons/CHANGELOG.md)
10
+ * [@snack-uikit/link@0.9.1](https://git.sbercloud.tech/sbercloud-ui/tokens-design-system/snack-uikit/-/blob/master/packages/link/CHANGELOG.md)
11
+ * [@snack-uikit/truncate-string@0.4.1](https://git.sbercloud.tech/sbercloud-ui/tokens-design-system/snack-uikit/-/blob/master/packages/truncate-string/CHANGELOG.md)
12
+
13
+
14
+
15
+
16
+
17
+ # 0.7.0 (2023-12-14)
18
+
19
+
20
+ ### BREAKING CHANGES
21
+
22
+
23
+ * **FF-3729:** replace enum with unions ([910db4a](https://github.com/cloud-ru-tech/snack-uikit/commit/910db4aa8231ccbc58e538e5c5c1f461b1dec275))
24
+
25
+
26
+
27
+
6
28
  ## 0.6.1 (2023-12-06)
7
29
 
8
30
  ### 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={Alert.appearances.Neutral}
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={AlertTop.appearances.Neutral}
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"` | Alert.appearances.Neutral | Внешний вид |
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"` | AlertTop.appearances.Neutral | Внешний вид |
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 '../../constants';
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 { Appearance, APPEARANCE_TO_COLOR_MAP } from '../../constants';
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 = Alert.appearances.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: Link.onSurfaces.Decor, external: true, onColor: APPEARANCE_TO_COLOR_MAP[appearance], size: Link.sizes.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, {}) })))] })));
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", { className: styles.icon, "data-color": APPEARANCE_TO_COLOR_MAP[appearance], "data-test-id": 'alert__icon', children: getIcon(appearance) })), _jsxs("div", { className: styles.content, children: [_jsxs("div", { className: styles.textlayout, children: [title && _jsx(TruncateString, { text: title, maxLines: 1, className: styles.title, "data-test-id": 'alert__title' }), _jsx("span", { "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", { 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 '../../constants';
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 { Appearance, APPEARANCE_TO_COLOR_MAP } from '../../constants';
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 = AlertTop.appearances.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: Link.onSurfaces.Accent, href: href, text: link, external: true, onColor: APPEARANCE_TO_COLOR_MAP[appearance], size: Link.sizes.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, {}) })))] }))] })));
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", { className: styles.contentWrapper, children: [icon && (_jsx("div", { className: styles.icon, "data-color": APPEARANCE_TO_COLOR_MAP_INVERT[appearance], "data-test-id": 'alert-top__icon', children: getIcon(appearance) })), _jsxs("div", { className: styles.contentLayout, children: [_jsxs("div", { className: styles.textLayout, children: [title && (_jsx("div", { 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", { 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", { className: styles.actions, children: [buttonText && (_jsx(AlertTopButton, { buttonIcon: buttonIcon, buttonOnClick: buttonOnClick, buttonText: buttonText, appearance: appearance })), onClose && (_jsx("button", { 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: Color.InvertNeutral;
10
- readonly primary: Color.Primary;
11
- readonly error: Color.Red;
12
- readonly warning: Color.Yellow;
13
- readonly success: Color.Green;
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 { Appearance } from '../../constants';
2
- export var Color;
3
- (function (Color) {
4
- Color["InvertNeutral"] = "invert-neutral";
5
- Color["Primary"] = "primary";
6
- Color["Red"] = "red";
7
- Color["Yellow"] = "yellow";
8
- Color["Green"] = "green";
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
- [Appearance.Neutral]: Color.InvertNeutral,
12
- [Appearance.Primary]: Color.Primary,
13
- [Appearance.Error]: Color.Red,
14
- [Appearance.Warning]: Color.Yellow,
15
- [Appearance.Success]: Color.Green,
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
  };
@@ -1,15 +1,14 @@
1
- import { OnColor } from '@snack-uikit/link';
2
- export declare enum Appearance {
3
- Neutral = "neutral",
4
- Primary = "primary",
5
- Error = "error",
6
- Warning = "warning",
7
- Success = "success"
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: OnColor.Neutral;
11
- readonly primary: OnColor.Primary;
12
- readonly error: OnColor.Red;
13
- readonly warning: OnColor.Yellow;
14
- readonly success: OnColor.Green;
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 { OnColor } from '@snack-uikit/link';
2
- export var Appearance;
3
- (function (Appearance) {
4
- Appearance["Neutral"] = "neutral";
5
- Appearance["Primary"] = "primary";
6
- Appearance["Error"] = "error";
7
- Appearance["Warning"] = "warning";
8
- Appearance["Success"] = "success";
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
- [Appearance.Neutral]: OnColor.Neutral,
12
- [Appearance.Primary]: OnColor.Primary,
13
- [Appearance.Error]: OnColor.Red,
14
- [Appearance.Warning]: OnColor.Yellow,
15
- [Appearance.Success]: OnColor.Green,
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
  };
@@ -1,5 +1,5 @@
1
1
  import { ReactElement } from 'react';
2
- import { Appearance } from '../../constants';
2
+ import { Appearance } from '../../types';
3
3
  export type AlertTopButtonProps = {
4
4
  appearance: Appearance;
5
5
  buttonText: string;
@@ -2,5 +2,5 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { APPEARANCE_TO_COLOR_MAP_INVERT } from '../../components/AlertTop/constants';
3
3
  import styles from './styles.module.css';
4
4
  export function AlertTopButton({ appearance, buttonText, buttonIcon, buttonOnClick }) {
5
- return (_jsxs("button", Object.assign({ onClick: buttonOnClick, className: styles.alertTopButton, "data-color": APPEARANCE_TO_COLOR_MAP_INVERT[appearance] }, { children: [_jsx("span", { children: buttonText }), buttonIcon] })));
5
+ return (_jsxs("button", { onClick: buttonOnClick, className: styles.alertTopButton, "data-color": APPEARANCE_TO_COLOR_MAP_INVERT[appearance], children: [_jsx("span", { children: buttonText }), buttonIcon] }));
6
6
  }
@@ -0,0 +1,3 @@
1
+ import { ValueOf } from '@snack-uikit/utils';
2
+ import { APPEARANCE } from './constants';
3
+ export type Appearance = ValueOf<typeof APPEARANCE>;
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/dist/utils.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { Appearance } from './constants';
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 { Appearance } from './constants';
3
+ import { APPEARANCE } from './constants';
4
4
  export function getIcon(appearance) {
5
5
  switch (appearance) {
6
- case Appearance.Success:
6
+ case APPEARANCE.Success:
7
7
  return _jsx(CheckFilledSVG, {});
8
- case Appearance.Error:
8
+ case APPEARANCE.Error:
9
9
  return _jsx(CrossFilledSVG, {});
10
- case Appearance.Warning:
10
+ case APPEARANCE.Warning:
11
11
  return _jsx(AlarmFilledSVG, {});
12
- case Appearance.Primary:
13
- case Appearance.Neutral:
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.6.1",
7
+ "version": "0.7.1",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
@@ -32,11 +32,11 @@
32
32
  "license": "Apache-2.0",
33
33
  "scripts": {},
34
34
  "dependencies": {
35
- "@snack-uikit/icons": "0.19.0",
36
- "@snack-uikit/link": "0.8.1",
37
- "@snack-uikit/truncate-string": "0.3.1",
38
- "@snack-uikit/utils": "3.1.0",
35
+ "@snack-uikit/icons": "0.19.1",
36
+ "@snack-uikit/link": "0.9.1",
37
+ "@snack-uikit/truncate-string": "0.4.1",
38
+ "@snack-uikit/utils": "3.2.0",
39
39
  "classnames": "2.3.2"
40
40
  },
41
- "gitHead": "76a159dde7baccf49dc7b11e1fd7abc31424b42f"
41
+ "gitHead": "62f43bf0cbfd611d0b746117400f67096b1790f6"
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 { Appearance, APPEARANCE_TO_COLOR_MAP } from '../../constants';
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 = Alert.appearances.Neutral,
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={Link.onSurfaces.Decor}
70
+ onSurface='decor'
70
71
  external
71
72
  onColor={APPEARANCE_TO_COLOR_MAP[appearance]}
72
- size={Link.sizes.M}
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 { Appearance, APPEARANCE_TO_COLOR_MAP } from '../../constants';
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 = AlertTop.appearances.Neutral,
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={Link.onSurfaces.Accent}
98
+ onSurface='accent'
98
99
  href={href}
99
100
  text={link}
100
101
  external
101
102
  onColor={APPEARANCE_TO_COLOR_MAP[appearance]}
102
- size={Link.sizes.M}
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 { Appearance } from '../../constants';
1
+ import { APPEARANCE } from '../../constants';
2
2
 
3
- export enum Color {
4
- InvertNeutral = 'invert-neutral',
5
- Primary = 'primary',
6
- Red = 'red',
7
- Yellow = 'yellow',
8
- Green = '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
- [Appearance.Neutral]: Color.InvertNeutral,
13
- [Appearance.Primary]: Color.Primary,
14
- [Appearance.Error]: Color.Red,
15
- [Appearance.Warning]: Color.Yellow,
16
- [Appearance.Success]: Color.Green,
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 { OnColor } from '@snack-uikit/link';
1
+ import { ON_COLOR } from '@snack-uikit/link';
2
2
 
3
- export enum Appearance {
4
- Neutral = 'neutral',
5
- Primary = 'primary',
6
- Error = 'error',
7
- Warning = 'warning',
8
- Success = '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
- [Appearance.Neutral]: OnColor.Neutral,
13
- [Appearance.Primary]: OnColor.Primary,
14
- [Appearance.Error]: OnColor.Red,
15
- [Appearance.Warning]: OnColor.Yellow,
16
- [Appearance.Success]: OnColor.Green,
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 '../../constants';
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
@@ -0,0 +1,5 @@
1
+ import { ValueOf } from '@snack-uikit/utils';
2
+
3
+ import { APPEARANCE } from './constants';
4
+
5
+ export type Appearance = ValueOf<typeof APPEARANCE>;
package/src/utils.tsx CHANGED
@@ -1,17 +1,18 @@
1
1
  import { AlarmFilledSVG, CheckFilledSVG, CrossFilledSVG, InfoFilledSVG } from '@snack-uikit/icons';
2
2
 
3
- import { Appearance } from './constants';
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 Appearance.Success:
8
+ case APPEARANCE.Success:
8
9
  return <CheckFilledSVG />;
9
- case Appearance.Error:
10
+ case APPEARANCE.Error:
10
11
  return <CrossFilledSVG />;
11
- case Appearance.Warning:
12
+ case APPEARANCE.Warning:
12
13
  return <AlarmFilledSVG />;
13
- case Appearance.Primary:
14
- case Appearance.Neutral:
14
+ case APPEARANCE.Primary:
15
+ case APPEARANCE.Neutral:
15
16
  default:
16
17
  return <InfoFilledSVG />;
17
18
  }