@cloud-ru/uikit-product-mobile-modal 0.9.18
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 +1060 -0
- package/LICENSE +201 -0
- package/README.md +8 -0
- package/package.json +52 -0
- package/src/components/AdaptiveDrawer/AdaptiveDrawer.tsx +37 -0
- package/src/components/AdaptiveDrawer/index.ts +1 -0
- package/src/components/AdaptiveModal/AdaptiveModal.tsx +31 -0
- package/src/components/AdaptiveModal/index.ts +1 -0
- package/src/components/MobileModal/MobileModal.tsx +169 -0
- package/src/components/MobileModal/index.ts +1 -0
- package/src/components/MobileModal/styles.module.scss +27 -0
- package/src/components/MobileModalCustom/MobileModalCustom.tsx +61 -0
- package/src/components/MobileModalCustom/index.ts +1 -0
- package/src/components/index.ts +4 -0
- package/src/constants.ts +41 -0
- package/src/helperComponents/Body/Body.tsx +29 -0
- package/src/helperComponents/Body/index.ts +1 -0
- package/src/helperComponents/Body/styles.module.scss +15 -0
- package/src/helperComponents/Footer/Footer.tsx +37 -0
- package/src/helperComponents/Footer/index.ts +1 -0
- package/src/helperComponents/Footer/styles.module.scss +46 -0
- package/src/helperComponents/Header/Header.tsx +54 -0
- package/src/helperComponents/Header/index.ts +2 -0
- package/src/helperComponents/Header/styles.module.scss +64 -0
- package/src/helperComponents/Header/types.ts +4 -0
- package/src/helperComponents/index.ts +3 -0
- package/src/index.ts +1 -0
- package/src/types.ts +11 -0
- package/src/utils.ts +28 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import cn from 'classnames';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
import { MobileDrawerCustom } from '@cloud-ru/uikit-product-mobile-drawer';
|
|
5
|
+
import { extractSupportProps, WithSupportProps } from '@snack-uikit/utils';
|
|
6
|
+
|
|
7
|
+
import { CONTENT_ALIGN, TEST_IDS } from '../../constants';
|
|
8
|
+
import { ContentAlign } from '../../types';
|
|
9
|
+
import styles from './styles.module.scss';
|
|
10
|
+
|
|
11
|
+
export type ModalBodyProps = WithSupportProps<{
|
|
12
|
+
/** Содержимое модального окна */
|
|
13
|
+
content: ReactNode;
|
|
14
|
+
/** Выравнивание контента */
|
|
15
|
+
align?: ContentAlign;
|
|
16
|
+
className?: string;
|
|
17
|
+
}>;
|
|
18
|
+
|
|
19
|
+
export function ModalBody({ content, align = CONTENT_ALIGN.Default, className, ...rest }: ModalBodyProps) {
|
|
20
|
+
return (
|
|
21
|
+
<MobileDrawerCustom.Body
|
|
22
|
+
content={content}
|
|
23
|
+
className={cn(styles.modalBody, className)}
|
|
24
|
+
{...extractSupportProps(rest)}
|
|
25
|
+
data-align={align}
|
|
26
|
+
data-test-id={TEST_IDS.content}
|
|
27
|
+
/>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Body';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
@use '@sbercloud/figma-tokens-cloud-platform/build/scss/components/styles-tokens-modal';
|
|
2
|
+
|
|
3
|
+
.modalBody {
|
|
4
|
+
@include styles-tokens-modal.composite-var(styles-tokens-modal.$sans-body-m);
|
|
5
|
+
padding: styles-tokens-modal.$dimension-3m styles-tokens-modal.$dimension-2m;
|
|
6
|
+
|
|
7
|
+
flex: 1 1 auto;
|
|
8
|
+
box-sizing: border-box;
|
|
9
|
+
min-height: styles-tokens-modal.$dimension-2m;
|
|
10
|
+
color: styles-tokens-modal.$sys-neutral-text-main;
|
|
11
|
+
|
|
12
|
+
&[data-align='center'] {
|
|
13
|
+
text-align: center;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import cn from 'classnames';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
import { extractSupportProps, WithSupportProps } from '@snack-uikit/utils';
|
|
5
|
+
|
|
6
|
+
import { ALIGN, TEST_IDS } from '../../constants';
|
|
7
|
+
import { Align } from '../../types';
|
|
8
|
+
import styles from './styles.module.scss';
|
|
9
|
+
|
|
10
|
+
export type ModalFooterProps = WithSupportProps<{
|
|
11
|
+
/** Параметр для передачи кнопок */
|
|
12
|
+
actions: ReactNode;
|
|
13
|
+
/** Параметр для небольшого текста под кнопками */
|
|
14
|
+
disclaimer?: ReactNode;
|
|
15
|
+
/** Выравнивание контента */
|
|
16
|
+
align?: Align;
|
|
17
|
+
className?: string;
|
|
18
|
+
}>;
|
|
19
|
+
|
|
20
|
+
export function ModalFooter({ actions, disclaimer, align = ALIGN.Default, className, ...rest }: ModalFooterProps) {
|
|
21
|
+
return (
|
|
22
|
+
<div
|
|
23
|
+
data-align={align}
|
|
24
|
+
className={cn(styles.footer, className)}
|
|
25
|
+
{...extractSupportProps(rest)}
|
|
26
|
+
data-test-id={TEST_IDS.footer}
|
|
27
|
+
>
|
|
28
|
+
<div className={styles.footerActions}>{actions}</div>
|
|
29
|
+
|
|
30
|
+
{disclaimer && (
|
|
31
|
+
<div className={styles.footerDisclaimer} data-test-id={TEST_IDS.disclaimer}>
|
|
32
|
+
{disclaimer}
|
|
33
|
+
</div>
|
|
34
|
+
)}
|
|
35
|
+
</div>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Footer';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
@use '@sbercloud/figma-tokens-cloud-platform/build/scss/components/styles-tokens-modal';
|
|
2
|
+
|
|
3
|
+
.footerActions {
|
|
4
|
+
@include styles-tokens-modal.composite-var(styles-tokens-modal.$modal, 'action-row');
|
|
5
|
+
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: row-reverse;
|
|
8
|
+
flex-wrap: wrap-reverse;
|
|
9
|
+
align-items: center;
|
|
10
|
+
justify-content: center;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.footerDisclaimer {
|
|
14
|
+
display: flex;
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
align-items: flex-end;
|
|
17
|
+
color: styles-tokens-modal.simple-var(styles-tokens-modal.$sys-neutral-text-disabled);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.footer {
|
|
21
|
+
padding: 0 styles-tokens-modal.$dimension-2m styles-tokens-modal.$dimension-3m styles-tokens-modal.$dimension-2m;
|
|
22
|
+
gap: styles-tokens-modal.$dimension-2m;
|
|
23
|
+
|
|
24
|
+
display: flex;
|
|
25
|
+
flex-direction: column;
|
|
26
|
+
|
|
27
|
+
&[data-align='vertical'] {
|
|
28
|
+
align-items: center;
|
|
29
|
+
|
|
30
|
+
.footerActions {
|
|
31
|
+
width: 100%;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.footerDisclaimer {
|
|
35
|
+
align-items: center;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&[data-align='center'] {
|
|
40
|
+
align-items: center;
|
|
41
|
+
|
|
42
|
+
.footerDisclaimer {
|
|
43
|
+
align-items: center;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import cn from 'classnames';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
import { MobileQuestionTooltip, MobileQuestionTooltipProps } from '@cloud-ru/uikit-product-mobile-tooltip';
|
|
5
|
+
import { Typography } from '@snack-uikit/typography';
|
|
6
|
+
import { extractSupportProps, WithSupportProps } from '@snack-uikit/utils';
|
|
7
|
+
|
|
8
|
+
import { CONTENT_ALIGN, TEST_IDS } from '../../constants';
|
|
9
|
+
import { ContentAlign } from '../../types';
|
|
10
|
+
import styles from './styles.module.scss';
|
|
11
|
+
|
|
12
|
+
export type ModalHeaderProps = WithSupportProps<{
|
|
13
|
+
/** Заголовок модального окна */
|
|
14
|
+
title: ReactNode;
|
|
15
|
+
/** Тултип для заголовка */
|
|
16
|
+
titleTooltip?: MobileQuestionTooltipProps['tip'];
|
|
17
|
+
/** Подзаголовок */
|
|
18
|
+
subtitle?: ReactNode;
|
|
19
|
+
/** Выравнивание контента */
|
|
20
|
+
align?: ContentAlign;
|
|
21
|
+
className?: string;
|
|
22
|
+
}>;
|
|
23
|
+
|
|
24
|
+
export function ModalHeader({
|
|
25
|
+
title,
|
|
26
|
+
titleTooltip,
|
|
27
|
+
subtitle,
|
|
28
|
+
align = CONTENT_ALIGN.Default,
|
|
29
|
+
className,
|
|
30
|
+
...rest
|
|
31
|
+
}: ModalHeaderProps) {
|
|
32
|
+
return (
|
|
33
|
+
<div className={cn(styles.header, className)} {...extractSupportProps(rest)} data-test-id={TEST_IDS.header}>
|
|
34
|
+
<div className={styles.headlineLayout} data-align={align}>
|
|
35
|
+
<div className={styles.headline}>
|
|
36
|
+
<Typography.SansHeadlineS className={styles.title} data-test-id={TEST_IDS.title}>
|
|
37
|
+
{title}
|
|
38
|
+
{titleTooltip && (
|
|
39
|
+
<span className={styles.questionTooltip}>
|
|
40
|
+
<MobileQuestionTooltip tip={titleTooltip} size='s' data-test-id={TEST_IDS.tooltip} />
|
|
41
|
+
</span>
|
|
42
|
+
)}
|
|
43
|
+
</Typography.SansHeadlineS>
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
{subtitle && (
|
|
47
|
+
<Typography.SansBodyM className={styles.subtitle} data-test-id={TEST_IDS.subtitle}>
|
|
48
|
+
{subtitle}
|
|
49
|
+
</Typography.SansBodyM>
|
|
50
|
+
)}
|
|
51
|
+
</div>
|
|
52
|
+
</div>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
@use '@sbercloud/figma-tokens-cloud-platform/build/scss/components/styles-tokens-modal';
|
|
2
|
+
|
|
3
|
+
$aligns: 'default', 'center';
|
|
4
|
+
|
|
5
|
+
.header {
|
|
6
|
+
/* stub for proper typings */
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.title {
|
|
10
|
+
display: inline;
|
|
11
|
+
color: styles-tokens-modal.$sys-neutral-text-main;
|
|
12
|
+
word-break: break-word;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.subtitle {
|
|
16
|
+
color: styles-tokens-modal.$sys-neutral-text-support;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.questionTooltip {
|
|
20
|
+
display: inline-flex;
|
|
21
|
+
height: styles-tokens-modal.$dimension-4m;
|
|
22
|
+
padding-left: 4px;
|
|
23
|
+
|
|
24
|
+
> span {
|
|
25
|
+
transform: translate(0, 4px);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.image {
|
|
30
|
+
@include styles-tokens-modal.composite-var(styles-tokens-modal.$modal, 'image');
|
|
31
|
+
|
|
32
|
+
display: block;
|
|
33
|
+
width: 100%;
|
|
34
|
+
object-fit: cover;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.icon {
|
|
38
|
+
@include styles-tokens-modal.composite-var(styles-tokens-modal.$modal, 'icon-decor');
|
|
39
|
+
|
|
40
|
+
display: flex;
|
|
41
|
+
justify-content: center;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.headlineLayout {
|
|
45
|
+
padding: styles-tokens-modal.$dimension-3m styles-tokens-modal.$dimension-2m 0;
|
|
46
|
+
gap: styles-tokens-modal.$dimension-1m;
|
|
47
|
+
display: flex;
|
|
48
|
+
flex-direction: column;
|
|
49
|
+
|
|
50
|
+
&[data-align="center"] {
|
|
51
|
+
align-items: center;
|
|
52
|
+
|
|
53
|
+
.title, .subtitle {
|
|
54
|
+
text-align: center;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.headline {
|
|
60
|
+
@include styles-tokens-modal.composite-var(styles-tokens-modal.$modal-headline);
|
|
61
|
+
|
|
62
|
+
display: flex;
|
|
63
|
+
align-items: center;
|
|
64
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components';
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ValueOf } from '@snack-uikit/utils';
|
|
2
|
+
|
|
3
|
+
import { ALIGN, CONTENT_ALIGN, MODE, SIZE } from './constants';
|
|
4
|
+
|
|
5
|
+
export type Size = ValueOf<typeof SIZE>;
|
|
6
|
+
|
|
7
|
+
export type Mode = ValueOf<typeof MODE>;
|
|
8
|
+
|
|
9
|
+
export type Align = ValueOf<typeof ALIGN>;
|
|
10
|
+
|
|
11
|
+
export type ContentAlign = ValueOf<typeof CONTENT_ALIGN>;
|
package/src/utils.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ALIGN, CONTENT_ALIGN } from './constants';
|
|
2
|
+
import { Align } from './types';
|
|
3
|
+
|
|
4
|
+
const MAP_ALIGNS = {
|
|
5
|
+
[ALIGN.Default]: {
|
|
6
|
+
header: CONTENT_ALIGN.Default,
|
|
7
|
+
body: CONTENT_ALIGN.Default,
|
|
8
|
+
footer: ALIGN.Vertical,
|
|
9
|
+
},
|
|
10
|
+
[ALIGN.Center]: {
|
|
11
|
+
header: CONTENT_ALIGN.Center,
|
|
12
|
+
body: CONTENT_ALIGN.Center,
|
|
13
|
+
footer: ALIGN.Center,
|
|
14
|
+
},
|
|
15
|
+
[ALIGN.Vertical]: {
|
|
16
|
+
header: CONTENT_ALIGN.Center,
|
|
17
|
+
body: CONTENT_ALIGN.Center,
|
|
18
|
+
footer: ALIGN.Vertical,
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export function getAlignProps({ align }: { align: Align }) {
|
|
23
|
+
return MAP_ALIGNS[align];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function getButtonsSize() {
|
|
27
|
+
return 'm' as const;
|
|
28
|
+
}
|