@snack-uikit/alert 0.8.8-preview-1fcf96b1.0 → 0.9.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 +21 -0
- package/README.md +18 -18
- package/dist/components/Alert/Alert.d.ts +9 -7
- package/dist/components/Alert/Alert.js +2 -2
- package/dist/components/Alert/styles.module.css +6 -102
- package/dist/components/AlertTop/AlertTop.d.ts +7 -12
- package/dist/components/AlertTop/AlertTop.js +3 -3
- package/dist/components/AlertTop/styles.module.css +0 -114
- package/dist/helperComponents/AlertButton.d.ts +19 -0
- package/dist/helperComponents/AlertButton.js +5 -0
- package/dist/helperComponents/index.d.ts +0 -1
- package/dist/helperComponents/index.js +0 -1
- package/dist/helperComponents/styles.module.css +138 -0
- package/package.json +4 -4
- package/src/components/Alert/Alert.tsx +24 -22
- package/src/components/Alert/styles.module.scss +7 -48
- package/src/components/AlertTop/AlertTop.tsx +16 -34
- package/src/components/AlertTop/styles.module.scss +14 -68
- package/src/helperComponents/AlertButton.tsx +45 -0
- package/src/helperComponents/index.ts +0 -1
- package/src/helperComponents/styles.module.scss +110 -0
- package/dist/helperComponents/AlertButton/AlertButton.d.ts +0 -9
- package/dist/helperComponents/AlertButton/AlertButton.js +0 -6
- package/dist/helperComponents/AlertButton/index.d.ts +0 -1
- package/dist/helperComponents/AlertButton/index.js +0 -1
- package/dist/helperComponents/AlertButton/styles.module.css +0 -75
- package/dist/helperComponents/AlertTopButton/AlertTopButton.d.ts +0 -9
- package/dist/helperComponents/AlertTopButton/AlertTopButton.js +0 -6
- package/dist/helperComponents/AlertTopButton/index.d.ts +0 -1
- package/dist/helperComponents/AlertTopButton/index.js +0 -1
- package/dist/helperComponents/AlertTopButton/styles.module.css +0 -55
- package/src/helperComponents/AlertButton/AlertButton.tsx +0 -26
- package/src/helperComponents/AlertButton/index.ts +0 -1
- package/src/helperComponents/AlertButton/styles.module.scss +0 -49
- package/src/helperComponents/AlertTopButton/AlertTopButton.tsx +0 -25
- package/src/helperComponents/AlertTopButton/index.ts +0 -1
- package/src/helperComponents/AlertTopButton/styles.module.scss +0 -54
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,27 @@
|
|
|
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.9.1 (2024-03-22)
|
|
7
|
+
|
|
8
|
+
### Only dependencies have been changed
|
|
9
|
+
* [@snack-uikit/link@0.11.5](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/link/CHANGELOG.md)
|
|
10
|
+
* [@snack-uikit/truncate-string@0.4.11](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/truncate-string/CHANGELOG.md)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
# 0.9.0 (2024-03-22)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### BREAKING CHANGES
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
* **FF-4556:** link/action(ex button) props was union; add link onClick ([314aab0](https://github.com/cloud-ru-tech/snack-uikit/commit/314aab0db20d73957fa58e09f1a604469a734d40))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
6
27
|
## 0.8.7 (2024-02-29)
|
|
7
28
|
|
|
8
29
|
### Only dependencies have been changed
|
package/README.md
CHANGED
|
@@ -17,9 +17,10 @@ import { InfoFilledSVG } from '@snack-uikit/icons';
|
|
|
17
17
|
|
|
18
18
|
<Alert
|
|
19
19
|
appearance='neutral'
|
|
20
|
-
link=
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
link={{
|
|
21
|
+
text: 'Link text',
|
|
22
|
+
href: 'https://cloud.ru/',
|
|
23
|
+
}}
|
|
23
24
|
title='Title'
|
|
24
25
|
description='Title description'
|
|
25
26
|
onClose={() => console.log('alert')}
|
|
@@ -30,15 +31,18 @@ import { InfoFilledSVG } from '@snack-uikit/icons';
|
|
|
30
31
|
|
|
31
32
|
<AlertTop
|
|
32
33
|
appearance='neutral'
|
|
33
|
-
link=
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
link={{
|
|
35
|
+
text: 'Link text',
|
|
36
|
+
href: 'https://cloud.ru/',
|
|
37
|
+
}}
|
|
38
|
+
closeable
|
|
37
39
|
title='Title'
|
|
38
40
|
description='Title description'
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
action={{
|
|
42
|
+
text: 'Button Text',
|
|
43
|
+
icon: <PlaceholderSVG />,
|
|
44
|
+
onClick: () => {},
|
|
45
|
+
}}
|
|
42
46
|
onClose={() => console.log('alert top')}
|
|
43
47
|
/>;
|
|
44
48
|
```
|
|
@@ -53,12 +57,11 @@ import { InfoFilledSVG } from '@snack-uikit/icons';
|
|
|
53
57
|
| description* | `string` | - | Описание |
|
|
54
58
|
| icon | `boolean` | true | Отображать иконку |
|
|
55
59
|
| title | `string` | - | Заголовок |
|
|
56
|
-
| link | `
|
|
57
|
-
| href | `string` | - | Ссылка |
|
|
60
|
+
| link | `Pick<LinkProps, "text" \| "target" \| "onClick" \| "href">` | - | Cсылка |
|
|
58
61
|
| onClose | `() => void` | - | Колбек закрытия |
|
|
59
62
|
| appearance | enum Appearance: `"neutral"`, `"primary"`, `"error"`, `"warning"`, `"success"` | neutral | Внешний вид |
|
|
60
63
|
| className | `string` | - | CSS-класс |
|
|
61
|
-
|
|
|
64
|
+
| actions | `{ primary: Omit<AlertButtonProps, "appearance">; secondary?: Omit<AlertButtonProps, "appearance">; }` | - | Кнопки в футере алерта |
|
|
62
65
|
## AlertTop
|
|
63
66
|
Компонент для отображения уведомления вверху экрана.
|
|
64
67
|
### Props
|
|
@@ -67,13 +70,10 @@ import { InfoFilledSVG } from '@snack-uikit/icons';
|
|
|
67
70
|
| description* | `string` | - | Описание |
|
|
68
71
|
| icon | `boolean` | true | Отображать иконку |
|
|
69
72
|
| title | `string` | - | Заголовок |
|
|
70
|
-
| link | `
|
|
71
|
-
|
|
|
73
|
+
| link | `Pick<LinkProps, "text" \| "target" \| "onClick" \| "href">` | - | Cсылка |
|
|
74
|
+
| action | `AlertButtonProps` | - | Кнопка дополнительного действия |
|
|
72
75
|
| onClose | `() => void` | - | Колбек закрытия |
|
|
73
76
|
| appearance | enum Appearance: `"neutral"`, `"primary"`, `"error"`, `"warning"`, `"success"` | neutral | Внешний вид |
|
|
74
|
-
| buttonText | `string` | - | Текст кнопки |
|
|
75
|
-
| buttonOnClick | `() => void` | - | Колбек клика по кнопке |
|
|
76
|
-
| buttonIcon | `ReactElement<any, string \| JSXElementConstructor<any>>` | - | Иконка в кнопке |
|
|
77
77
|
| className | `string` | - | CSS-класс |
|
|
78
78
|
|
|
79
79
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { LinkProps } from '@snack-uikit/link';
|
|
1
2
|
import { WithSupportProps } from '@snack-uikit/utils';
|
|
2
3
|
import { AlertButtonProps } from '../../helperComponents';
|
|
3
4
|
import { Appearance } from '../../types';
|
|
@@ -8,20 +9,21 @@ export type AlertProps = WithSupportProps<{
|
|
|
8
9
|
title?: string;
|
|
9
10
|
/** Описание */
|
|
10
11
|
description: string;
|
|
11
|
-
/**
|
|
12
|
-
link?:
|
|
13
|
-
/** Ссылка */
|
|
14
|
-
href?: string;
|
|
12
|
+
/** Cсылка */
|
|
13
|
+
link?: Pick<LinkProps, 'text' | 'target' | 'onClick' | 'href'>;
|
|
15
14
|
/** Колбек закрытия */
|
|
16
15
|
onClose?: () => void;
|
|
17
16
|
/** Внешний вид */
|
|
18
17
|
appearance?: Appearance;
|
|
19
18
|
/** CSS-класс */
|
|
20
19
|
className?: string;
|
|
21
|
-
/**
|
|
22
|
-
|
|
20
|
+
/** Кнопки в футере алерта */
|
|
21
|
+
actions?: {
|
|
22
|
+
primary: Omit<AlertButtonProps, 'appearance'>;
|
|
23
|
+
secondary?: Omit<AlertButtonProps, 'appearance'>;
|
|
24
|
+
};
|
|
23
25
|
}>;
|
|
24
26
|
/**
|
|
25
27
|
* Компонент для отображения уведомления.
|
|
26
28
|
*/
|
|
27
|
-
export declare function Alert({ icon, title,
|
|
29
|
+
export declare function Alert({ icon, title, link, description, onClose, appearance, className, actions, ...rest }: AlertProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -23,6 +23,6 @@ import styles from './styles.module.css';
|
|
|
23
23
|
* Компонент для отображения уведомления.
|
|
24
24
|
*/
|
|
25
25
|
export function Alert(_a) {
|
|
26
|
-
var { icon = true, title,
|
|
27
|
-
return (_jsxs("div", Object.assign({ className: cn(styles.alert, className) }, extractSupportProps(rest), { "data-color": APPEARANCE_TO_COLOR_MAP[appearance], children: [_jsxs("div", { className: styles.body, 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.contentLayout, 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, {
|
|
26
|
+
var { icon = true, title, link, description, onClose, appearance = APPEARANCE.Neutral, className, actions } = _a, rest = __rest(_a, ["icon", "title", "link", "description", "onClose", "appearance", "className", "actions"]);
|
|
27
|
+
return (_jsxs("div", Object.assign({ className: cn(styles.alert, className) }, extractSupportProps(rest), { "data-color": APPEARANCE_TO_COLOR_MAP[appearance], children: [_jsxs("div", { className: styles.body, 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.contentLayout, 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, Object.assign({}, link, { textMode: 'default', external: true, appearance: APPEARANCE_TO_COLOR_MAP[appearance], size: 'm', "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, children: [actions.primary && (_jsx(AlertButton, Object.assign({}, actions.primary, { appearance: APPEARANCE_TO_COLOR_MAP[appearance], variant: 'simple' }))), (actions === null || actions === void 0 ? void 0 : actions.secondary) && (_jsx(AlertButton, Object.assign({}, actions.secondary, { appearance: APPEARANCE_TO_COLOR_MAP[appearance], variant: 'simple' })))] }))] })));
|
|
28
28
|
}
|
|
@@ -40,6 +40,10 @@
|
|
|
40
40
|
width:100%;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
.icon{
|
|
44
|
+
width:var(--size-icon-container-s, 24px);
|
|
45
|
+
height:var(--size-icon-container-s, 24px);
|
|
46
|
+
}
|
|
43
47
|
.icon[data-color=neutral]{
|
|
44
48
|
color:var(--sys-neutral-accent-default, #6f717c);
|
|
45
49
|
}
|
|
@@ -56,8 +60,8 @@
|
|
|
56
60
|
color:var(--sys-green-accent-default, #57b762);
|
|
57
61
|
}
|
|
58
62
|
.icon svg{
|
|
59
|
-
width:var(--size-icon-container-s, 24px)
|
|
60
|
-
height:var(--size-icon-container-s, 24px)
|
|
63
|
+
max-width:var(--size-icon-container-s, 24px);
|
|
64
|
+
max-height:var(--size-icon-container-s, 24px);
|
|
61
65
|
}
|
|
62
66
|
|
|
63
67
|
.contentLayout{
|
|
@@ -89,106 +93,6 @@
|
|
|
89
93
|
word-wrap:break-word;
|
|
90
94
|
}
|
|
91
95
|
|
|
92
|
-
.closeButton{
|
|
93
|
-
height:var(--size-alert-button, 24px);
|
|
94
|
-
width:var(--size-alert-button, 24px);
|
|
95
|
-
border-radius:var(--radius-alert-button, 8px);
|
|
96
|
-
cursor:pointer;
|
|
97
|
-
display:flex;
|
|
98
|
-
align-items:center;
|
|
99
|
-
justify-content:center;
|
|
100
|
-
box-sizing:border-box;
|
|
101
|
-
margin:0;
|
|
102
|
-
margin-left:auto;
|
|
103
|
-
padding:0;
|
|
104
|
-
background:none;
|
|
105
|
-
border:none;
|
|
106
|
-
}
|
|
107
|
-
.closeButton svg{
|
|
108
|
-
width:var(--size-icon-container-s, 24px) !important;
|
|
109
|
-
height:var(--size-icon-container-s, 24px) !important;
|
|
110
|
-
}
|
|
111
|
-
.closeButton[data-color=neutral]{
|
|
112
|
-
color:var(--sys-neutral-text-support, #656771);
|
|
113
|
-
}
|
|
114
|
-
.closeButton[data-color=neutral]:hover{
|
|
115
|
-
color:var(--sys-neutral-text-light, #868892);
|
|
116
|
-
}
|
|
117
|
-
.closeButton[data-color=neutral]:focus-visible{
|
|
118
|
-
outline-width:var(--border-state-focus-s-border-width, 2px);
|
|
119
|
-
outline-style:var(--border-state-focus-s-border-style, solid);
|
|
120
|
-
outline-color:var(--border-state-focus-s-border-color, );
|
|
121
|
-
color:var(--sys-neutral-text-light, #868892);
|
|
122
|
-
outline-color:var(--sys-available-complementary, #141415);
|
|
123
|
-
}
|
|
124
|
-
.closeButton[data-color=neutral]:active{
|
|
125
|
-
color:var(--sys-neutral-text-main, #33333b);
|
|
126
|
-
}
|
|
127
|
-
.closeButton[data-color=primary]{
|
|
128
|
-
color:var(--sys-primary-text-support, #5b4796);
|
|
129
|
-
}
|
|
130
|
-
.closeButton[data-color=primary]:hover{
|
|
131
|
-
color:var(--sys-primary-text-light, #997adc);
|
|
132
|
-
}
|
|
133
|
-
.closeButton[data-color=primary]:focus-visible{
|
|
134
|
-
outline-width:var(--border-state-focus-s-border-width, 2px);
|
|
135
|
-
outline-style:var(--border-state-focus-s-border-style, solid);
|
|
136
|
-
outline-color:var(--border-state-focus-s-border-color, );
|
|
137
|
-
color:var(--sys-primary-text-light, #997adc);
|
|
138
|
-
outline-color:var(--sys-available-complementary, #141415);
|
|
139
|
-
}
|
|
140
|
-
.closeButton[data-color=primary]:active{
|
|
141
|
-
color:var(--sys-primary-text-main, #382a62);
|
|
142
|
-
}
|
|
143
|
-
.closeButton[data-color=red]{
|
|
144
|
-
color:var(--sys-red-text-support, #ab423e);
|
|
145
|
-
}
|
|
146
|
-
.closeButton[data-color=red]:hover{
|
|
147
|
-
color:var(--sys-red-text-light, #ea6658);
|
|
148
|
-
}
|
|
149
|
-
.closeButton[data-color=red]:focus-visible{
|
|
150
|
-
outline-width:var(--border-state-focus-s-border-width, 2px);
|
|
151
|
-
outline-style:var(--border-state-focus-s-border-style, solid);
|
|
152
|
-
outline-color:var(--border-state-focus-s-border-color, );
|
|
153
|
-
color:var(--sys-red-text-light, #ea6658);
|
|
154
|
-
outline-color:var(--sys-available-complementary, #141415);
|
|
155
|
-
}
|
|
156
|
-
.closeButton[data-color=red]:active{
|
|
157
|
-
color:var(--sys-red-text-main, #621c1b);
|
|
158
|
-
}
|
|
159
|
-
.closeButton[data-color=yellow]{
|
|
160
|
-
color:var(--sys-yellow-text-support, #a57b0e);
|
|
161
|
-
}
|
|
162
|
-
.closeButton[data-color=yellow]:hover{
|
|
163
|
-
color:var(--sys-yellow-text-light, #ddb035);
|
|
164
|
-
}
|
|
165
|
-
.closeButton[data-color=yellow]:focus-visible{
|
|
166
|
-
outline-width:var(--border-state-focus-s-border-width, 2px);
|
|
167
|
-
outline-style:var(--border-state-focus-s-border-style, solid);
|
|
168
|
-
outline-color:var(--border-state-focus-s-border-color, );
|
|
169
|
-
color:var(--sys-yellow-text-light, #ddb035);
|
|
170
|
-
outline-color:var(--sys-available-complementary, #141415);
|
|
171
|
-
}
|
|
172
|
-
.closeButton[data-color=yellow]:active{
|
|
173
|
-
color:var(--sys-yellow-text-main, #5e3d06);
|
|
174
|
-
}
|
|
175
|
-
.closeButton[data-color=green]{
|
|
176
|
-
color:var(--sys-green-text-support, #568a56);
|
|
177
|
-
}
|
|
178
|
-
.closeButton[data-color=green]:hover{
|
|
179
|
-
color:var(--sys-green-text-light, #67ba6e);
|
|
180
|
-
}
|
|
181
|
-
.closeButton[data-color=green]:focus-visible{
|
|
182
|
-
outline-width:var(--border-state-focus-s-border-width, 2px);
|
|
183
|
-
outline-style:var(--border-state-focus-s-border-style, solid);
|
|
184
|
-
outline-color:var(--border-state-focus-s-border-color, );
|
|
185
|
-
color:var(--sys-green-text-light, #67ba6e);
|
|
186
|
-
outline-color:var(--sys-available-complementary, #141415);
|
|
187
|
-
}
|
|
188
|
-
.closeButton[data-color=green]:active{
|
|
189
|
-
color:var(--sys-green-text-main, #323f27);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
96
|
.footer{
|
|
193
97
|
gap:var(--space-alert-container-footer-gap, 16px);
|
|
194
98
|
position:relative;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LinkProps } from '@snack-uikit/link';
|
|
2
2
|
import { WithSupportProps } from '@snack-uikit/utils';
|
|
3
|
+
import { AlertButtonProps } from '../../helperComponents';
|
|
3
4
|
import { Appearance } from '../../types';
|
|
4
5
|
export type AlertTopProps = WithSupportProps<{
|
|
5
6
|
/** Отображать иконку */
|
|
@@ -8,24 +9,18 @@ export type AlertTopProps = WithSupportProps<{
|
|
|
8
9
|
title?: string;
|
|
9
10
|
/** Описание */
|
|
10
11
|
description: string;
|
|
11
|
-
/**
|
|
12
|
-
link?:
|
|
13
|
-
/**
|
|
14
|
-
|
|
12
|
+
/** Cсылка */
|
|
13
|
+
link?: Pick<LinkProps, 'text' | 'target' | 'onClick' | 'href'>;
|
|
14
|
+
/** Кнопка дополнительного действия */
|
|
15
|
+
action?: AlertButtonProps;
|
|
15
16
|
/** Колбек закрытия */
|
|
16
17
|
onClose?: () => void;
|
|
17
18
|
/** Внешний вид */
|
|
18
19
|
appearance?: Appearance;
|
|
19
|
-
/** Текст кнопки */
|
|
20
|
-
buttonText?: string;
|
|
21
|
-
/** Колбек клика по кнопке */
|
|
22
|
-
buttonOnClick?: () => void;
|
|
23
|
-
/** Иконка в кнопке */
|
|
24
|
-
buttonIcon?: ReactElement;
|
|
25
20
|
/** CSS-класс */
|
|
26
21
|
className?: string;
|
|
27
22
|
}>;
|
|
28
23
|
/**
|
|
29
24
|
* Компонент для отображения уведомления вверху экрана.
|
|
30
25
|
*/
|
|
31
|
-
export declare function AlertTop({ icon, title, description, link,
|
|
26
|
+
export declare function AlertTop({ icon, title, description, link, onClose, appearance, action, className, ...rest }: AlertTopProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -16,7 +16,7 @@ import { Link } from '@snack-uikit/link';
|
|
|
16
16
|
import { TruncateString } from '@snack-uikit/truncate-string';
|
|
17
17
|
import { extractSupportProps } from '@snack-uikit/utils';
|
|
18
18
|
import { APPEARANCE, APPEARANCE_TO_COLOR_MAP } from '../../constants';
|
|
19
|
-
import {
|
|
19
|
+
import { AlertButton } from '../../helperComponents';
|
|
20
20
|
import { getIcon } from '../../utils';
|
|
21
21
|
import { APPEARANCE_TO_COLOR_MAP_INVERT } from './constants';
|
|
22
22
|
import styles from './styles.module.css';
|
|
@@ -24,6 +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,
|
|
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, { textMode: 'on-accent',
|
|
27
|
+
var { icon = true, title, description, link, onClose, appearance = APPEARANCE.Neutral, action, className } = _a, rest = __rest(_a, ["icon", "title", "description", "link", "onClose", "appearance", "action", "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, Object.assign({}, link, { textMode: 'on-accent', external: true, appearance: APPEARANCE_TO_COLOR_MAP[appearance], 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
29
|
}
|
|
@@ -120,118 +120,4 @@
|
|
|
120
120
|
display:flex;
|
|
121
121
|
gap:var(--dimension-2m, 16px);
|
|
122
122
|
align-items:center;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
.closeButton{
|
|
126
|
-
border-radius:var(--radius-alert-top-button, 12px);
|
|
127
|
-
height:var(--size-alert-top-button, 32px);
|
|
128
|
-
width:var(--size-alert-top-button, 32px);
|
|
129
|
-
cursor:pointer;
|
|
130
|
-
display:flex;
|
|
131
|
-
align-items:center;
|
|
132
|
-
justify-content:center;
|
|
133
|
-
box-sizing:border-box;
|
|
134
|
-
margin:0;
|
|
135
|
-
padding:0;
|
|
136
|
-
background:none;
|
|
137
|
-
border:none;
|
|
138
|
-
}
|
|
139
|
-
.closeButton svg{
|
|
140
|
-
width:var(--size-icon-container-s, 24px) !important;
|
|
141
|
-
height:var(--size-icon-container-s, 24px) !important;
|
|
142
|
-
}
|
|
143
|
-
.closeButton[data-color=invert-neutral]{
|
|
144
|
-
color:var(--sys-invert-neutral-text-main, #e8eaf1);
|
|
145
|
-
background-color:inherit;
|
|
146
|
-
}
|
|
147
|
-
.closeButton[data-color=invert-neutral]:hover{
|
|
148
|
-
opacity:unset;
|
|
149
|
-
background-color:var(--sys-opacity-hovered, rgba(255, 255, 255, 0.2392156863));
|
|
150
|
-
}
|
|
151
|
-
.closeButton[data-color=invert-neutral]:focus-visible{
|
|
152
|
-
outline-width:var(--border-state-focus-s-border-width, 2px);
|
|
153
|
-
outline-style:var(--border-state-focus-s-border-style, solid);
|
|
154
|
-
outline-color:var(--border-state-focus-s-border-color, );
|
|
155
|
-
opacity:unset;
|
|
156
|
-
background-color:var(--sys-opacity-hovered, rgba(255, 255, 255, 0.2392156863));
|
|
157
|
-
outline-color:var(--sys-available-on-complementary, #ffffff);
|
|
158
|
-
}
|
|
159
|
-
.closeButton[data-color=invert-neutral]:active{
|
|
160
|
-
background-color:var(--sys-opacity-activated, rgba(255, 255, 255, 0.3215686275));
|
|
161
|
-
}
|
|
162
|
-
.closeButton[data-color=primary]{
|
|
163
|
-
color:var(--sys-primary-on-accent, #fdfbff);
|
|
164
|
-
background-color:inherit;
|
|
165
|
-
}
|
|
166
|
-
.closeButton[data-color=primary]:hover{
|
|
167
|
-
opacity:unset;
|
|
168
|
-
background-color:var(--sys-opacity-hovered, rgba(255, 255, 255, 0.2392156863));
|
|
169
|
-
}
|
|
170
|
-
.closeButton[data-color=primary]:focus-visible{
|
|
171
|
-
outline-width:var(--border-state-focus-s-border-width, 2px);
|
|
172
|
-
outline-style:var(--border-state-focus-s-border-style, solid);
|
|
173
|
-
outline-color:var(--border-state-focus-s-border-color, );
|
|
174
|
-
opacity:unset;
|
|
175
|
-
background-color:var(--sys-opacity-hovered, rgba(255, 255, 255, 0.2392156863));
|
|
176
|
-
outline-color:var(--sys-available-on-complementary, #ffffff);
|
|
177
|
-
}
|
|
178
|
-
.closeButton[data-color=primary]:active{
|
|
179
|
-
background-color:var(--sys-opacity-activated, rgba(255, 255, 255, 0.3215686275));
|
|
180
|
-
}
|
|
181
|
-
.closeButton[data-color=red]{
|
|
182
|
-
color:var(--sys-red-on-accent, #fffbf9);
|
|
183
|
-
background-color:inherit;
|
|
184
|
-
}
|
|
185
|
-
.closeButton[data-color=red]:hover{
|
|
186
|
-
opacity:unset;
|
|
187
|
-
background-color:var(--sys-opacity-hovered, rgba(255, 255, 255, 0.2392156863));
|
|
188
|
-
}
|
|
189
|
-
.closeButton[data-color=red]:focus-visible{
|
|
190
|
-
outline-width:var(--border-state-focus-s-border-width, 2px);
|
|
191
|
-
outline-style:var(--border-state-focus-s-border-style, solid);
|
|
192
|
-
outline-color:var(--border-state-focus-s-border-color, );
|
|
193
|
-
opacity:unset;
|
|
194
|
-
background-color:var(--sys-opacity-hovered, rgba(255, 255, 255, 0.2392156863));
|
|
195
|
-
outline-color:var(--sys-available-on-complementary, #ffffff);
|
|
196
|
-
}
|
|
197
|
-
.closeButton[data-color=red]:active{
|
|
198
|
-
background-color:var(--sys-opacity-activated, rgba(255, 255, 255, 0.3215686275));
|
|
199
|
-
}
|
|
200
|
-
.closeButton[data-color=yellow]{
|
|
201
|
-
color:var(--sys-yellow-on-accent, #5e3d06);
|
|
202
|
-
background-color:inherit;
|
|
203
|
-
}
|
|
204
|
-
.closeButton[data-color=yellow]:hover{
|
|
205
|
-
opacity:unset;
|
|
206
|
-
background-color:var(--sys-opacity-hovered, rgba(255, 255, 255, 0.2392156863));
|
|
207
|
-
}
|
|
208
|
-
.closeButton[data-color=yellow]:focus-visible{
|
|
209
|
-
outline-width:var(--border-state-focus-s-border-width, 2px);
|
|
210
|
-
outline-style:var(--border-state-focus-s-border-style, solid);
|
|
211
|
-
outline-color:var(--border-state-focus-s-border-color, );
|
|
212
|
-
opacity:unset;
|
|
213
|
-
background-color:var(--sys-opacity-hovered, rgba(255, 255, 255, 0.2392156863));
|
|
214
|
-
outline-color:var(--sys-available-on-complementary, #ffffff);
|
|
215
|
-
}
|
|
216
|
-
.closeButton[data-color=yellow]:active{
|
|
217
|
-
background-color:var(--sys-opacity-activated, rgba(255, 255, 255, 0.3215686275));
|
|
218
|
-
}
|
|
219
|
-
.closeButton[data-color=green]{
|
|
220
|
-
color:var(--sys-green-on-accent, #fcfefa);
|
|
221
|
-
background-color:inherit;
|
|
222
|
-
}
|
|
223
|
-
.closeButton[data-color=green]:hover{
|
|
224
|
-
opacity:unset;
|
|
225
|
-
background-color:var(--sys-opacity-hovered, rgba(255, 255, 255, 0.2392156863));
|
|
226
|
-
}
|
|
227
|
-
.closeButton[data-color=green]:focus-visible{
|
|
228
|
-
outline-width:var(--border-state-focus-s-border-width, 2px);
|
|
229
|
-
outline-style:var(--border-state-focus-s-border-style, solid);
|
|
230
|
-
outline-color:var(--border-state-focus-s-border-color, );
|
|
231
|
-
opacity:unset;
|
|
232
|
-
background-color:var(--sys-opacity-hovered, rgba(255, 255, 255, 0.2392156863));
|
|
233
|
-
outline-color:var(--sys-available-on-complementary, #ffffff);
|
|
234
|
-
}
|
|
235
|
-
.closeButton[data-color=green]:active{
|
|
236
|
-
background-color:var(--sys-opacity-activated, rgba(255, 255, 255, 0.3215686275));
|
|
237
123
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { MouseEvent, ReactElement } from 'react';
|
|
2
|
+
import { LinkProps } from '@snack-uikit/link';
|
|
3
|
+
type PrivateAlertButtonProps = {
|
|
4
|
+
/** Внешний вид */
|
|
5
|
+
appearance?: LinkProps['appearance'] | 'invert-neutral';
|
|
6
|
+
/** Текст кнопки */
|
|
7
|
+
text?: string;
|
|
8
|
+
/** Иконка в кнопке */
|
|
9
|
+
icon?: ReactElement;
|
|
10
|
+
/** Вариант отображения */
|
|
11
|
+
variant?: 'simple' | 'tonal';
|
|
12
|
+
/** Колбек клика */
|
|
13
|
+
onClick?(e: MouseEvent<HTMLButtonElement>): void;
|
|
14
|
+
/** Дата тест айди */
|
|
15
|
+
dataTestId?: string;
|
|
16
|
+
};
|
|
17
|
+
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;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import styles from './styles.module.css';
|
|
3
|
+
export function AlertButton({ appearance, text, icon, onClick, variant = 'simple', dataTestId, }) {
|
|
4
|
+
return (_jsxs("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 })] }));
|
|
5
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
.alertButton{
|
|
2
|
+
cursor:pointer;
|
|
3
|
+
display:flex;
|
|
4
|
+
align-items:center;
|
|
5
|
+
justify-content:center;
|
|
6
|
+
box-sizing:border-box;
|
|
7
|
+
margin:0;
|
|
8
|
+
padding:0;
|
|
9
|
+
white-space:nowrap;
|
|
10
|
+
background:none;
|
|
11
|
+
border:0;
|
|
12
|
+
}
|
|
13
|
+
.alertButton .text{
|
|
14
|
+
font-family:var(--sans-label-l-font-family, SB Sans Interface);
|
|
15
|
+
font-weight:var(--sans-label-l-font-weight, Semibold);
|
|
16
|
+
line-height:var(--sans-label-l-line-height, 20px);
|
|
17
|
+
font-size:var(--sans-label-l-font-size, 14px);
|
|
18
|
+
letter-spacing:var(--sans-label-l-letter-spacing, -0.1px);
|
|
19
|
+
paragraph-spacing:var(--sans-label-l-paragraph-spacing, 7.7px);
|
|
20
|
+
}
|
|
21
|
+
.alertButton .icon{
|
|
22
|
+
display:inline-flex;
|
|
23
|
+
align-items:center;
|
|
24
|
+
justify-content:center;
|
|
25
|
+
width:var(--size-icon-container-s, 24px);
|
|
26
|
+
height:var(--size-icon-container-s, 24px);
|
|
27
|
+
}
|
|
28
|
+
.alertButton .icon svg{
|
|
29
|
+
max-width:var(--size-icon-container-s, 24px);
|
|
30
|
+
max-height:var(--size-icon-container-s, 24px);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.alertButton[data-variant=simple]{
|
|
34
|
+
height:var(--size-alert-button, 24px);
|
|
35
|
+
gap:var(--space-alert-button-gap, 4px);
|
|
36
|
+
border-radius:var(--radius-alert-button, 8px);
|
|
37
|
+
}
|
|
38
|
+
.alertButton[data-variant=simple][data-icon-only]{
|
|
39
|
+
height:var(--size-alert-button, 24px);
|
|
40
|
+
width:var(--size-alert-button, 24px);
|
|
41
|
+
border-radius:var(--radius-alert-button, 8px);
|
|
42
|
+
}
|
|
43
|
+
.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
|
+
outline-color:var(--sys-available-complementary, #141415);
|
|
48
|
+
outline-offset:var(--spacing-state-focus-offset, 2px);
|
|
49
|
+
}
|
|
50
|
+
.alertButton[data-variant=simple][data-appearance=neutral]{
|
|
51
|
+
color:var(--sys-neutral-text-support, #656771);
|
|
52
|
+
}
|
|
53
|
+
.alertButton[data-variant=simple][data-appearance=neutral]:hover, .alertButton[data-variant=simple][data-appearance=neutral]:focus-visible{
|
|
54
|
+
color:var(--sys-neutral-text-light, #868892);
|
|
55
|
+
}
|
|
56
|
+
.alertButton[data-variant=simple][data-appearance=neutral]:active{
|
|
57
|
+
color:var(--sys-neutral-text-main, #33333b);
|
|
58
|
+
}
|
|
59
|
+
.alertButton[data-variant=simple][data-appearance=primary]{
|
|
60
|
+
color:var(--sys-primary-text-support, #5b4796);
|
|
61
|
+
}
|
|
62
|
+
.alertButton[data-variant=simple][data-appearance=primary]:hover, .alertButton[data-variant=simple][data-appearance=primary]:focus-visible{
|
|
63
|
+
color:var(--sys-primary-text-light, #997adc);
|
|
64
|
+
}
|
|
65
|
+
.alertButton[data-variant=simple][data-appearance=primary]:active{
|
|
66
|
+
color:var(--sys-primary-text-main, #382a62);
|
|
67
|
+
}
|
|
68
|
+
.alertButton[data-variant=simple][data-appearance=red]{
|
|
69
|
+
color:var(--sys-red-text-support, #ab423e);
|
|
70
|
+
}
|
|
71
|
+
.alertButton[data-variant=simple][data-appearance=red]:hover, .alertButton[data-variant=simple][data-appearance=red]:focus-visible{
|
|
72
|
+
color:var(--sys-red-text-light, #ea6658);
|
|
73
|
+
}
|
|
74
|
+
.alertButton[data-variant=simple][data-appearance=red]:active{
|
|
75
|
+
color:var(--sys-red-text-main, #621c1b);
|
|
76
|
+
}
|
|
77
|
+
.alertButton[data-variant=simple][data-appearance=yellow]{
|
|
78
|
+
color:var(--sys-yellow-text-support, #a57b0e);
|
|
79
|
+
}
|
|
80
|
+
.alertButton[data-variant=simple][data-appearance=yellow]:hover, .alertButton[data-variant=simple][data-appearance=yellow]:focus-visible{
|
|
81
|
+
color:var(--sys-yellow-text-light, #ddb035);
|
|
82
|
+
}
|
|
83
|
+
.alertButton[data-variant=simple][data-appearance=yellow]:active{
|
|
84
|
+
color:var(--sys-yellow-text-main, #5e3d06);
|
|
85
|
+
}
|
|
86
|
+
.alertButton[data-variant=simple][data-appearance=green]{
|
|
87
|
+
color:var(--sys-green-text-support, #568a56);
|
|
88
|
+
}
|
|
89
|
+
.alertButton[data-variant=simple][data-appearance=green]:hover, .alertButton[data-variant=simple][data-appearance=green]:focus-visible{
|
|
90
|
+
color:var(--sys-green-text-light, #67ba6e);
|
|
91
|
+
}
|
|
92
|
+
.alertButton[data-variant=simple][data-appearance=green]:active{
|
|
93
|
+
color:var(--sys-green-text-main, #323f27);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.alertButton[data-variant=tonal]{
|
|
97
|
+
height:var(--size-alert-top-button, 32px);
|
|
98
|
+
gap:var(--space-alert-top-button-gap, 4px);
|
|
99
|
+
border-radius:var(--radius-alert-top-button, 12px);
|
|
100
|
+
padding-left:var(--space-alert-top-button-horizontal-padding, 12px);
|
|
101
|
+
padding-right:var(--space-alert-top-button-horizontal-padding, 12px);
|
|
102
|
+
background:var(--sys-opacity-enabled, rgba(255, 255, 255, 0.1607843137));
|
|
103
|
+
}
|
|
104
|
+
.alertButton[data-variant=tonal][data-icon-only]{
|
|
105
|
+
border-radius:var(--radius-alert-top-button, 12px);
|
|
106
|
+
height:var(--size-alert-top-button, 32px);
|
|
107
|
+
width:var(--size-alert-top-button, 32px);
|
|
108
|
+
background:none;
|
|
109
|
+
}
|
|
110
|
+
.alertButton[data-variant=tonal]:hover{
|
|
111
|
+
opacity:unset;
|
|
112
|
+
background-color:var(--sys-opacity-hovered, rgba(255, 255, 255, 0.2392156863));
|
|
113
|
+
}
|
|
114
|
+
.alertButton[data-variant=tonal]:focus-visible{
|
|
115
|
+
outline-width:var(--border-state-focus-s-border-width, 2px);
|
|
116
|
+
outline-style:var(--border-state-focus-s-border-style, solid);
|
|
117
|
+
outline-color:var(--border-state-focus-s-border-color, );
|
|
118
|
+
background-color:var(--sys-opacity-hovered, rgba(255, 255, 255, 0.2392156863));
|
|
119
|
+
outline-color:var(--sys-available-on-complementary, #ffffff);
|
|
120
|
+
}
|
|
121
|
+
.alertButton[data-variant=tonal]:active{
|
|
122
|
+
background-color:var(--sys-opacity-activated, rgba(255, 255, 255, 0.3215686275));
|
|
123
|
+
}
|
|
124
|
+
.alertButton[data-variant=tonal][data-appearance=invert-neutral]{
|
|
125
|
+
color:var(--sys-invert-neutral-text-main, #e8eaf1);
|
|
126
|
+
}
|
|
127
|
+
.alertButton[data-variant=tonal][data-appearance=primary]{
|
|
128
|
+
color:var(--sys-primary-on-accent, #fdfbff);
|
|
129
|
+
}
|
|
130
|
+
.alertButton[data-variant=tonal][data-appearance=red]{
|
|
131
|
+
color:var(--sys-red-on-accent, #fffbf9);
|
|
132
|
+
}
|
|
133
|
+
.alertButton[data-variant=tonal][data-appearance=yellow]{
|
|
134
|
+
color:var(--sys-yellow-on-accent, #5e3d06);
|
|
135
|
+
}
|
|
136
|
+
.alertButton[data-variant=tonal][data-appearance=green]{
|
|
137
|
+
color:var(--sys-green-on-accent, #fcfefa);
|
|
138
|
+
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Alert",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.9.1",
|
|
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.20.1",
|
|
36
|
-
"@snack-uikit/link": "0.11.5
|
|
37
|
-
"@snack-uikit/truncate-string": "0.4.11
|
|
36
|
+
"@snack-uikit/link": "0.11.5",
|
|
37
|
+
"@snack-uikit/truncate-string": "0.4.11",
|
|
38
38
|
"@snack-uikit/utils": "3.2.0",
|
|
39
39
|
"classnames": "2.3.2"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "52f53f82be47e223ad63678b709e32d38c5bca87"
|
|
42
42
|
}
|