@snack-uikit/alert 0.8.7 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/README.md +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 +2 -2
- 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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import cn from 'classnames';
|
|
2
2
|
|
|
3
3
|
import { CrossSVG } from '@snack-uikit/icons';
|
|
4
|
-
import { Link } from '@snack-uikit/link';
|
|
4
|
+
import { Link, LinkProps } from '@snack-uikit/link';
|
|
5
5
|
import { TruncateString } from '@snack-uikit/truncate-string';
|
|
6
6
|
import { extractSupportProps, WithSupportProps } from '@snack-uikit/utils';
|
|
7
7
|
|
|
@@ -18,18 +18,19 @@ export type AlertProps = WithSupportProps<{
|
|
|
18
18
|
title?: string;
|
|
19
19
|
/** Описание */
|
|
20
20
|
description: string;
|
|
21
|
-
/**
|
|
22
|
-
link?:
|
|
23
|
-
/** Ссылка */
|
|
24
|
-
href?: string;
|
|
21
|
+
/** Cсылка */
|
|
22
|
+
link?: Pick<LinkProps, 'text' | 'target' | 'onClick' | 'href'>;
|
|
25
23
|
/** Колбек закрытия */
|
|
26
24
|
onClose?: () => void;
|
|
27
25
|
/** Внешний вид */
|
|
28
26
|
appearance?: Appearance;
|
|
29
27
|
/** CSS-класс */
|
|
30
28
|
className?: string;
|
|
31
|
-
/**
|
|
32
|
-
|
|
29
|
+
/** Кнопки в футере алерта */
|
|
30
|
+
actions?: {
|
|
31
|
+
primary: Omit<AlertButtonProps, 'appearance'>;
|
|
32
|
+
secondary?: Omit<AlertButtonProps, 'appearance'>;
|
|
33
|
+
};
|
|
33
34
|
}>;
|
|
34
35
|
|
|
35
36
|
/**
|
|
@@ -38,13 +39,12 @@ export type AlertProps = WithSupportProps<{
|
|
|
38
39
|
export function Alert({
|
|
39
40
|
icon = true,
|
|
40
41
|
title,
|
|
41
|
-
href,
|
|
42
42
|
link,
|
|
43
43
|
description,
|
|
44
44
|
onClose,
|
|
45
45
|
appearance = APPEARANCE.Neutral,
|
|
46
46
|
className,
|
|
47
|
-
|
|
47
|
+
actions,
|
|
48
48
|
...rest
|
|
49
49
|
}: AlertProps) {
|
|
50
50
|
return (
|
|
@@ -62,6 +62,7 @@ export function Alert({
|
|
|
62
62
|
|
|
63
63
|
<div className={styles.contentLayout}>
|
|
64
64
|
{title && <TruncateString text={title} maxLines={1} className={styles.title} data-test-id='alert__title' />}
|
|
65
|
+
|
|
65
66
|
<span data-test-id='alert__description' className={styles.description}>
|
|
66
67
|
{description}
|
|
67
68
|
</span>
|
|
@@ -69,8 +70,7 @@ export function Alert({
|
|
|
69
70
|
{link && (
|
|
70
71
|
<span>
|
|
71
72
|
<Link
|
|
72
|
-
|
|
73
|
-
text={link}
|
|
73
|
+
{...link}
|
|
74
74
|
textMode='default'
|
|
75
75
|
external
|
|
76
76
|
appearance={APPEARANCE_TO_COLOR_MAP[appearance]}
|
|
@@ -82,22 +82,24 @@ export function Alert({
|
|
|
82
82
|
</div>
|
|
83
83
|
|
|
84
84
|
{onClose && (
|
|
85
|
-
<
|
|
85
|
+
<AlertButton
|
|
86
86
|
onClick={onClose}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
</button>
|
|
87
|
+
appearance={APPEARANCE_TO_COLOR_MAP[appearance]}
|
|
88
|
+
icon={<CrossSVG />}
|
|
89
|
+
variant='simple'
|
|
90
|
+
dataTestId='alert__close-button'
|
|
91
|
+
/>
|
|
93
92
|
)}
|
|
94
93
|
</div>
|
|
95
94
|
|
|
96
|
-
{
|
|
95
|
+
{actions && (
|
|
97
96
|
<div className={styles.footer}>
|
|
98
|
-
{
|
|
99
|
-
<AlertButton
|
|
100
|
-
)
|
|
97
|
+
{actions.primary && (
|
|
98
|
+
<AlertButton {...actions.primary} appearance={APPEARANCE_TO_COLOR_MAP[appearance]} variant='simple' />
|
|
99
|
+
)}
|
|
100
|
+
{actions?.secondary && (
|
|
101
|
+
<AlertButton {...actions.secondary} appearance={APPEARANCE_TO_COLOR_MAP[appearance]} variant='simple' />
|
|
102
|
+
)}
|
|
101
103
|
</div>
|
|
102
104
|
)}
|
|
103
105
|
</div>
|
|
@@ -19,7 +19,7 @@ $colors: 'neutral', 'primary', 'red', 'yellow', 'green';
|
|
|
19
19
|
background-color: simple-var($theme-variables, 'sys', $color, 'background');
|
|
20
20
|
border-color: simple-var($theme-variables, 'sys', $color, 'decor-default');
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
}
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
.body {
|
|
@@ -27,7 +27,7 @@ $colors: 'neutral', 'primary', 'red', 'yellow', 'green';
|
|
|
27
27
|
|
|
28
28
|
display: flex;
|
|
29
29
|
box-sizing: border-box;
|
|
30
|
-
width: 100
|
|
30
|
+
width: 100%;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
.icon {
|
|
@@ -37,9 +37,12 @@ $colors: 'neutral', 'primary', 'red', 'yellow', 'green';
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
width: $icon-s;
|
|
41
|
+
height: $icon-s;
|
|
42
|
+
|
|
40
43
|
svg {
|
|
41
|
-
width: $icon-s
|
|
42
|
-
height: $icon-s
|
|
44
|
+
max-width: $icon-s;
|
|
45
|
+
max-height: $icon-s;
|
|
43
46
|
}
|
|
44
47
|
}
|
|
45
48
|
|
|
@@ -65,50 +68,6 @@ $colors: 'neutral', 'primary', 'red', 'yellow', 'green';
|
|
|
65
68
|
word-wrap: break-word;
|
|
66
69
|
}
|
|
67
70
|
|
|
68
|
-
.closeButton {
|
|
69
|
-
@include composite-var($alert-button-button-close);
|
|
70
|
-
|
|
71
|
-
cursor: pointer;
|
|
72
|
-
|
|
73
|
-
display: flex;
|
|
74
|
-
align-items: center;
|
|
75
|
-
justify-content: center;
|
|
76
|
-
|
|
77
|
-
box-sizing: border-box;
|
|
78
|
-
margin: 0;
|
|
79
|
-
margin-left: auto;
|
|
80
|
-
padding: 0;
|
|
81
|
-
|
|
82
|
-
background: none;
|
|
83
|
-
border: none;
|
|
84
|
-
|
|
85
|
-
svg {
|
|
86
|
-
width: $icon-s !important; /* stylelint-disable-line declaration-no-important */
|
|
87
|
-
height: $icon-s !important; /* stylelint-disable-line declaration-no-important */
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
@each $color in $colors {
|
|
91
|
-
&[data-color='#{$color}'] {
|
|
92
|
-
color: simple-var($theme-variables, 'sys', $color, 'text-support');
|
|
93
|
-
|
|
94
|
-
&:hover {
|
|
95
|
-
color: simple-var($theme-variables, 'sys', $color, 'text-light');
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
&:focus-visible {
|
|
99
|
-
@include outline-var($container-focused-s);
|
|
100
|
-
|
|
101
|
-
color: simple-var($theme-variables, 'sys', $color, 'text-light');
|
|
102
|
-
outline-color: $sys-available-complementary;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
&:active {
|
|
106
|
-
color: simple-var($theme-variables, 'sys', $color, 'text-main');
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
71
|
.footer {
|
|
113
72
|
@include composite-var($alert-container-footer);
|
|
114
73
|
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import cn from 'classnames';
|
|
2
|
-
import { ReactElement } from 'react';
|
|
3
2
|
|
|
4
3
|
import { CrossSVG } from '@snack-uikit/icons';
|
|
5
|
-
import { Link } from '@snack-uikit/link';
|
|
4
|
+
import { Link, LinkProps } from '@snack-uikit/link';
|
|
6
5
|
import { TruncateString } from '@snack-uikit/truncate-string';
|
|
7
6
|
import { extractSupportProps, WithSupportProps } from '@snack-uikit/utils';
|
|
8
7
|
|
|
9
8
|
import { APPEARANCE, APPEARANCE_TO_COLOR_MAP } from '../../constants';
|
|
10
|
-
import {
|
|
9
|
+
import { AlertButton, AlertButtonProps } from '../../helperComponents';
|
|
11
10
|
import { Appearance } from '../../types';
|
|
12
11
|
import { getIcon } from '../../utils';
|
|
13
12
|
import { APPEARANCE_TO_COLOR_MAP_INVERT } from './constants';
|
|
@@ -20,20 +19,14 @@ export type AlertTopProps = WithSupportProps<{
|
|
|
20
19
|
title?: string;
|
|
21
20
|
/** Описание */
|
|
22
21
|
description: string;
|
|
23
|
-
/**
|
|
24
|
-
link?:
|
|
25
|
-
/**
|
|
26
|
-
|
|
22
|
+
/** Cсылка */
|
|
23
|
+
link?: Pick<LinkProps, 'text' | 'target' | 'onClick' | 'href'>;
|
|
24
|
+
/** Кнопка дополнительного действия */
|
|
25
|
+
action?: AlertButtonProps;
|
|
27
26
|
/** Колбек закрытия */
|
|
28
27
|
onClose?: () => void;
|
|
29
28
|
/** Внешний вид */
|
|
30
29
|
appearance?: Appearance;
|
|
31
|
-
/** Текст кнопки */
|
|
32
|
-
buttonText?: string;
|
|
33
|
-
/** Колбек клика по кнопке */
|
|
34
|
-
buttonOnClick?: () => void;
|
|
35
|
-
/** Иконка в кнопке */
|
|
36
|
-
buttonIcon?: ReactElement;
|
|
37
30
|
/** CSS-класс */
|
|
38
31
|
className?: string;
|
|
39
32
|
}>;
|
|
@@ -46,12 +39,9 @@ export function AlertTop({
|
|
|
46
39
|
title,
|
|
47
40
|
description,
|
|
48
41
|
link,
|
|
49
|
-
href,
|
|
50
42
|
onClose,
|
|
51
43
|
appearance = APPEARANCE.Neutral,
|
|
52
|
-
|
|
53
|
-
buttonOnClick,
|
|
54
|
-
buttonIcon,
|
|
44
|
+
action,
|
|
55
45
|
className,
|
|
56
46
|
...rest
|
|
57
47
|
}: AlertTopProps) {
|
|
@@ -92,12 +82,12 @@ export function AlertTop({
|
|
|
92
82
|
{description}
|
|
93
83
|
</span>
|
|
94
84
|
</div>
|
|
85
|
+
|
|
95
86
|
{link && (
|
|
96
87
|
<span>
|
|
97
88
|
<Link
|
|
89
|
+
{...link}
|
|
98
90
|
textMode='on-accent'
|
|
99
|
-
href={href}
|
|
100
|
-
text={link}
|
|
101
91
|
external
|
|
102
92
|
appearance={APPEARANCE_TO_COLOR_MAP[appearance]}
|
|
103
93
|
size='m'
|
|
@@ -108,24 +98,16 @@ export function AlertTop({
|
|
|
108
98
|
</div>
|
|
109
99
|
</div>
|
|
110
100
|
<div className={styles.actions}>
|
|
111
|
-
{
|
|
112
|
-
<AlertTopButton
|
|
113
|
-
buttonIcon={buttonIcon}
|
|
114
|
-
buttonOnClick={buttonOnClick}
|
|
115
|
-
buttonText={buttonText}
|
|
116
|
-
appearance={appearance}
|
|
117
|
-
/>
|
|
118
|
-
)}
|
|
101
|
+
{action && <AlertButton {...action} appearance={APPEARANCE_TO_COLOR_MAP_INVERT[appearance]} variant='tonal' />}
|
|
119
102
|
|
|
120
103
|
{onClose && (
|
|
121
|
-
<
|
|
104
|
+
<AlertButton
|
|
122
105
|
onClick={onClose}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
</button>
|
|
106
|
+
appearance={APPEARANCE_TO_COLOR_MAP_INVERT[appearance]}
|
|
107
|
+
icon={<CrossSVG />}
|
|
108
|
+
variant='tonal'
|
|
109
|
+
dataTestId='alert-top__close-button'
|
|
110
|
+
/>
|
|
129
111
|
)}
|
|
130
112
|
</div>
|
|
131
113
|
</div>
|
|
@@ -12,11 +12,11 @@ $colors: 'invert-neutral', 'primary', 'red', 'yellow', 'green';
|
|
|
12
12
|
|
|
13
13
|
@each $color in $colors {
|
|
14
14
|
&[data-color='#{$color}'] {
|
|
15
|
-
@if $color == 'invert-neutral'{
|
|
16
|
-
background-color
|
|
15
|
+
@if $color == 'invert-neutral' {
|
|
16
|
+
background-color: $sys-invert-neutral-background;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
@else {
|
|
20
20
|
background-color: simple-var($theme-variables, 'sys', $color, 'accent-default');
|
|
21
21
|
}
|
|
22
22
|
}
|
|
@@ -30,11 +30,11 @@ $colors: 'invert-neutral', 'primary', 'red', 'yellow', 'green';
|
|
|
30
30
|
|
|
31
31
|
@each $color in $colors {
|
|
32
32
|
&[data-color='#{$color}'] {
|
|
33
|
-
@if $color == 'invert-neutral'{
|
|
34
|
-
color
|
|
33
|
+
@if $color == 'invert-neutral' {
|
|
34
|
+
color: $sys-invert-neutral-text-main;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
@else {
|
|
38
38
|
color: simple-var($theme-variables, 'sys', $color, 'on-accent');
|
|
39
39
|
}
|
|
40
40
|
}
|
|
@@ -51,11 +51,11 @@ $colors: 'invert-neutral', 'primary', 'red', 'yellow', 'green';
|
|
|
51
51
|
|
|
52
52
|
@each $color in $colors {
|
|
53
53
|
&[data-color='#{$color}'] {
|
|
54
|
-
@if $color == 'invert-neutral'{
|
|
55
|
-
color
|
|
54
|
+
@if $color == 'invert-neutral' {
|
|
55
|
+
color: $sys-invert-neutral-text-main;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
@else {
|
|
59
59
|
color: simple-var($theme-variables, 'sys', $color, 'on-accent');
|
|
60
60
|
}
|
|
61
61
|
}
|
|
@@ -69,11 +69,11 @@ $colors: 'invert-neutral', 'primary', 'red', 'yellow', 'green';
|
|
|
69
69
|
|
|
70
70
|
@each $color in $colors {
|
|
71
71
|
&[data-color='#{$color}'] {
|
|
72
|
-
@if $color == 'invert-neutral'{
|
|
73
|
-
color
|
|
72
|
+
@if $color == 'invert-neutral' {
|
|
73
|
+
color: $sys-invert-neutral-text-main;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
@else {
|
|
77
77
|
color: simple-var($theme-variables, 'sys', $color, 'on-accent');
|
|
78
78
|
}
|
|
79
79
|
}
|
|
@@ -85,15 +85,14 @@ $colors: 'invert-neutral', 'primary', 'red', 'yellow', 'green';
|
|
|
85
85
|
gap: $dimension-2m;
|
|
86
86
|
align-items: center;
|
|
87
87
|
min-width: 0;
|
|
88
|
-
}
|
|
89
|
-
|
|
88
|
+
}
|
|
90
89
|
|
|
91
90
|
.contentLayout {
|
|
92
91
|
@include composite-var($alert-top-container-content-layout);
|
|
93
92
|
|
|
94
93
|
display: flex;
|
|
95
94
|
flex-direction: column;
|
|
96
|
-
min-width: 0;
|
|
95
|
+
min-width: 0;
|
|
97
96
|
}
|
|
98
97
|
|
|
99
98
|
.textLayout {
|
|
@@ -105,56 +104,3 @@ $colors: 'invert-neutral', 'primary', 'red', 'yellow', 'green';
|
|
|
105
104
|
gap: $dimension-2m;
|
|
106
105
|
align-items: center;
|
|
107
106
|
}
|
|
108
|
-
|
|
109
|
-
.closeButton {
|
|
110
|
-
@include composite-var($alert-top-button-button-close);
|
|
111
|
-
|
|
112
|
-
cursor: pointer;
|
|
113
|
-
|
|
114
|
-
display: flex;
|
|
115
|
-
align-items: center;
|
|
116
|
-
justify-content: center;
|
|
117
|
-
|
|
118
|
-
box-sizing: border-box;
|
|
119
|
-
margin: 0;
|
|
120
|
-
padding: 0;
|
|
121
|
-
|
|
122
|
-
background: none;
|
|
123
|
-
border: none;
|
|
124
|
-
|
|
125
|
-
svg {
|
|
126
|
-
width: $icon-s !important; /* stylelint-disable-line declaration-no-important */
|
|
127
|
-
height: $icon-s !important; /* stylelint-disable-line declaration-no-important */
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
@each $color in $colors {
|
|
131
|
-
&[data-color='#{$color}'] {
|
|
132
|
-
@if $color == 'invert-neutral'{
|
|
133
|
-
color: $sys-invert-neutral-text-main;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
@else {
|
|
137
|
-
color: simple-var($theme-variables, 'sys', $color, 'on-accent');
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
background-color: inherit;
|
|
141
|
-
|
|
142
|
-
&:hover {
|
|
143
|
-
opacity: unset;
|
|
144
|
-
background-color: $sys-opacity-hovered;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
&:focus-visible {
|
|
148
|
-
@include outline-var($container-focused-s);
|
|
149
|
-
|
|
150
|
-
opacity: unset;
|
|
151
|
-
background-color: $sys-opacity-hovered;
|
|
152
|
-
outline-color: $sys-available-on-complementary;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
&:active {
|
|
156
|
-
background-color: $sys-opacity-activated;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { MouseEvent, ReactElement } from 'react';
|
|
2
|
+
|
|
3
|
+
import { LinkProps } from '@snack-uikit/link';
|
|
4
|
+
|
|
5
|
+
import styles from './styles.module.scss';
|
|
6
|
+
|
|
7
|
+
type PrivateAlertButtonProps = {
|
|
8
|
+
/** Внешний вид */
|
|
9
|
+
appearance?: LinkProps['appearance'] | 'invert-neutral';
|
|
10
|
+
/** Текст кнопки */
|
|
11
|
+
text?: string;
|
|
12
|
+
/** Иконка в кнопке */
|
|
13
|
+
icon?: ReactElement;
|
|
14
|
+
/** Вариант отображения */
|
|
15
|
+
variant?: 'simple' | 'tonal';
|
|
16
|
+
/** Колбек клика */
|
|
17
|
+
onClick?(e: MouseEvent<HTMLButtonElement>): void;
|
|
18
|
+
/** Дата тест айди */
|
|
19
|
+
dataTestId?: string;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type AlertButtonProps = Omit<PrivateAlertButtonProps, 'appearance' | 'variant'>;
|
|
23
|
+
|
|
24
|
+
export function AlertButton({
|
|
25
|
+
appearance,
|
|
26
|
+
text,
|
|
27
|
+
icon,
|
|
28
|
+
onClick,
|
|
29
|
+
variant = 'simple',
|
|
30
|
+
dataTestId,
|
|
31
|
+
}: PrivateAlertButtonProps) {
|
|
32
|
+
return (
|
|
33
|
+
<button
|
|
34
|
+
onClick={onClick}
|
|
35
|
+
className={styles.alertButton}
|
|
36
|
+
data-variant={variant}
|
|
37
|
+
data-appearance={appearance}
|
|
38
|
+
data-test-id={dataTestId || 'alert__action-button'}
|
|
39
|
+
data-icon-only={!text || undefined}
|
|
40
|
+
>
|
|
41
|
+
{text && <span className={styles.text}>{text}</span>}
|
|
42
|
+
{icon && <span className={styles.icon}>{icon}</span>}
|
|
43
|
+
</button>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
@import '@snack-uikit/figma-tokens/build/scss/components/styles-tokens-alert';
|
|
2
|
+
@import '@snack-uikit/figma-tokens/build/scss/components/styles-tokens-alert-alertTop';
|
|
3
|
+
@import '@snack-uikit/figma-tokens/build/scss/components/styles-tokens-element';
|
|
4
|
+
|
|
5
|
+
$simpleAppearances: 'neutral', 'primary', 'red', 'yellow', 'green';
|
|
6
|
+
$tonalAppearances: 'invert-neutral', 'primary', 'red', 'yellow', 'green';
|
|
7
|
+
|
|
8
|
+
.alertButton {
|
|
9
|
+
cursor: pointer;
|
|
10
|
+
|
|
11
|
+
display: flex;
|
|
12
|
+
align-items: center;
|
|
13
|
+
justify-content: center;
|
|
14
|
+
|
|
15
|
+
box-sizing: border-box;
|
|
16
|
+
margin: 0;
|
|
17
|
+
padding: 0;
|
|
18
|
+
|
|
19
|
+
white-space: nowrap;
|
|
20
|
+
|
|
21
|
+
background: none;
|
|
22
|
+
border: 0;
|
|
23
|
+
|
|
24
|
+
.text {
|
|
25
|
+
@include composite-var($sans-label-l);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.icon {
|
|
29
|
+
display: inline-flex;
|
|
30
|
+
align-items: center;
|
|
31
|
+
justify-content: center;
|
|
32
|
+
|
|
33
|
+
width: $icon-s;
|
|
34
|
+
height: $icon-s;
|
|
35
|
+
|
|
36
|
+
svg {
|
|
37
|
+
max-width: $icon-s;
|
|
38
|
+
max-height: $icon-s;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.alertButton[data-variant='simple'] {
|
|
44
|
+
@include composite-var($alert-button-button-action);
|
|
45
|
+
|
|
46
|
+
&[data-icon-only] {
|
|
47
|
+
@include composite-var($alert-button-button-close);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
&:focus-visible {
|
|
51
|
+
@include outline-var($container-focused-s);
|
|
52
|
+
|
|
53
|
+
outline-color: $sys-available-complementary;
|
|
54
|
+
outline-offset: $spacing-state-focus-offset;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@each $appearance in $simpleAppearances {
|
|
58
|
+
&[data-appearance='#{$appearance}'] {
|
|
59
|
+
color: simple-var($theme-variables, 'sys', $appearance, 'text-support');
|
|
60
|
+
|
|
61
|
+
&:hover,
|
|
62
|
+
&:focus-visible {
|
|
63
|
+
color: simple-var($theme-variables, 'sys', $appearance, 'text-light');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
&:active {
|
|
67
|
+
color: simple-var($theme-variables, 'sys', $appearance, 'text-main');
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.alertButton[data-variant='tonal'] {
|
|
74
|
+
@include composite-var($alert-top-button-button-action);
|
|
75
|
+
|
|
76
|
+
background: $sys-opacity-enabled;
|
|
77
|
+
|
|
78
|
+
&[data-icon-only] {
|
|
79
|
+
@include composite-var($alert-top-button-button-close);
|
|
80
|
+
|
|
81
|
+
background: none;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
&:hover {
|
|
85
|
+
opacity: unset;
|
|
86
|
+
background-color: $sys-opacity-hovered;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
&:focus-visible {
|
|
90
|
+
@include outline-var($container-focused-s);
|
|
91
|
+
|
|
92
|
+
background-color: $sys-opacity-hovered;
|
|
93
|
+
outline-color: $sys-available-on-complementary;
|
|
94
|
+
}
|
|
95
|
+
&:active {
|
|
96
|
+
background-color: $sys-opacity-activated;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
@each $appearance in $tonalAppearances {
|
|
100
|
+
&[data-appearance='#{$appearance}'] {
|
|
101
|
+
@if $appearance == 'invert-neutral' {
|
|
102
|
+
color: simple-var($theme-variables, 'sys', $appearance, 'text-main');
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
@else {
|
|
106
|
+
color: simple-var($theme-variables, 'sys', $appearance, 'on-accent');
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { MouseEvent, ReactElement } from 'react';
|
|
2
|
-
import { Appearance } from '../../types';
|
|
3
|
-
export type AlertButtonProps = {
|
|
4
|
-
appearance: Appearance;
|
|
5
|
-
label: string;
|
|
6
|
-
icon?: ReactElement;
|
|
7
|
-
onClick(e: MouseEvent<HTMLButtonElement>): void;
|
|
8
|
-
};
|
|
9
|
-
export declare function AlertButton({ appearance, label, icon, onClick }: AlertButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { APPEARANCE_TO_COLOR_MAP } from '../../constants';
|
|
3
|
-
import styles from './styles.module.css';
|
|
4
|
-
export function AlertButton({ appearance, label, icon, onClick }) {
|
|
5
|
-
return (_jsxs("button", { onClick: onClick, className: styles.alertButton, "data-color": APPEARANCE_TO_COLOR_MAP[appearance], "data-test-id": 'alert__action-button', children: [_jsx("span", { children: label }), icon] }));
|
|
6
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './AlertButton';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './AlertButton';
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
.alertButton{
|
|
2
|
-
height:var(--size-alert-button, 24px);
|
|
3
|
-
gap:var(--space-alert-button-gap, 4px);
|
|
4
|
-
border-radius:var(--radius-alert-button, 8px);
|
|
5
|
-
font-family:var(--sans-label-l-font-family, SB Sans Interface);
|
|
6
|
-
font-weight:var(--sans-label-l-font-weight, Semibold);
|
|
7
|
-
line-height:var(--sans-label-l-line-height, 20px);
|
|
8
|
-
font-size:var(--sans-label-l-font-size, 14px);
|
|
9
|
-
letter-spacing:var(--sans-label-l-letter-spacing, -0.1px);
|
|
10
|
-
paragraph-spacing:var(--sans-label-l-paragraph-spacing, 7.7px);
|
|
11
|
-
cursor:pointer;
|
|
12
|
-
display:flex;
|
|
13
|
-
align-items:center;
|
|
14
|
-
box-sizing:border-box;
|
|
15
|
-
margin:0;
|
|
16
|
-
white-space:nowrap;
|
|
17
|
-
background:none;
|
|
18
|
-
border:0;
|
|
19
|
-
}
|
|
20
|
-
.alertButton svg{
|
|
21
|
-
width:var(--size-icon-container-s, 24px) !important;
|
|
22
|
-
height:var(--size-icon-container-s, 24px) !important;
|
|
23
|
-
}
|
|
24
|
-
.alertButton:focus-visible{
|
|
25
|
-
outline-width:var(--border-state-focus-s-border-width, 2px);
|
|
26
|
-
outline-style:var(--border-state-focus-s-border-style, solid);
|
|
27
|
-
outline-color:var(--border-state-focus-s-border-color, );
|
|
28
|
-
outline-color:var(--sys-available-complementary, #141415);
|
|
29
|
-
outline-offset:var(--spacing-state-focus-offset, 2px);
|
|
30
|
-
}
|
|
31
|
-
.alertButton[data-color=neutral]{
|
|
32
|
-
color:var(--sys-neutral-text-support, #656771);
|
|
33
|
-
}
|
|
34
|
-
.alertButton[data-color=neutral]:hover, .alertButton[data-color=neutral]:focus-visible{
|
|
35
|
-
color:var(--sys-neutral-text-light, #868892);
|
|
36
|
-
}
|
|
37
|
-
.alertButton[data-color=neutral]:active{
|
|
38
|
-
color:var(--sys-neutral-text-main, #33333b);
|
|
39
|
-
}
|
|
40
|
-
.alertButton[data-color=primary]{
|
|
41
|
-
color:var(--sys-primary-text-support, #5b4796);
|
|
42
|
-
}
|
|
43
|
-
.alertButton[data-color=primary]:hover, .alertButton[data-color=primary]:focus-visible{
|
|
44
|
-
color:var(--sys-primary-text-light, #997adc);
|
|
45
|
-
}
|
|
46
|
-
.alertButton[data-color=primary]:active{
|
|
47
|
-
color:var(--sys-primary-text-main, #382a62);
|
|
48
|
-
}
|
|
49
|
-
.alertButton[data-color=red]{
|
|
50
|
-
color:var(--sys-red-text-support, #ab423e);
|
|
51
|
-
}
|
|
52
|
-
.alertButton[data-color=red]:hover, .alertButton[data-color=red]:focus-visible{
|
|
53
|
-
color:var(--sys-red-text-light, #ea6658);
|
|
54
|
-
}
|
|
55
|
-
.alertButton[data-color=red]:active{
|
|
56
|
-
color:var(--sys-red-text-main, #621c1b);
|
|
57
|
-
}
|
|
58
|
-
.alertButton[data-color=yellow]{
|
|
59
|
-
color:var(--sys-yellow-text-support, #a57b0e);
|
|
60
|
-
}
|
|
61
|
-
.alertButton[data-color=yellow]:hover, .alertButton[data-color=yellow]:focus-visible{
|
|
62
|
-
color:var(--sys-yellow-text-light, #ddb035);
|
|
63
|
-
}
|
|
64
|
-
.alertButton[data-color=yellow]:active{
|
|
65
|
-
color:var(--sys-yellow-text-main, #5e3d06);
|
|
66
|
-
}
|
|
67
|
-
.alertButton[data-color=green]{
|
|
68
|
-
color:var(--sys-green-text-support, #568a56);
|
|
69
|
-
}
|
|
70
|
-
.alertButton[data-color=green]:hover, .alertButton[data-color=green]:focus-visible{
|
|
71
|
-
color:var(--sys-green-text-light, #67ba6e);
|
|
72
|
-
}
|
|
73
|
-
.alertButton[data-color=green]:active{
|
|
74
|
-
color:var(--sys-green-text-main, #323f27);
|
|
75
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
import { Appearance } from '../../types';
|
|
3
|
-
export type AlertTopButtonProps = {
|
|
4
|
-
appearance: Appearance;
|
|
5
|
-
buttonText: string;
|
|
6
|
-
buttonIcon?: ReactElement;
|
|
7
|
-
buttonOnClick?: () => void;
|
|
8
|
-
};
|
|
9
|
-
export declare function AlertTopButton({ appearance, buttonText, buttonIcon, buttonOnClick }: AlertTopButtonProps): import("react/jsx-runtime").JSX.Element;
|