@snack-uikit/alert 0.13.0 → 0.13.1-preview-93df0b94.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.
@@ -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, APPEARANCE_TO_LINK_COLOR_MAP } from '../../constants';
19
19
  import { AlertButton } from '../../helperComponents';
20
20
  import { getIcon } from '../../utils';
21
21
  import styles from './styles.module.css';
@@ -27,5 +27,5 @@ export function Alert(_a) {
27
27
  var { icon = true, title, truncate, link, description, onClose, appearance = APPEARANCE.Neutral, className, actions, outline, size = 'm' } = _a, rest = __rest(_a, ["icon", "title", "truncate", "link", "description", "onClose", "appearance", "className", "actions", "outline", "size"]);
28
28
  return (_jsxs("div", Object.assign({ className: cn(styles.alert, {
29
29
  [styles.alertOutline]: outline,
30
- }, className) }, extractSupportProps(rest), { "data-color": APPEARANCE_TO_COLOR_MAP[appearance], "data-size": size, children: [_jsxs("div", { className: styles.body, "data-size": size, children: [icon && (_jsx("div", { className: styles.icon, "data-color": APPEARANCE_TO_COLOR_MAP[appearance], "data-test-id": 'alert__icon', "data-size": size, children: getIcon(appearance, size === 's' ? 16 : 24) })), _jsxs("div", { className: styles.contentLayout, children: [title && (_jsx(TruncateString, { text: title, maxLines: (_b = truncate === null || truncate === void 0 ? void 0 : truncate.title) !== null && _b !== void 0 ? _b : 1, className: styles.title, "data-test-id": 'alert__title', "data-size": size })), _jsx("span", { "data-test-id": 'alert__description', className: styles.description, "data-size": size, children: description }), link && (_jsx("span", { children: _jsx(Link, Object.assign({}, link, { appearance: APPEARANCE_TO_COLOR_MAP[appearance], textMode: 'default', size: size, "data-test-id": 'alert__link' })) }))] }), onClose && (_jsx(AlertButton, { onClick: onClose, appearance: APPEARANCE_TO_COLOR_MAP[appearance], icon: _jsx(CrossSVG, {}), variant: 'simple', dataTestId: 'alert__close-button' }))] }), actions && (_jsxs("div", { className: styles.footer, "data-size": size, children: [actions.primary && (_jsx(AlertButton, Object.assign({}, actions.primary, { appearance: APPEARANCE_TO_COLOR_MAP[appearance], variant: 'simple', size: size }))), (actions === null || actions === void 0 ? void 0 : actions.secondary) && (_jsx(AlertButton, Object.assign({}, actions.secondary, { appearance: APPEARANCE_TO_COLOR_MAP[appearance], variant: 'simple', size: size })))] }))] })));
30
+ }, className) }, extractSupportProps(rest), { "data-color": APPEARANCE_TO_COLOR_MAP[appearance], "data-size": size, children: [_jsxs("div", { className: styles.body, "data-size": size, children: [icon && (_jsx("div", { className: styles.icon, "data-color": APPEARANCE_TO_COLOR_MAP[appearance], "data-test-id": 'alert__icon', "data-size": size, children: getIcon(appearance, size === 's' ? 16 : 24) })), _jsxs("div", { className: styles.contentLayout, children: [title && (_jsx(TruncateString, { text: title, maxLines: (_b = truncate === null || truncate === void 0 ? void 0 : truncate.title) !== null && _b !== void 0 ? _b : 1, className: styles.title, "data-test-id": 'alert__title', "data-size": size })), _jsx("span", { "data-test-id": 'alert__description', className: styles.description, "data-size": size, children: description }), link && (_jsx("span", { children: _jsx(Link, Object.assign({}, link, { appearance: APPEARANCE_TO_LINK_COLOR_MAP[appearance], textMode: 'default', size: size, "data-test-id": 'alert__link' })) }))] }), onClose && (_jsx(AlertButton, { onClick: onClose, appearance: APPEARANCE_TO_COLOR_MAP[appearance], icon: _jsx(CrossSVG, {}), variant: 'simple', dataTestId: 'alert__close-button' }))] }), actions && (_jsxs("div", { className: styles.footer, "data-size": size, children: [actions.primary && (_jsx(AlertButton, Object.assign({}, actions.primary, { appearance: APPEARANCE_TO_COLOR_MAP[appearance], variant: 'simple', size: size }))), (actions === null || actions === void 0 ? void 0 : actions.secondary) && (_jsx(AlertButton, Object.assign({}, actions.secondary, { appearance: APPEARANCE_TO_COLOR_MAP[appearance], variant: 'simple', size: size })))] }))] })));
31
31
  }
@@ -13,3 +13,4 @@ export declare const SIZE: {
13
13
  readonly M: "m";
14
14
  };
15
15
  export declare const APPEARANCE_TO_COLOR_MAP: Record<ValueOf<typeof APPEARANCE>, LinkProps['appearance']>;
16
+ export declare const APPEARANCE_TO_LINK_COLOR_MAP: Record<ValueOf<typeof APPEARANCE>, LinkProps['appearance']>;
package/dist/constants.js CHANGED
@@ -18,3 +18,11 @@ export const APPEARANCE_TO_COLOR_MAP = {
18
18
  [APPEARANCE.Success]: 'green',
19
19
  [APPEARANCE.Info]: 'blue',
20
20
  };
21
+ export const APPEARANCE_TO_LINK_COLOR_MAP = {
22
+ [APPEARANCE.Neutral]: 'primary',
23
+ [APPEARANCE.Primary]: 'primary',
24
+ [APPEARANCE.Error]: 'red',
25
+ [APPEARANCE.Warning]: 'yellow',
26
+ [APPEARANCE.Success]: 'green',
27
+ [APPEARANCE.Info]: 'blue',
28
+ };
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "Alert",
7
- "version": "0.13.0",
7
+ "version": "0.13.1-preview-93df0b94.0",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
@@ -39,5 +39,5 @@
39
39
  "@snack-uikit/utils": "3.3.0",
40
40
  "classnames": "2.3.2"
41
41
  },
42
- "gitHead": "86e5b8fc3a6235eddccf75485b6e989b6baf9a86"
42
+ "gitHead": "3f8cea2f1205605b31f27416fd444075f2373484"
43
43
  }
@@ -6,7 +6,7 @@ import { Link, LinkProps } 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, APPEARANCE_TO_LINK_COLOR_MAP } from '../../constants';
10
10
  import { AlertButton, AlertButtonProps } from '../../helperComponents';
11
11
  import { Appearance, Size } from '../../types';
12
12
  import { getIcon } from '../../utils';
@@ -107,7 +107,7 @@ export function Alert({
107
107
  <span>
108
108
  <Link
109
109
  {...link}
110
- appearance={APPEARANCE_TO_COLOR_MAP[appearance]}
110
+ appearance={APPEARANCE_TO_LINK_COLOR_MAP[appearance]}
111
111
  textMode='default'
112
112
  size={size}
113
113
  data-test-id='alert__link'
package/src/constants.ts CHANGED
@@ -23,3 +23,12 @@ export const APPEARANCE_TO_COLOR_MAP: Record<ValueOf<typeof APPEARANCE>, LinkPro
23
23
  [APPEARANCE.Success]: 'green',
24
24
  [APPEARANCE.Info]: 'blue',
25
25
  } as const;
26
+
27
+ export const APPEARANCE_TO_LINK_COLOR_MAP: Record<ValueOf<typeof APPEARANCE>, LinkProps['appearance']> = {
28
+ [APPEARANCE.Neutral]: 'primary',
29
+ [APPEARANCE.Primary]: 'primary',
30
+ [APPEARANCE.Error]: 'red',
31
+ [APPEARANCE.Warning]: 'yellow',
32
+ [APPEARANCE.Success]: 'green',
33
+ [APPEARANCE.Info]: 'blue',
34
+ } as const;