@cloud-ru/uikit-product-mobile-alert 0.4.64

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.
@@ -0,0 +1,51 @@
1
+ import { MouseEvent, ReactElement } from 'react';
2
+
3
+ import { LinkProps } from '@snack-uikit/link';
4
+ import { Sun } from '@snack-uikit/loaders';
5
+
6
+ import { Size } from '../types';
7
+ import styles from './styles.module.scss';
8
+
9
+ type PrivateAlertButtonProps = {
10
+ /** Внешний вид */
11
+ appearance?: LinkProps['appearance'] | 'invert-neutral';
12
+ /** Текст кнопки */
13
+ text?: string;
14
+ /** Иконка в кнопке */
15
+ icon?: ReactElement;
16
+ /** Вариант отображения */
17
+ variant?: 'simple' | 'tonal';
18
+ /** Колбек клика */
19
+ onClick?(e: MouseEvent<HTMLButtonElement>): void;
20
+ /** Дата тест айди */
21
+ dataTestId?: string;
22
+ /** Управление состоянием загрузки */
23
+ loading?: boolean;
24
+ /** Размер */
25
+ size?: Size;
26
+ };
27
+
28
+ export type AlertButtonProps = Omit<PrivateAlertButtonProps, 'appearance' | 'variant'>;
29
+
30
+ export function AlertButton({ appearance, text, icon, onClick, dataTestId, loading = false }: PrivateAlertButtonProps) {
31
+ return (
32
+ <button
33
+ type='button'
34
+ onClick={onClick}
35
+ className={styles.alertButton}
36
+ data-variant='tonal'
37
+ data-appearance={appearance}
38
+ data-test-id={dataTestId || 'alert__action-button'}
39
+ data-icon-only={!text || undefined}
40
+ data-loading={loading}
41
+ data-size='m'
42
+ >
43
+ {text && (
44
+ <span className={styles.text} data-size='m'>
45
+ {text}
46
+ </span>
47
+ )}
48
+ {icon && (loading ? <Sun size='s' /> : <span className={styles.icon}>{icon}</span>)}
49
+ </button>
50
+ );
51
+ }
@@ -0,0 +1 @@
1
+ export * from './AlertButton';
@@ -0,0 +1,89 @@
1
+ @use '@sbercloud/figma-tokens-cloud-platform/build/scss/components/styles-tokens-alert-alertTop';
2
+ @use '@sbercloud/figma-tokens-cloud-platform/build/scss/components/styles-tokens-element';
3
+
4
+ $simpleAppearances: 'neutral', 'primary', 'red', 'yellow', 'green', 'blue';
5
+ $tonalAppearances: 'invert-neutral', 'primary', 'red', 'yellow', 'green', 'blue';
6
+
7
+ .alertButton {
8
+ cursor: pointer;
9
+
10
+ display: flex;
11
+ align-items: center;
12
+ justify-content: center;
13
+
14
+ box-sizing: border-box;
15
+ margin: 0;
16
+ padding: 0;
17
+
18
+ white-space: nowrap;
19
+
20
+ background: none;
21
+ border: 0;
22
+
23
+ .text {
24
+ &[data-size='m'] {
25
+ @include styles-tokens-element.composite-var(styles-tokens-element.$theme-variables, 'sans', 'label', 'l')
26
+ }
27
+ }
28
+
29
+ .icon {
30
+ display: inline-flex;
31
+ align-items: center;
32
+ justify-content: center;
33
+
34
+ width: styles-tokens-element.$icon-s;
35
+ height: styles-tokens-element.$icon-s;
36
+
37
+ svg {
38
+ max-width: styles-tokens-element.$icon-s;
39
+ max-height: styles-tokens-element.$icon-s;
40
+ }
41
+ }
42
+
43
+ &[data-loading='true'] {
44
+ cursor: not-allowed;
45
+
46
+ > * {
47
+ cursor: not-allowed;
48
+ }
49
+ }
50
+
51
+ &[data-variant='tonal'] {
52
+ @include styles-tokens-element.composite-var(styles-tokens-alert-alertTop.$alert-top-button-button-action);
53
+
54
+ background: styles-tokens-element.$sys-opacity-enabled;
55
+
56
+ &[data-icon-only] {
57
+ @include styles-tokens-element.composite-var(styles-tokens-alert-alertTop.$alert-top-button-button-close);
58
+ height: styles-tokens-element.$dimension-5m;
59
+ width: styles-tokens-element.$dimension-5m;
60
+
61
+ background: none;
62
+ }
63
+
64
+ &:hover {
65
+ opacity: unset;
66
+ background-color: styles-tokens-element.$sys-opacity-hovered;
67
+ }
68
+
69
+ &:focus-visible {
70
+ @include styles-tokens-element.outline-var(styles-tokens-element.$container-focused-s);
71
+
72
+ background-color: styles-tokens-element.$sys-opacity-hovered;
73
+ outline-color: styles-tokens-element.$sys-available-on-complementary;
74
+ }
75
+ &:active {
76
+ background-color: styles-tokens-element.$sys-opacity-activated;
77
+ }
78
+
79
+ @each $appearance in $tonalAppearances {
80
+ &[data-appearance='#{$appearance}'] {
81
+ @if $appearance == 'invert-neutral' {
82
+ color: styles-tokens-element.simple-var(styles-tokens-element.$theme-variables, 'sys', $appearance, 'text-main');
83
+ } @else {
84
+ color: styles-tokens-element.simple-var(styles-tokens-element.$theme-variables, 'sys', $appearance, 'on-accent');
85
+ }
86
+ }
87
+ }
88
+ }
89
+ }
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './components';
package/src/types.ts ADDED
@@ -0,0 +1,7 @@
1
+ import { ValueOf } from '@snack-uikit/utils';
2
+
3
+ import { APPEARANCE, SIZE } from './constants';
4
+
5
+ export type Appearance = ValueOf<typeof APPEARANCE>;
6
+
7
+ export type Size = ValueOf<typeof SIZE>;