@snack-uikit/alert 0.11.5-preview-a882321d.0 → 0.12.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 +22 -0
- package/README.md +6 -4
- package/dist/components/Alert/Alert.d.ts +7 -3
- package/dist/components/Alert/Alert.js +4 -2
- package/dist/components/Alert/styles.module.css +119 -24
- package/dist/components/AlertTop/AlertTop.d.ts +1 -1
- package/dist/components/AlertTop/AlertTop.js +1 -1
- package/dist/components/AlertTop/constants.d.ts +1 -0
- package/dist/components/AlertTop/constants.js +2 -0
- package/dist/components/AlertTop/styles.module.css +12 -0
- package/dist/constants.d.ts +5 -0
- package/dist/constants.js +6 -0
- package/dist/helperComponents/AlertButton.d.ts +6 -1
- package/dist/helperComponents/AlertButton.js +3 -2
- package/dist/helperComponents/styles.module.css +48 -15
- package/dist/types.d.ts +2 -1
- package/package.json +6 -5
- package/src/components/Alert/Alert.tsx +40 -10
- package/src/components/Alert/styles.module.scss +66 -22
- package/src/components/AlertTop/AlertTop.tsx +2 -1
- package/src/components/AlertTop/constants.ts +2 -0
- package/src/components/AlertTop/styles.module.scss +1 -1
- package/src/constants.ts +7 -0
- package/src/helperComponents/AlertButton.tsx +16 -2
- package/src/helperComponents/styles.module.scss +25 -9
- package/src/types.ts +3 -1
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.12.0 (2024-07-24)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **PDS-128:** add alert-component updates ([93068f3](https://github.com/cloud-ru-tech/snack-uikit/commit/93068f3b499363d882efd69f6a4b5145b410f3c1))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## 0.11.5 (2024-07-19)
|
|
18
|
+
|
|
19
|
+
### Only dependencies have been changed
|
|
20
|
+
* [@snack-uikit/icons@0.22.0](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/icons/CHANGELOG.md)
|
|
21
|
+
* [@snack-uikit/link@0.12.4](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/link/CHANGELOG.md)
|
|
22
|
+
* [@snack-uikit/truncate-string@0.4.20](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/truncate-string/CHANGELOG.md)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
6
28
|
## 0.11.4 (2024-06-27)
|
|
7
29
|
|
|
8
30
|
### Only dependencies have been changed
|
package/README.md
CHANGED
|
@@ -58,9 +58,11 @@ import { InfoFilledSVG } from '@snack-uikit/icons';
|
|
|
58
58
|
| icon | `boolean` | true | Отображать иконку |
|
|
59
59
|
| title | `string` | - | Заголовок |
|
|
60
60
|
| truncate | `{ title?: number; }` | '{ <br>title: 1 }' | Максимальное кол-во строк <br> - `title` - в заголовке |
|
|
61
|
-
| link | `Pick<LinkProps, "text" \| "target" \| "onClick" \| "href" \| "appearance">` | - | Cсылка |
|
|
61
|
+
| link | `Pick<LinkProps, "text" \| "target" \| "onClick" \| "href" \| "appearance" \| "external">` | - | Cсылка |
|
|
62
62
|
| onClose | `() => void` | - | Колбек закрытия |
|
|
63
|
-
| appearance | enum Appearance: `"neutral"`, `"primary"`, `"error"`, `"warning"`, `"success"` | neutral | Внешний вид |
|
|
63
|
+
| appearance | enum Appearance: `"neutral"`, `"primary"`, `"error"`, `"warning"`, `"success"`, `"info"` | neutral | Внешний вид |
|
|
64
|
+
| outline | `boolean` | - | Внешний бордер |
|
|
65
|
+
| size | enum Size: `"s"`, `"m"` | m | Размер |
|
|
64
66
|
| className | `string` | - | CSS-класс |
|
|
65
67
|
| actions | `{ primary: Omit<AlertButtonProps, "appearance">; secondary?: Omit<AlertButtonProps, "appearance">; }` | - | Кнопки в футере алерта |
|
|
66
68
|
## AlertTop
|
|
@@ -72,10 +74,10 @@ import { InfoFilledSVG } from '@snack-uikit/icons';
|
|
|
72
74
|
| icon | `boolean` | true | Отображать иконку |
|
|
73
75
|
| title | `string` | - | Заголовок |
|
|
74
76
|
| truncate | `{ title?: number; }` | '{ <br>title: 1 }' | Максимальное кол-во строк <br> - `title` - в заголовке |
|
|
75
|
-
| link | `Pick<LinkProps, "text" \| "target" \| "onClick" \| "href" \| "appearance">` | - | Cсылка |
|
|
77
|
+
| link | `Pick<LinkProps, "text" \| "target" \| "onClick" \| "href" \| "appearance" \| "external">` | - | Cсылка |
|
|
76
78
|
| action | `AlertButtonProps` | - | Кнопка дополнительного действия |
|
|
77
79
|
| onClose | `() => void` | - | Колбек закрытия |
|
|
78
|
-
| appearance | enum Appearance: `"neutral"`, `"primary"`, `"error"`, `"warning"`, `"success"` | neutral | Внешний вид |
|
|
80
|
+
| appearance | enum Appearance: `"neutral"`, `"primary"`, `"error"`, `"warning"`, `"success"`, `"info"` | neutral | Внешний вид |
|
|
79
81
|
| className | `string` | - | CSS-класс |
|
|
80
82
|
|
|
81
83
|
|
|
@@ -2,7 +2,7 @@ import { ReactNode } from 'react';
|
|
|
2
2
|
import { LinkProps } from '@snack-uikit/link';
|
|
3
3
|
import { WithSupportProps } from '@snack-uikit/utils';
|
|
4
4
|
import { AlertButtonProps } from '../../helperComponents';
|
|
5
|
-
import { Appearance } from '../../types';
|
|
5
|
+
import { Appearance, Size } from '../../types';
|
|
6
6
|
export type AlertProps = WithSupportProps<{
|
|
7
7
|
/** Отображать иконку */
|
|
8
8
|
icon?: boolean;
|
|
@@ -19,11 +19,15 @@ export type AlertProps = WithSupportProps<{
|
|
|
19
19
|
/** Описание */
|
|
20
20
|
description: ReactNode;
|
|
21
21
|
/** Cсылка */
|
|
22
|
-
link?: Pick<LinkProps, 'text' | 'target' | 'onClick' | 'href' | 'appearance'>;
|
|
22
|
+
link?: Pick<LinkProps, 'text' | 'target' | 'onClick' | 'href' | 'appearance' | 'external'>;
|
|
23
23
|
/** Колбек закрытия */
|
|
24
24
|
onClose?: () => void;
|
|
25
25
|
/** Внешний вид */
|
|
26
26
|
appearance?: Appearance;
|
|
27
|
+
/** Внешний бордер */
|
|
28
|
+
outline?: boolean;
|
|
29
|
+
/** Размер */
|
|
30
|
+
size?: Size;
|
|
27
31
|
/** CSS-класс */
|
|
28
32
|
className?: string;
|
|
29
33
|
/** Кнопки в футере алерта */
|
|
@@ -35,4 +39,4 @@ export type AlertProps = WithSupportProps<{
|
|
|
35
39
|
/**
|
|
36
40
|
* Компонент для отображения уведомления.
|
|
37
41
|
*/
|
|
38
|
-
export declare function Alert({ icon, title, truncate, link, description, onClose, appearance, className, actions, ...rest }: AlertProps): import("react/jsx-runtime").JSX.Element;
|
|
42
|
+
export declare function Alert({ icon, title, truncate, link, description, onClose, appearance, className, actions, outline, size, ...rest }: AlertProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -24,6 +24,8 @@ import styles from './styles.module.css';
|
|
|
24
24
|
*/
|
|
25
25
|
export function Alert(_a) {
|
|
26
26
|
var _b;
|
|
27
|
-
var { icon = true, title, truncate, link, description, onClose, appearance = APPEARANCE.Neutral, className, actions } = _a, rest = __rest(_a, ["icon", "title", "truncate", "link", "description", "onClose", "appearance", "className", "actions"]);
|
|
28
|
-
return (_jsxs("div", Object.assign({ className: cn(styles.alert,
|
|
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
|
+
return (_jsxs("div", Object.assign({ className: cn(styles.alert, {
|
|
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) })), _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({ external: true }, 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 })))] }))] })));
|
|
29
31
|
}
|
|
@@ -1,49 +1,99 @@
|
|
|
1
1
|
.alert{
|
|
2
|
-
padding-top:var(--space-alert-container-vertical-padding, 14px);
|
|
3
|
-
padding-bottom:var(--space-alert-container-vertical-padding, 14px);
|
|
4
|
-
padding-left:var(--space-alert-container-horizontal-padding, 14px);
|
|
5
|
-
padding-right:var(--space-alert-container-horizontal-padding, 14px);
|
|
6
|
-
gap:var(--space-alert-container-gap, 14px);
|
|
7
|
-
border-radius:var(--radius-alert-container, 8px);
|
|
8
|
-
border-width:var(--border-width-general-xs, 1px);
|
|
9
2
|
display:flex;
|
|
10
3
|
flex-direction:column;
|
|
11
4
|
box-sizing:border-box;
|
|
12
5
|
min-width:256px;
|
|
13
|
-
border-style:solid;
|
|
14
6
|
}
|
|
15
7
|
.alert[data-color=neutral]{
|
|
16
8
|
background-color:var(--sys-neutral-background, #eeeff3);
|
|
17
|
-
border-color:var(--sys-neutral-decor-default, #dde0ea);
|
|
18
9
|
}
|
|
19
10
|
.alert[data-color=primary]{
|
|
20
11
|
background-color:var(--sys-primary-background, #f6effe);
|
|
21
|
-
border-color:var(--sys-primary-decor-default, #ebdefd);
|
|
22
12
|
}
|
|
23
13
|
.alert[data-color=red]{
|
|
24
14
|
background-color:var(--sys-red-background, #fdedea);
|
|
25
|
-
border-color:var(--sys-red-decor-default, #fdd6cd);
|
|
26
15
|
}
|
|
27
16
|
.alert[data-color=yellow]{
|
|
28
17
|
background-color:var(--sys-yellow-background, #fcf4da);
|
|
29
|
-
border-color:var(--sys-yellow-decor-default, #f0dfb1);
|
|
30
18
|
}
|
|
31
19
|
.alert[data-color=green]{
|
|
32
20
|
background-color:var(--sys-green-background, #ecf6ea);
|
|
33
|
-
|
|
21
|
+
}
|
|
22
|
+
.alert[data-color=blue]{
|
|
23
|
+
background-color:var(--sys-blue-background, #edf4fd);
|
|
24
|
+
}
|
|
25
|
+
.alert[data-size=s]{
|
|
26
|
+
padding-top:var(--space-alert-s-container-vertical-padding, 7px);
|
|
27
|
+
padding-bottom:var(--space-alert-s-container-vertical-padding, 7px);
|
|
28
|
+
padding-left:var(--space-alert-s-container-horizontal-padding, 7px);
|
|
29
|
+
padding-right:var(--space-alert-s-container-horizontal-padding, 7px);
|
|
30
|
+
gap:var(--space-alert-s-container-gap, 7px);
|
|
31
|
+
border-radius:var(--radius-alert-container, 8px);
|
|
32
|
+
border-width:var(--border-width-alert-single, 1px);
|
|
33
|
+
}
|
|
34
|
+
.alert[data-size=m]{
|
|
35
|
+
padding-top:var(--space-alert-m-container-vertical-padding, 15px);
|
|
36
|
+
padding-bottom:var(--space-alert-m-container-vertical-padding, 15px);
|
|
37
|
+
padding-left:var(--space-alert-m-container-horizontal-padding, 15px);
|
|
38
|
+
padding-right:var(--space-alert-m-container-horizontal-padding, 15px);
|
|
39
|
+
gap:var(--space-alert-m-container-gap, 15px);
|
|
40
|
+
border-radius:var(--radius-alert-container, 8px);
|
|
41
|
+
border-width:var(--border-width-alert-single, 1px);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.alertOutline{
|
|
45
|
+
outline-style:solid;
|
|
46
|
+
outline-width:var(--border-width-accordion-collapse-block-primary, 1px);
|
|
47
|
+
}
|
|
48
|
+
.alertOutline[data-color=neutral]{
|
|
49
|
+
outline-color:var(--sys-neutral-decor-default, #dde0ea);
|
|
50
|
+
}
|
|
51
|
+
.alertOutline[data-color=neutral]:focus-within, .alertOutline[data-color=neutral]:hover{
|
|
52
|
+
outline-color:var(--sys-neutral-decor-default, #dde0ea);
|
|
53
|
+
}
|
|
54
|
+
.alertOutline[data-color=primary]{
|
|
55
|
+
outline-color:var(--sys-primary-decor-default, #ebdefd);
|
|
56
|
+
}
|
|
57
|
+
.alertOutline[data-color=primary]:focus-within, .alertOutline[data-color=primary]:hover{
|
|
58
|
+
outline-color:var(--sys-primary-decor-default, #ebdefd);
|
|
59
|
+
}
|
|
60
|
+
.alertOutline[data-color=red]{
|
|
61
|
+
outline-color:var(--sys-red-decor-default, #fdd6cd);
|
|
62
|
+
}
|
|
63
|
+
.alertOutline[data-color=red]:focus-within, .alertOutline[data-color=red]:hover{
|
|
64
|
+
outline-color:var(--sys-red-decor-default, #fdd6cd);
|
|
65
|
+
}
|
|
66
|
+
.alertOutline[data-color=yellow]{
|
|
67
|
+
outline-color:var(--sys-yellow-decor-default, #f0dfb1);
|
|
68
|
+
}
|
|
69
|
+
.alertOutline[data-color=yellow]:focus-within, .alertOutline[data-color=yellow]:hover{
|
|
70
|
+
outline-color:var(--sys-yellow-decor-default, #f0dfb1);
|
|
71
|
+
}
|
|
72
|
+
.alertOutline[data-color=green]{
|
|
73
|
+
outline-color:var(--sys-green-decor-default, #d2ead0);
|
|
74
|
+
}
|
|
75
|
+
.alertOutline[data-color=green]:focus-within, .alertOutline[data-color=green]:hover{
|
|
76
|
+
outline-color:var(--sys-green-decor-default, #d2ead0);
|
|
77
|
+
}
|
|
78
|
+
.alertOutline[data-color=blue]{
|
|
79
|
+
outline-color:var(--sys-blue-decor-default, #d6e2f4);
|
|
80
|
+
}
|
|
81
|
+
.alertOutline[data-color=blue]:focus-within, .alertOutline[data-color=blue]:hover{
|
|
82
|
+
outline-color:var(--sys-blue-decor-default, #d6e2f4);
|
|
34
83
|
}
|
|
35
84
|
|
|
36
85
|
.body{
|
|
37
|
-
gap:var(--space-alert-container-body-gap, 8px);
|
|
38
86
|
display:flex;
|
|
39
87
|
box-sizing:border-box;
|
|
40
88
|
width:100%;
|
|
41
89
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
width:var(--size-icon-container-s, 24px);
|
|
45
|
-
height:var(--size-icon-container-s, 24px);
|
|
90
|
+
.body[data-size=s]{
|
|
91
|
+
gap:var(--space-alert-s-container-body-gap, 4px);
|
|
46
92
|
}
|
|
93
|
+
.body[data-size=m]{
|
|
94
|
+
gap:var(--space-alert-m-container-body-gap, 8px);
|
|
95
|
+
}
|
|
96
|
+
|
|
47
97
|
.icon[data-color=neutral]{
|
|
48
98
|
color:var(--sys-neutral-accent-default, #787b8a);
|
|
49
99
|
}
|
|
@@ -59,45 +109,90 @@
|
|
|
59
109
|
.icon[data-color=green]{
|
|
60
110
|
color:var(--sys-green-accent-default, #57b762);
|
|
61
111
|
}
|
|
62
|
-
.icon
|
|
112
|
+
.icon[data-color=blue]{
|
|
113
|
+
color:var(--sys-blue-accent-default, #5388d1);
|
|
114
|
+
}
|
|
115
|
+
.icon[data-size=s]{
|
|
116
|
+
width:var(--size-icon-container-xs, 16px);
|
|
117
|
+
height:var(--size-icon-container-xs, 16px);
|
|
118
|
+
}
|
|
119
|
+
.icon[data-size=s] svg{
|
|
120
|
+
max-width:var(--size-icon-container-xs, 16px);
|
|
121
|
+
max-height:var(--size-icon-container-xs, 16px);
|
|
122
|
+
}
|
|
123
|
+
.icon[data-size=m]{
|
|
124
|
+
width:var(--size-icon-container-s, 24px);
|
|
125
|
+
height:var(--size-icon-container-s, 24px);
|
|
126
|
+
}
|
|
127
|
+
.icon[data-size=m] svg{
|
|
63
128
|
max-width:var(--size-icon-container-s, 24px);
|
|
64
129
|
max-height:var(--size-icon-container-s, 24px);
|
|
65
130
|
}
|
|
66
131
|
|
|
67
132
|
.contentLayout{
|
|
68
|
-
padding-top:var(--space-alert-container-content-layout-padding-top, 2px);
|
|
69
133
|
display:flex;
|
|
70
134
|
flex:1;
|
|
71
135
|
flex-direction:column;
|
|
72
136
|
min-width:0;
|
|
73
137
|
}
|
|
138
|
+
.contentLayout[data-size=s]{
|
|
139
|
+
padding-top:var(--space-alert-s-container-content-layout-padding-top, 0px);
|
|
140
|
+
}
|
|
141
|
+
.contentLayout[data-size=m]{
|
|
142
|
+
padding-top:var(--space-alert-m-container-content-layout-padding-top, 2px);
|
|
143
|
+
}
|
|
74
144
|
|
|
75
145
|
.title{
|
|
146
|
+
color:var(--sys-neutral-text-main, #33343f);
|
|
147
|
+
}
|
|
148
|
+
.title[data-size=s]{
|
|
76
149
|
font-family:var(--sans-title-s-font-family, SB Sans Interface);
|
|
77
150
|
font-weight:var(--sans-title-s-font-weight, Semibold);
|
|
78
151
|
line-height:var(--sans-title-s-line-height, 20px);
|
|
79
152
|
font-size:var(--sans-title-s-font-size, 14px);
|
|
80
153
|
letter-spacing:var(--sans-title-s-letter-spacing, 0.15px);
|
|
81
154
|
paragraph-spacing:var(--sans-title-s-paragraph-spacing, 7.7px);
|
|
82
|
-
|
|
155
|
+
}
|
|
156
|
+
.title[data-size=m]{
|
|
157
|
+
font-family:var(--sans-title-m-font-family, SB Sans Interface);
|
|
158
|
+
font-weight:var(--sans-title-m-font-weight, Semibold);
|
|
159
|
+
line-height:var(--sans-title-m-line-height, 24px);
|
|
160
|
+
font-size:var(--sans-title-m-font-size, 16px);
|
|
161
|
+
letter-spacing:var(--sans-title-m-letter-spacing, 0.15px);
|
|
162
|
+
paragraph-spacing:var(--sans-title-m-paragraph-spacing, 8.8px);
|
|
83
163
|
}
|
|
84
164
|
|
|
85
165
|
.description{
|
|
166
|
+
color:var(--sys-neutral-text-support, #6d707f);
|
|
167
|
+
word-wrap:break-word;
|
|
168
|
+
}
|
|
169
|
+
.description[data-size=s]{
|
|
170
|
+
font-family:var(--sans-body-s-font-family, SB Sans Interface);
|
|
171
|
+
font-weight:var(--sans-body-s-font-weight, Regular);
|
|
172
|
+
line-height:var(--sans-body-s-line-height, 16px);
|
|
173
|
+
font-size:var(--sans-body-s-font-size, 12px);
|
|
174
|
+
letter-spacing:var(--sans-body-s-letter-spacing, 0.1px);
|
|
175
|
+
paragraph-spacing:var(--sans-body-s-paragraph-spacing, 6.6px);
|
|
176
|
+
}
|
|
177
|
+
.description[data-size=m]{
|
|
86
178
|
font-family:var(--sans-body-m-font-family, SB Sans Interface);
|
|
87
179
|
font-weight:var(--sans-body-m-font-weight, Regular);
|
|
88
180
|
line-height:var(--sans-body-m-line-height, 20px);
|
|
89
181
|
font-size:var(--sans-body-m-font-size, 14px);
|
|
90
182
|
letter-spacing:var(--sans-body-m-letter-spacing, 0.1px);
|
|
91
183
|
paragraph-spacing:var(--sans-body-m-paragraph-spacing, 7.7px);
|
|
92
|
-
color:var(--sys-neutral-text-support, #6d707f);
|
|
93
|
-
word-wrap:break-word;
|
|
94
184
|
}
|
|
95
185
|
|
|
96
186
|
.footer{
|
|
97
|
-
gap:var(--space-alert-container-footer-gap, 16px);
|
|
98
187
|
position:relative;
|
|
99
188
|
display:flex;
|
|
100
189
|
flex-direction:row-reverse;
|
|
101
190
|
align-items:center;
|
|
102
191
|
width:100%;
|
|
192
|
+
}
|
|
193
|
+
.footer[data-size=s]{
|
|
194
|
+
gap:var(--space-alert-s-container-footer-gap, 16px);
|
|
195
|
+
}
|
|
196
|
+
.footer[data-size=m]{
|
|
197
|
+
gap:var(--space-alert-m-container-footer-gap, 16px);
|
|
103
198
|
}
|
|
@@ -19,7 +19,7 @@ export type AlertTopProps = WithSupportProps<{
|
|
|
19
19
|
/** Описание */
|
|
20
20
|
description: ReactNode;
|
|
21
21
|
/** Cсылка */
|
|
22
|
-
link?: Pick<LinkProps, 'text' | 'target' | 'onClick' | 'href' | 'appearance'>;
|
|
22
|
+
link?: Pick<LinkProps, 'text' | 'target' | 'onClick' | 'href' | 'appearance' | 'external'>;
|
|
23
23
|
/** Кнопка дополнительного действия */
|
|
24
24
|
action?: AlertButtonProps;
|
|
25
25
|
/** Колбек закрытия */
|
|
@@ -26,5 +26,5 @@ import styles from './styles.module.css';
|
|
|
26
26
|
export function AlertTop(_a) {
|
|
27
27
|
var _b;
|
|
28
28
|
var { icon = true, title, description, link, onClose, truncate, appearance = APPEARANCE.Neutral, action, className } = _a, rest = __rest(_a, ["icon", "title", "description", "link", "onClose", "truncate", "appearance", "action", "className"]);
|
|
29
|
-
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: (_b = truncate === null || truncate === void 0 ? void 0 : truncate.title) !== null && _b !== void 0 ? _b : 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, Object.assign({}, link, { appearance: APPEARANCE_TO_COLOR_MAP[appearance], textMode: 'on-accent', size: 'm', "data-test-id": 'alert-top__link' })) }))] })] }), _jsxs("div", { className: styles.actions, children: [action && _jsx(AlertButton, Object.assign({}, action, { appearance: APPEARANCE_TO_COLOR_MAP_INVERT[appearance], variant: 'tonal' })), onClose && (_jsx(AlertButton, { onClick: onClose, appearance: APPEARANCE_TO_COLOR_MAP_INVERT[appearance], icon: _jsx(CrossSVG, {}), variant: 'tonal', dataTestId: 'alert-top__close-button' }))] })] })));
|
|
29
|
+
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: (_b = truncate === null || truncate === void 0 ? void 0 : truncate.title) !== null && _b !== void 0 ? _b : 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, Object.assign({ external: true }, link, { appearance: APPEARANCE_TO_COLOR_MAP[appearance], textMode: 'on-accent', size: 'm', "data-test-id": 'alert-top__link' })) }))] })] }), _jsxs("div", { className: styles.actions, children: [action && _jsx(AlertButton, Object.assign({}, action, { appearance: APPEARANCE_TO_COLOR_MAP_INVERT[appearance], variant: 'tonal' })), onClose && (_jsx(AlertButton, { onClick: onClose, appearance: APPEARANCE_TO_COLOR_MAP_INVERT[appearance], icon: _jsx(CrossSVG, {}), variant: 'tonal', dataTestId: 'alert-top__close-button' }))] })] })));
|
|
30
30
|
}
|
|
@@ -5,6 +5,7 @@ const COLOR = {
|
|
|
5
5
|
Red: 'red',
|
|
6
6
|
Yellow: 'yellow',
|
|
7
7
|
Green: 'green',
|
|
8
|
+
Blue: 'blue',
|
|
8
9
|
};
|
|
9
10
|
export const APPEARANCE_TO_COLOR_MAP_INVERT = {
|
|
10
11
|
[APPEARANCE.Neutral]: COLOR.InvertNeutral,
|
|
@@ -12,4 +13,5 @@ export const APPEARANCE_TO_COLOR_MAP_INVERT = {
|
|
|
12
13
|
[APPEARANCE.Error]: COLOR.Red,
|
|
13
14
|
[APPEARANCE.Warning]: COLOR.Yellow,
|
|
14
15
|
[APPEARANCE.Success]: COLOR.Green,
|
|
16
|
+
[APPEARANCE.Info]: COLOR.Blue,
|
|
15
17
|
};
|
|
@@ -23,6 +23,9 @@
|
|
|
23
23
|
.alertTop[data-color=green]{
|
|
24
24
|
background-color:var(--sys-green-accent-default, #57b762);
|
|
25
25
|
}
|
|
26
|
+
.alertTop[data-color=blue]{
|
|
27
|
+
background-color:var(--sys-blue-accent-default, #5388d1);
|
|
28
|
+
}
|
|
26
29
|
|
|
27
30
|
.icon{
|
|
28
31
|
display:flex;
|
|
@@ -44,6 +47,9 @@
|
|
|
44
47
|
.icon[data-color=green]{
|
|
45
48
|
color:var(--sys-green-on-accent, #fcfefa);
|
|
46
49
|
}
|
|
50
|
+
.icon[data-color=blue]{
|
|
51
|
+
color:var(--sys-blue-on-accent, #fdfeff);
|
|
52
|
+
}
|
|
47
53
|
.icon svg{
|
|
48
54
|
width:var(--size-icon-container-s, 24px) !important;
|
|
49
55
|
height:var(--size-icon-container-s, 24px) !important;
|
|
@@ -72,6 +78,9 @@
|
|
|
72
78
|
.title[data-color=green]{
|
|
73
79
|
color:var(--sys-green-on-accent, #fcfefa);
|
|
74
80
|
}
|
|
81
|
+
.title[data-color=blue]{
|
|
82
|
+
color:var(--sys-blue-on-accent, #fdfeff);
|
|
83
|
+
}
|
|
75
84
|
|
|
76
85
|
.description{
|
|
77
86
|
font-family:var(--sans-body-m-font-family, SB Sans Interface);
|
|
@@ -97,6 +106,9 @@
|
|
|
97
106
|
.description[data-color=green]{
|
|
98
107
|
color:var(--sys-green-on-accent, #fcfefa);
|
|
99
108
|
}
|
|
109
|
+
.description[data-color=blue]{
|
|
110
|
+
color:var(--sys-blue-on-accent, #fdfeff);
|
|
111
|
+
}
|
|
100
112
|
|
|
101
113
|
.contentWrapper{
|
|
102
114
|
display:flex;
|
package/dist/constants.d.ts
CHANGED
|
@@ -6,5 +6,10 @@ export declare const APPEARANCE: {
|
|
|
6
6
|
readonly Error: "error";
|
|
7
7
|
readonly Warning: "warning";
|
|
8
8
|
readonly Success: "success";
|
|
9
|
+
readonly Info: "info";
|
|
10
|
+
};
|
|
11
|
+
export declare const SIZE: {
|
|
12
|
+
readonly S: "s";
|
|
13
|
+
readonly M: "m";
|
|
9
14
|
};
|
|
10
15
|
export declare const APPEARANCE_TO_COLOR_MAP: Record<ValueOf<typeof APPEARANCE>, LinkProps['appearance']>;
|
package/dist/constants.js
CHANGED
|
@@ -4,6 +4,11 @@ export const APPEARANCE = {
|
|
|
4
4
|
Error: 'error',
|
|
5
5
|
Warning: 'warning',
|
|
6
6
|
Success: 'success',
|
|
7
|
+
Info: 'info',
|
|
8
|
+
};
|
|
9
|
+
export const SIZE = {
|
|
10
|
+
S: 's',
|
|
11
|
+
M: 'm',
|
|
7
12
|
};
|
|
8
13
|
export const APPEARANCE_TO_COLOR_MAP = {
|
|
9
14
|
[APPEARANCE.Neutral]: 'neutral',
|
|
@@ -11,4 +16,5 @@ export const APPEARANCE_TO_COLOR_MAP = {
|
|
|
11
16
|
[APPEARANCE.Error]: 'red',
|
|
12
17
|
[APPEARANCE.Warning]: 'yellow',
|
|
13
18
|
[APPEARANCE.Success]: 'green',
|
|
19
|
+
[APPEARANCE.Info]: 'blue',
|
|
14
20
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { MouseEvent, ReactElement } from 'react';
|
|
2
2
|
import { LinkProps } from '@snack-uikit/link';
|
|
3
|
+
import { Size } from '../types';
|
|
3
4
|
type PrivateAlertButtonProps = {
|
|
4
5
|
/** Внешний вид */
|
|
5
6
|
appearance?: LinkProps['appearance'] | 'invert-neutral';
|
|
@@ -13,7 +14,11 @@ type PrivateAlertButtonProps = {
|
|
|
13
14
|
onClick?(e: MouseEvent<HTMLButtonElement>): void;
|
|
14
15
|
/** Дата тест айди */
|
|
15
16
|
dataTestId?: string;
|
|
17
|
+
/** Управление состоянием загрузки */
|
|
18
|
+
loading?: boolean;
|
|
19
|
+
/** Размер */
|
|
20
|
+
size?: Size;
|
|
16
21
|
};
|
|
17
22
|
export type AlertButtonProps = Omit<PrivateAlertButtonProps, 'appearance' | 'variant'>;
|
|
18
|
-
export declare function AlertButton({ appearance, text, icon, onClick, variant, dataTestId, }: PrivateAlertButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export declare function AlertButton({ appearance, text, icon, onClick, variant, dataTestId, loading, size, }: PrivateAlertButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
19
24
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Sun } from '@snack-uikit/loaders';
|
|
2
3
|
import styles from './styles.module.css';
|
|
3
|
-
export function AlertButton({ appearance, text, icon, onClick, variant = 'simple', dataTestId, }) {
|
|
4
|
-
return (_jsxs("button", { type: 'button', onClick: onClick, className: styles.alertButton, "data-variant": variant, "data-appearance": appearance, "data-test-id": dataTestId || 'alert__action-button', "data-icon-only": !text || undefined, children: [text && _jsx("span", { className: styles.text, children: text }), icon && _jsx("span", { className: styles.icon, children: icon })] }));
|
|
4
|
+
export function AlertButton({ appearance, text, icon, onClick, variant = 'simple', dataTestId, loading = false, size = 's', }) {
|
|
5
|
+
return (_jsxs("button", { type: 'button', onClick: onClick, className: styles.alertButton, "data-variant": variant, "data-appearance": appearance, "data-test-id": dataTestId || 'alert__action-button', "data-icon-only": !text || undefined, "data-loading": loading, "data-size": size, children: [text && (_jsx("span", { className: styles.text, "data-size": size, children: text })), icon && (loading ? _jsx(Sun, { size: 's' }) : _jsx("span", { className: styles.icon, children: icon }))] }));
|
|
5
6
|
}
|
|
@@ -10,7 +10,15 @@
|
|
|
10
10
|
background:none;
|
|
11
11
|
border:0;
|
|
12
12
|
}
|
|
13
|
-
.alertButton .text{
|
|
13
|
+
.alertButton .text[data-size=s]{
|
|
14
|
+
font-family:var(--sans-label-m-font-family, SB Sans Interface);
|
|
15
|
+
font-weight:var(--sans-label-m-font-weight, Semibold);
|
|
16
|
+
line-height:var(--sans-label-m-line-height, 16px);
|
|
17
|
+
font-size:var(--sans-label-m-font-size, 12px);
|
|
18
|
+
letter-spacing:var(--sans-label-m-letter-spacing, 0px);
|
|
19
|
+
paragraph-spacing:var(--sans-label-m-paragraph-spacing, 6.6px);
|
|
20
|
+
}
|
|
21
|
+
.alertButton .text[data-size=m]{
|
|
14
22
|
font-family:var(--sans-label-l-font-family, SB Sans Interface);
|
|
15
23
|
font-weight:var(--sans-label-l-font-weight, Semibold);
|
|
16
24
|
line-height:var(--sans-label-l-line-height, 20px);
|
|
@@ -29,21 +37,34 @@
|
|
|
29
37
|
max-width:var(--size-icon-container-s, 24px);
|
|
30
38
|
max-height:var(--size-icon-container-s, 24px);
|
|
31
39
|
}
|
|
40
|
+
.alertButton[data-loading=true]{
|
|
41
|
+
cursor:not-allowed;
|
|
42
|
+
}
|
|
43
|
+
.alertButton[data-loading=true] > *{
|
|
44
|
+
cursor:not-allowed;
|
|
45
|
+
}
|
|
32
46
|
|
|
33
|
-
.alertButton[data-variant=simple]{
|
|
34
|
-
height:var(--size-alert-button, 24px);
|
|
35
|
-
gap:var(--space-alert-button-gap, 4px);
|
|
47
|
+
.alertButton[data-variant=simple][data-size=s]{
|
|
48
|
+
height:var(--size-alert-button-m, 24px);
|
|
49
|
+
gap:var(--space-alert-m-button-gap, 4px);
|
|
36
50
|
border-radius:var(--radius-alert-button, 8px);
|
|
37
51
|
}
|
|
38
|
-
.alertButton[data-variant=simple][data-icon-only]{
|
|
39
|
-
height:var(--size-alert-button,
|
|
40
|
-
width:var(--size-alert-button,
|
|
52
|
+
.alertButton[data-variant=simple][data-size=s][data-icon-only]{
|
|
53
|
+
height:var(--size-alert-button-s, 16px);
|
|
54
|
+
width:var(--size-alert-button-s, 16px);
|
|
55
|
+
border-radius:var(--radius-alert-button, 8px);
|
|
56
|
+
}
|
|
57
|
+
.alertButton[data-variant=simple][data-size=m]{
|
|
58
|
+
height:var(--size-alert-button-m, 24px);
|
|
59
|
+
gap:var(--space-alert-m-button-gap, 4px);
|
|
60
|
+
border-radius:var(--radius-alert-button, 8px);
|
|
61
|
+
}
|
|
62
|
+
.alertButton[data-variant=simple][data-size=m][data-icon-only]{
|
|
63
|
+
height:var(--size-alert-button-m, 24px);
|
|
64
|
+
width:var(--size-alert-button-m, 24px);
|
|
41
65
|
border-radius:var(--radius-alert-button, 8px);
|
|
42
66
|
}
|
|
43
67
|
.alertButton[data-variant=simple]:focus-visible{
|
|
44
|
-
outline-width:var(--border-state-focus-s-border-width, 2px);
|
|
45
|
-
outline-style:var(--border-state-focus-s-border-style, solid);
|
|
46
|
-
outline-color:var(--border-state-focus-s-border-color, );
|
|
47
68
|
outline-color:var(--sys-available-complementary, #15151b);
|
|
48
69
|
outline-offset:var(--spacing-state-focus-offset, 2px);
|
|
49
70
|
}
|
|
@@ -51,7 +72,7 @@
|
|
|
51
72
|
color:var(--sys-neutral-text-support, #6d707f);
|
|
52
73
|
}
|
|
53
74
|
.alertButton[data-variant=simple][data-appearance=neutral]:hover, .alertButton[data-variant=simple][data-appearance=neutral]:focus-visible{
|
|
54
|
-
color:var(--sys-neutral-text-
|
|
75
|
+
color:var(--sys-neutral-text-main, #33343f);
|
|
55
76
|
}
|
|
56
77
|
.alertButton[data-variant=simple][data-appearance=neutral]:active{
|
|
57
78
|
color:var(--sys-neutral-text-main, #33343f);
|
|
@@ -60,7 +81,7 @@
|
|
|
60
81
|
color:var(--sys-primary-text-support, #5b4796);
|
|
61
82
|
}
|
|
62
83
|
.alertButton[data-variant=simple][data-appearance=primary]:hover, .alertButton[data-variant=simple][data-appearance=primary]:focus-visible{
|
|
63
|
-
color:var(--sys-primary-text-
|
|
84
|
+
color:var(--sys-primary-text-main, #382a62);
|
|
64
85
|
}
|
|
65
86
|
.alertButton[data-variant=simple][data-appearance=primary]:active{
|
|
66
87
|
color:var(--sys-primary-text-main, #382a62);
|
|
@@ -69,7 +90,7 @@
|
|
|
69
90
|
color:var(--sys-red-text-support, #a63d3a);
|
|
70
91
|
}
|
|
71
92
|
.alertButton[data-variant=simple][data-appearance=red]:hover, .alertButton[data-variant=simple][data-appearance=red]:focus-visible{
|
|
72
|
-
color:var(--sys-red-text-
|
|
93
|
+
color:var(--sys-red-text-main, #621c1b);
|
|
73
94
|
}
|
|
74
95
|
.alertButton[data-variant=simple][data-appearance=red]:active{
|
|
75
96
|
color:var(--sys-red-text-main, #621c1b);
|
|
@@ -78,7 +99,7 @@
|
|
|
78
99
|
color:var(--sys-yellow-text-support, #a77a10);
|
|
79
100
|
}
|
|
80
101
|
.alertButton[data-variant=simple][data-appearance=yellow]:hover, .alertButton[data-variant=simple][data-appearance=yellow]:focus-visible{
|
|
81
|
-
color:var(--sys-yellow-text-
|
|
102
|
+
color:var(--sys-yellow-text-main, #5e3d06);
|
|
82
103
|
}
|
|
83
104
|
.alertButton[data-variant=simple][data-appearance=yellow]:active{
|
|
84
105
|
color:var(--sys-yellow-text-main, #5e3d06);
|
|
@@ -87,11 +108,20 @@
|
|
|
87
108
|
color:var(--sys-green-text-support, #568a56);
|
|
88
109
|
}
|
|
89
110
|
.alertButton[data-variant=simple][data-appearance=green]:hover, .alertButton[data-variant=simple][data-appearance=green]:focus-visible{
|
|
90
|
-
color:var(--sys-green-text-
|
|
111
|
+
color:var(--sys-green-text-main, #323f27);
|
|
91
112
|
}
|
|
92
113
|
.alertButton[data-variant=simple][data-appearance=green]:active{
|
|
93
114
|
color:var(--sys-green-text-main, #323f27);
|
|
94
115
|
}
|
|
116
|
+
.alertButton[data-variant=simple][data-appearance=blue]{
|
|
117
|
+
color:var(--sys-blue-text-support, #4975a9);
|
|
118
|
+
}
|
|
119
|
+
.alertButton[data-variant=simple][data-appearance=blue]:hover, .alertButton[data-variant=simple][data-appearance=blue]:focus-visible{
|
|
120
|
+
color:var(--sys-blue-text-main, #153a61);
|
|
121
|
+
}
|
|
122
|
+
.alertButton[data-variant=simple][data-appearance=blue]:active{
|
|
123
|
+
color:var(--sys-blue-text-main, #153a61);
|
|
124
|
+
}
|
|
95
125
|
|
|
96
126
|
.alertButton[data-variant=tonal]{
|
|
97
127
|
height:var(--size-alert-top-button, 32px);
|
|
@@ -135,4 +165,7 @@
|
|
|
135
165
|
}
|
|
136
166
|
.alertButton[data-variant=tonal][data-appearance=green]{
|
|
137
167
|
color:var(--sys-green-on-accent, #fcfefa);
|
|
168
|
+
}
|
|
169
|
+
.alertButton[data-variant=tonal][data-appearance=blue]{
|
|
170
|
+
color:var(--sys-blue-on-accent, #fdfeff);
|
|
138
171
|
}
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Alert",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.12.0",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -32,11 +32,12 @@
|
|
|
32
32
|
"license": "Apache-2.0",
|
|
33
33
|
"scripts": {},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@snack-uikit/icons": "0.
|
|
36
|
-
"@snack-uikit/link": "0.12.4
|
|
37
|
-
"@snack-uikit/
|
|
35
|
+
"@snack-uikit/icons": "0.22.0",
|
|
36
|
+
"@snack-uikit/link": "0.12.4",
|
|
37
|
+
"@snack-uikit/loaders": "0.5.2",
|
|
38
|
+
"@snack-uikit/truncate-string": "0.4.20",
|
|
38
39
|
"@snack-uikit/utils": "3.3.0",
|
|
39
40
|
"classnames": "2.3.2"
|
|
40
41
|
},
|
|
41
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "e1962e152dbb02534dc447d16bf67ad0f4e19e9d"
|
|
42
43
|
}
|
|
@@ -8,7 +8,7 @@ import { extractSupportProps, WithSupportProps } from '@snack-uikit/utils';
|
|
|
8
8
|
|
|
9
9
|
import { APPEARANCE, APPEARANCE_TO_COLOR_MAP } from '../../constants';
|
|
10
10
|
import { AlertButton, AlertButtonProps } from '../../helperComponents';
|
|
11
|
-
import { Appearance } from '../../types';
|
|
11
|
+
import { Appearance, Size } from '../../types';
|
|
12
12
|
import { getIcon } from '../../utils';
|
|
13
13
|
import styles from './styles.module.scss';
|
|
14
14
|
|
|
@@ -28,11 +28,15 @@ export type AlertProps = WithSupportProps<{
|
|
|
28
28
|
/** Описание */
|
|
29
29
|
description: ReactNode;
|
|
30
30
|
/** Cсылка */
|
|
31
|
-
link?: Pick<LinkProps, 'text' | 'target' | 'onClick' | 'href' | 'appearance'>;
|
|
31
|
+
link?: Pick<LinkProps, 'text' | 'target' | 'onClick' | 'href' | 'appearance' | 'external'>;
|
|
32
32
|
/** Колбек закрытия */
|
|
33
33
|
onClose?: () => void;
|
|
34
34
|
/** Внешний вид */
|
|
35
35
|
appearance?: Appearance;
|
|
36
|
+
/** Внешний бордер */
|
|
37
|
+
outline?: boolean;
|
|
38
|
+
/** Размер */
|
|
39
|
+
size?: Size;
|
|
36
40
|
/** CSS-класс */
|
|
37
41
|
className?: string;
|
|
38
42
|
/** Кнопки в футере алерта */
|
|
@@ -55,17 +59,31 @@ export function Alert({
|
|
|
55
59
|
appearance = APPEARANCE.Neutral,
|
|
56
60
|
className,
|
|
57
61
|
actions,
|
|
62
|
+
outline,
|
|
63
|
+
size = 'm',
|
|
58
64
|
...rest
|
|
59
65
|
}: AlertProps) {
|
|
60
66
|
return (
|
|
61
67
|
<div
|
|
62
|
-
className={cn(
|
|
68
|
+
className={cn(
|
|
69
|
+
styles.alert,
|
|
70
|
+
{
|
|
71
|
+
[styles.alertOutline]: outline,
|
|
72
|
+
},
|
|
73
|
+
className,
|
|
74
|
+
)}
|
|
63
75
|
{...extractSupportProps(rest)}
|
|
64
76
|
data-color={APPEARANCE_TO_COLOR_MAP[appearance]}
|
|
77
|
+
data-size={size}
|
|
65
78
|
>
|
|
66
|
-
<div className={styles.body}>
|
|
79
|
+
<div className={styles.body} data-size={size}>
|
|
67
80
|
{icon && (
|
|
68
|
-
<div
|
|
81
|
+
<div
|
|
82
|
+
className={styles.icon}
|
|
83
|
+
data-color={APPEARANCE_TO_COLOR_MAP[appearance]}
|
|
84
|
+
data-test-id='alert__icon'
|
|
85
|
+
data-size={size}
|
|
86
|
+
>
|
|
69
87
|
{getIcon(appearance)}
|
|
70
88
|
</div>
|
|
71
89
|
)}
|
|
@@ -77,20 +95,22 @@ export function Alert({
|
|
|
77
95
|
maxLines={truncate?.title ?? 1}
|
|
78
96
|
className={styles.title}
|
|
79
97
|
data-test-id='alert__title'
|
|
98
|
+
data-size={size}
|
|
80
99
|
/>
|
|
81
100
|
)}
|
|
82
101
|
|
|
83
|
-
<span data-test-id='alert__description' className={styles.description}>
|
|
102
|
+
<span data-test-id='alert__description' className={styles.description} data-size={size}>
|
|
84
103
|
{description}
|
|
85
104
|
</span>
|
|
86
105
|
|
|
87
106
|
{link && (
|
|
88
107
|
<span>
|
|
89
108
|
<Link
|
|
109
|
+
external
|
|
90
110
|
{...link}
|
|
91
111
|
appearance={APPEARANCE_TO_COLOR_MAP[appearance]}
|
|
92
112
|
textMode='default'
|
|
93
|
-
size=
|
|
113
|
+
size={size}
|
|
94
114
|
data-test-id='alert__link'
|
|
95
115
|
/>
|
|
96
116
|
</span>
|
|
@@ -109,12 +129,22 @@ export function Alert({
|
|
|
109
129
|
</div>
|
|
110
130
|
|
|
111
131
|
{actions && (
|
|
112
|
-
<div className={styles.footer}>
|
|
132
|
+
<div className={styles.footer} data-size={size}>
|
|
113
133
|
{actions.primary && (
|
|
114
|
-
<AlertButton
|
|
134
|
+
<AlertButton
|
|
135
|
+
{...actions.primary}
|
|
136
|
+
appearance={APPEARANCE_TO_COLOR_MAP[appearance]}
|
|
137
|
+
variant='simple'
|
|
138
|
+
size={size}
|
|
139
|
+
/>
|
|
115
140
|
)}
|
|
116
141
|
{actions?.secondary && (
|
|
117
|
-
<AlertButton
|
|
142
|
+
<AlertButton
|
|
143
|
+
{...actions.secondary}
|
|
144
|
+
appearance={APPEARANCE_TO_COLOR_MAP[appearance]}
|
|
145
|
+
variant='simple'
|
|
146
|
+
size={size}
|
|
147
|
+
/>
|
|
118
148
|
)}
|
|
119
149
|
</div>
|
|
120
150
|
)}
|
|
@@ -1,33 +1,55 @@
|
|
|
1
1
|
@import '@snack-uikit/figma-tokens/build/scss/components/styles-tokens-alert';
|
|
2
2
|
@import '@snack-uikit/figma-tokens/build/scss/components/styles-tokens-element';
|
|
3
3
|
|
|
4
|
-
$colors: 'neutral', 'primary', 'red', 'yellow', 'green';
|
|
4
|
+
$colors: 'neutral', 'primary', 'red', 'yellow', 'green', 'blue';
|
|
5
|
+
$sizes: 's', 'm';
|
|
6
|
+
$icons: ('s': 'xs', 'm': 's');
|
|
5
7
|
|
|
6
8
|
.alert {
|
|
7
|
-
@include composite-var($alert-container-container);
|
|
8
|
-
|
|
9
9
|
display: flex;
|
|
10
10
|
flex-direction: column;
|
|
11
|
-
|
|
12
11
|
box-sizing: border-box;
|
|
13
12
|
min-width: 256px;
|
|
14
13
|
|
|
15
|
-
border-style: solid;
|
|
16
|
-
|
|
17
14
|
@each $color in $colors {
|
|
18
15
|
&[data-color='#{$color}'] {
|
|
19
16
|
background-color: simple-var($theme-variables, 'sys', $color, 'background');
|
|
20
|
-
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@each $size in $sizes {
|
|
21
|
+
&[data-size='#{$size}'] {
|
|
22
|
+
@include composite-var($alert, $size, 'container');
|
|
21
23
|
}
|
|
22
24
|
}
|
|
23
25
|
}
|
|
24
26
|
|
|
25
|
-
.
|
|
26
|
-
|
|
27
|
+
.alertOutline {
|
|
28
|
+
outline-style: solid;
|
|
29
|
+
outline-width: $border-width-accordion-collapse-block-primary;
|
|
30
|
+
|
|
31
|
+
@each $color in $colors {
|
|
32
|
+
&[data-color='#{$color}'] {
|
|
33
|
+
outline-color: simple-var($theme-variables, 'sys', $color, 'decor-default');
|
|
27
34
|
|
|
35
|
+
&:focus-within,
|
|
36
|
+
&:hover {
|
|
37
|
+
outline-color: simple-var($theme-variables, 'sys', $color, 'decor-default');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.body {
|
|
28
44
|
display: flex;
|
|
29
45
|
box-sizing: border-box;
|
|
30
46
|
width: 100%;
|
|
47
|
+
|
|
48
|
+
@each $size in $sizes {
|
|
49
|
+
&[data-size='#{$size}'] {
|
|
50
|
+
@include composite-var($alert, $size, 'body');
|
|
51
|
+
}
|
|
52
|
+
}
|
|
31
53
|
}
|
|
32
54
|
|
|
33
55
|
.icon {
|
|
@@ -37,40 +59,56 @@ $colors: 'neutral', 'primary', 'red', 'yellow', 'green';
|
|
|
37
59
|
}
|
|
38
60
|
}
|
|
39
61
|
|
|
40
|
-
|
|
41
|
-
|
|
62
|
+
@each $name, $glyph in $icons {
|
|
63
|
+
&[data-size='#{$name}'] {
|
|
64
|
+
width: simple-var($icon, $glyph);
|
|
65
|
+
height: simple-var($icon, $glyph);
|
|
42
66
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
67
|
+
svg {
|
|
68
|
+
max-width: simple-var($icon, $glyph);
|
|
69
|
+
max-height: simple-var($icon, $glyph);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
46
72
|
}
|
|
73
|
+
|
|
74
|
+
|
|
47
75
|
}
|
|
48
76
|
|
|
49
77
|
.contentLayout {
|
|
50
|
-
@include composite-var($alert-container-content-layout);
|
|
51
|
-
|
|
52
78
|
display: flex;
|
|
53
79
|
flex: 1;
|
|
54
80
|
flex-direction: column;
|
|
55
81
|
min-width: 0;
|
|
82
|
+
|
|
83
|
+
@each $size in $sizes {
|
|
84
|
+
&[data-size='#{$size}'] {
|
|
85
|
+
@include composite-var($alert, $size, 'content-layout');
|
|
86
|
+
}
|
|
87
|
+
}
|
|
56
88
|
}
|
|
57
89
|
|
|
58
90
|
.title {
|
|
59
|
-
@include composite-var($sans-title-s);
|
|
60
|
-
|
|
61
91
|
color: $sys-neutral-text-main;
|
|
92
|
+
|
|
93
|
+
@each $size in $sizes {
|
|
94
|
+
&[data-size='#{$size}'] {
|
|
95
|
+
@include composite-var($theme-variables, 'sans', 'title', $size)
|
|
96
|
+
}
|
|
97
|
+
}
|
|
62
98
|
}
|
|
63
99
|
|
|
64
100
|
.description {
|
|
65
|
-
@include composite-var($sans-body-m);
|
|
66
|
-
|
|
67
101
|
color: $sys-neutral-text-support;
|
|
68
102
|
word-wrap: break-word;
|
|
103
|
+
|
|
104
|
+
@each $size in $sizes {
|
|
105
|
+
&[data-size='#{$size}'] {
|
|
106
|
+
@include composite-var($theme-variables, 'sans', 'body', $size)
|
|
107
|
+
}
|
|
108
|
+
}
|
|
69
109
|
}
|
|
70
110
|
|
|
71
111
|
.footer {
|
|
72
|
-
@include composite-var($alert-container-footer);
|
|
73
|
-
|
|
74
112
|
position: relative;
|
|
75
113
|
|
|
76
114
|
display: flex;
|
|
@@ -78,4 +116,10 @@ $colors: 'neutral', 'primary', 'red', 'yellow', 'green';
|
|
|
78
116
|
align-items: center;
|
|
79
117
|
|
|
80
118
|
width: 100%;
|
|
119
|
+
|
|
120
|
+
@each $size in $sizes {
|
|
121
|
+
&[data-size='#{$size}'] {
|
|
122
|
+
@include composite-var($alert, $size, 'footer');
|
|
123
|
+
}
|
|
124
|
+
}
|
|
81
125
|
}
|
|
@@ -29,7 +29,7 @@ export type AlertTopProps = WithSupportProps<{
|
|
|
29
29
|
/** Описание */
|
|
30
30
|
description: ReactNode;
|
|
31
31
|
/** Cсылка */
|
|
32
|
-
link?: Pick<LinkProps, 'text' | 'target' | 'onClick' | 'href' | 'appearance'>;
|
|
32
|
+
link?: Pick<LinkProps, 'text' | 'target' | 'onClick' | 'href' | 'appearance' | 'external'>;
|
|
33
33
|
/** Кнопка дополнительного действия */
|
|
34
34
|
action?: AlertButtonProps;
|
|
35
35
|
/** Колбек закрытия */
|
|
@@ -96,6 +96,7 @@ export function AlertTop({
|
|
|
96
96
|
{link && (
|
|
97
97
|
<span>
|
|
98
98
|
<Link
|
|
99
|
+
external
|
|
99
100
|
{...link}
|
|
100
101
|
appearance={APPEARANCE_TO_COLOR_MAP[appearance]}
|
|
101
102
|
textMode='on-accent'
|
|
@@ -6,6 +6,7 @@ const COLOR = {
|
|
|
6
6
|
Red: 'red',
|
|
7
7
|
Yellow: 'yellow',
|
|
8
8
|
Green: 'green',
|
|
9
|
+
Blue: 'blue',
|
|
9
10
|
} as const;
|
|
10
11
|
|
|
11
12
|
export const APPEARANCE_TO_COLOR_MAP_INVERT = {
|
|
@@ -14,4 +15,5 @@ export const APPEARANCE_TO_COLOR_MAP_INVERT = {
|
|
|
14
15
|
[APPEARANCE.Error]: COLOR.Red,
|
|
15
16
|
[APPEARANCE.Warning]: COLOR.Yellow,
|
|
16
17
|
[APPEARANCE.Success]: COLOR.Green,
|
|
18
|
+
[APPEARANCE.Info]: COLOR.Blue,
|
|
17
19
|
} as const;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
@import '@snack-uikit/figma-tokens/build/scss/components/styles-tokens-alert-alertTop';
|
|
2
2
|
@import '@snack-uikit/figma-tokens/build/scss/components/styles-tokens-element';
|
|
3
3
|
|
|
4
|
-
$colors: 'invert-neutral', 'primary', 'red', 'yellow', 'green';
|
|
4
|
+
$colors: 'invert-neutral', 'primary', 'red', 'yellow', 'green', 'blue';
|
|
5
5
|
|
|
6
6
|
.alertTop {
|
|
7
7
|
@include composite-var($alert-top-container-container);
|
package/src/constants.ts
CHANGED
|
@@ -7,6 +7,12 @@ export const APPEARANCE = {
|
|
|
7
7
|
Error: 'error',
|
|
8
8
|
Warning: 'warning',
|
|
9
9
|
Success: 'success',
|
|
10
|
+
Info: 'info',
|
|
11
|
+
} as const;
|
|
12
|
+
|
|
13
|
+
export const SIZE = {
|
|
14
|
+
S: 's',
|
|
15
|
+
M: 'm',
|
|
10
16
|
} as const;
|
|
11
17
|
|
|
12
18
|
export const APPEARANCE_TO_COLOR_MAP: Record<ValueOf<typeof APPEARANCE>, LinkProps['appearance']> = {
|
|
@@ -15,4 +21,5 @@ export const APPEARANCE_TO_COLOR_MAP: Record<ValueOf<typeof APPEARANCE>, LinkPro
|
|
|
15
21
|
[APPEARANCE.Error]: 'red',
|
|
16
22
|
[APPEARANCE.Warning]: 'yellow',
|
|
17
23
|
[APPEARANCE.Success]: 'green',
|
|
24
|
+
[APPEARANCE.Info]: 'blue',
|
|
18
25
|
} as const;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { MouseEvent, ReactElement } from 'react';
|
|
2
2
|
|
|
3
3
|
import { LinkProps } from '@snack-uikit/link';
|
|
4
|
+
import { Sun } from '@snack-uikit/loaders';
|
|
4
5
|
|
|
6
|
+
import { Size } from '../types';
|
|
5
7
|
import styles from './styles.module.scss';
|
|
6
8
|
|
|
7
9
|
type PrivateAlertButtonProps = {
|
|
@@ -17,6 +19,10 @@ type PrivateAlertButtonProps = {
|
|
|
17
19
|
onClick?(e: MouseEvent<HTMLButtonElement>): void;
|
|
18
20
|
/** Дата тест айди */
|
|
19
21
|
dataTestId?: string;
|
|
22
|
+
/** Управление состоянием загрузки */
|
|
23
|
+
loading?: boolean;
|
|
24
|
+
/** Размер */
|
|
25
|
+
size?: Size;
|
|
20
26
|
};
|
|
21
27
|
|
|
22
28
|
export type AlertButtonProps = Omit<PrivateAlertButtonProps, 'appearance' | 'variant'>;
|
|
@@ -28,6 +34,8 @@ export function AlertButton({
|
|
|
28
34
|
onClick,
|
|
29
35
|
variant = 'simple',
|
|
30
36
|
dataTestId,
|
|
37
|
+
loading = false,
|
|
38
|
+
size = 's',
|
|
31
39
|
}: PrivateAlertButtonProps) {
|
|
32
40
|
return (
|
|
33
41
|
<button
|
|
@@ -38,9 +46,15 @@ export function AlertButton({
|
|
|
38
46
|
data-appearance={appearance}
|
|
39
47
|
data-test-id={dataTestId || 'alert__action-button'}
|
|
40
48
|
data-icon-only={!text || undefined}
|
|
49
|
+
data-loading={loading}
|
|
50
|
+
data-size={size}
|
|
41
51
|
>
|
|
42
|
-
{text &&
|
|
43
|
-
|
|
52
|
+
{text && (
|
|
53
|
+
<span className={styles.text} data-size={size}>
|
|
54
|
+
{text}
|
|
55
|
+
</span>
|
|
56
|
+
)}
|
|
57
|
+
{icon && (loading ? <Sun size='s' /> : <span className={styles.icon}>{icon}</span>)}
|
|
44
58
|
</button>
|
|
45
59
|
);
|
|
46
60
|
}
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
@import '@snack-uikit/figma-tokens/build/scss/components/styles-tokens-alert-alertTop';
|
|
3
3
|
@import '@snack-uikit/figma-tokens/build/scss/components/styles-tokens-element';
|
|
4
4
|
|
|
5
|
-
$simpleAppearances: 'neutral', 'primary', 'red', 'yellow', 'green';
|
|
6
|
-
$tonalAppearances: 'invert-neutral', 'primary', 'red', 'yellow', 'green';
|
|
5
|
+
$simpleAppearances: 'neutral', 'primary', 'red', 'yellow', 'green', 'blue';
|
|
6
|
+
$tonalAppearances: 'invert-neutral', 'primary', 'red', 'yellow', 'green', 'blue';
|
|
7
|
+
$sizes: 's', 'm';
|
|
8
|
+
$text: ('s': 'm', 'm': 'l');
|
|
7
9
|
|
|
8
10
|
.alertButton {
|
|
9
11
|
cursor: pointer;
|
|
@@ -22,7 +24,11 @@ $tonalAppearances: 'invert-neutral', 'primary', 'red', 'yellow', 'green';
|
|
|
22
24
|
border: 0;
|
|
23
25
|
|
|
24
26
|
.text {
|
|
25
|
-
@
|
|
27
|
+
@each $name, $glyph in $text {
|
|
28
|
+
&[data-size='#{$name}'] {
|
|
29
|
+
@include composite-var($theme-variables, 'sans', 'label', $glyph)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
26
32
|
}
|
|
27
33
|
|
|
28
34
|
.icon {
|
|
@@ -38,18 +44,28 @@ $tonalAppearances: 'invert-neutral', 'primary', 'red', 'yellow', 'green';
|
|
|
38
44
|
max-height: $icon-s;
|
|
39
45
|
}
|
|
40
46
|
}
|
|
47
|
+
|
|
48
|
+
&[data-loading='true'] {
|
|
49
|
+
cursor: not-allowed;
|
|
50
|
+
> * {
|
|
51
|
+
cursor: not-allowed;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
41
54
|
}
|
|
42
55
|
|
|
43
56
|
.alertButton[data-variant='simple'] {
|
|
44
|
-
@
|
|
57
|
+
@each $size in $sizes {
|
|
58
|
+
&[data-size='#{$size}'] {
|
|
59
|
+
@include composite-var($alert, $size, 'button', 'button-action');
|
|
45
60
|
|
|
46
|
-
|
|
47
|
-
|
|
61
|
+
&[data-icon-only] {
|
|
62
|
+
@include composite-var($alert, $size, 'button', 'button-close');
|
|
63
|
+
|
|
64
|
+
}
|
|
65
|
+
}
|
|
48
66
|
}
|
|
49
67
|
|
|
50
68
|
&:focus-visible {
|
|
51
|
-
@include outline-var($container-focused-s);
|
|
52
|
-
|
|
53
69
|
outline-color: $sys-available-complementary;
|
|
54
70
|
outline-offset: $spacing-state-focus-offset;
|
|
55
71
|
}
|
|
@@ -60,7 +76,7 @@ $tonalAppearances: 'invert-neutral', 'primary', 'red', 'yellow', 'green';
|
|
|
60
76
|
|
|
61
77
|
&:hover,
|
|
62
78
|
&:focus-visible {
|
|
63
|
-
color: simple-var($theme-variables, 'sys', $appearance, 'text-
|
|
79
|
+
color: simple-var($theme-variables, 'sys', $appearance, 'text-main');
|
|
64
80
|
}
|
|
65
81
|
|
|
66
82
|
&:active {
|
package/src/types.ts
CHANGED