@alfalab/core-components-navigation-bar-private 0.1.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/Component.d.ts +5 -0
- package/Component.js +165 -0
- package/components/back-arrow-addon/Component.d.ts +26 -0
- package/components/back-arrow-addon/Component.js +35 -0
- package/components/back-arrow-addon/index.css +76 -0
- package/components/back-arrow-addon/index.d.ts +1 -0
- package/components/back-arrow-addon/index.js +9 -0
- package/components/closer/Component.d.ts +35 -0
- package/components/closer/Component.js +32 -0
- package/components/closer/index.css +48 -0
- package/components/closer/index.d.ts +1 -0
- package/components/closer/index.js +9 -0
- package/cssm/Component.d.ts +5 -0
- package/cssm/Component.js +164 -0
- package/cssm/components/back-arrow-addon/Component.d.ts +26 -0
- package/cssm/components/back-arrow-addon/Component.js +34 -0
- package/cssm/components/back-arrow-addon/index.d.ts +1 -0
- package/cssm/components/back-arrow-addon/index.js +9 -0
- package/cssm/components/back-arrow-addon/index.module.css +75 -0
- package/cssm/components/closer/Component.d.ts +35 -0
- package/cssm/components/closer/Component.js +31 -0
- package/cssm/components/closer/index.d.ts +1 -0
- package/cssm/components/closer/index.js +9 -0
- package/cssm/components/closer/index.module.css +47 -0
- package/cssm/index.d.ts +2 -0
- package/cssm/index.js +9 -0
- package/cssm/index.module.css +108 -0
- package/cssm/shared/index.d.ts +2 -0
- package/cssm/shared/index.js +11 -0
- package/cssm/types.d.ts +118 -0
- package/cssm/types.js +2 -0
- package/cssm/vars.css +20 -0
- package/esm/Component.d.ts +5 -0
- package/esm/Component.js +155 -0
- package/esm/components/back-arrow-addon/Component.d.ts +26 -0
- package/esm/components/back-arrow-addon/Component.js +26 -0
- package/esm/components/back-arrow-addon/index.css +76 -0
- package/esm/components/back-arrow-addon/index.d.ts +1 -0
- package/esm/components/back-arrow-addon/index.js +1 -0
- package/esm/components/closer/Component.d.ts +35 -0
- package/esm/components/closer/Component.js +23 -0
- package/esm/components/closer/index.css +48 -0
- package/esm/components/closer/index.d.ts +1 -0
- package/esm/components/closer/index.js +1 -0
- package/esm/index.css +108 -0
- package/esm/index.d.ts +2 -0
- package/esm/index.js +1 -0
- package/esm/shared/index.d.ts +2 -0
- package/esm/shared/index.js +2 -0
- package/esm/types.d.ts +118 -0
- package/esm/types.js +1 -0
- package/index.css +108 -0
- package/index.d.ts +2 -0
- package/index.js +9 -0
- package/modern/Component.d.ts +5 -0
- package/modern/Component.js +160 -0
- package/modern/components/back-arrow-addon/Component.d.ts +26 -0
- package/modern/components/back-arrow-addon/Component.js +23 -0
- package/modern/components/back-arrow-addon/index.css +76 -0
- package/modern/components/back-arrow-addon/index.d.ts +1 -0
- package/modern/components/back-arrow-addon/index.js +1 -0
- package/modern/components/closer/Component.d.ts +35 -0
- package/modern/components/closer/Component.js +20 -0
- package/modern/components/closer/index.css +48 -0
- package/modern/components/closer/index.d.ts +1 -0
- package/modern/components/closer/index.js +1 -0
- package/modern/index.css +108 -0
- package/modern/index.d.ts +2 -0
- package/modern/index.js +1 -0
- package/modern/shared/index.d.ts +2 -0
- package/modern/shared/index.js +2 -0
- package/modern/types.d.ts +118 -0
- package/modern/types.js +1 -0
- package/package.json +27 -0
- package/shared/index.d.ts +2 -0
- package/shared/index.js +11 -0
- package/shared/package.json +3 -0
- package/src/Component.tsx +284 -0
- package/src/components/back-arrow-addon/Component.tsx +79 -0
- package/src/components/back-arrow-addon/index.module.css +69 -0
- package/src/components/back-arrow-addon/index.ts +1 -0
- package/src/components/closer/Component.tsx +80 -0
- package/src/components/closer/index.module.css +32 -0
- package/src/components/closer/index.ts +1 -0
- package/src/index.module.css +118 -0
- package/src/index.ts +2 -0
- package/src/shared/index.ts +2 -0
- package/src/shared/package.json +3 -0
- package/src/types.ts +143 -0
- package/src/vars.css +9 -0
- package/types.d.ts +118 -0
- package/types.js +2 -0
package/esm/types.d.ts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { ReactNode } from "react";
|
|
4
|
+
import { BackArrowAddonProps } from "./components/back-arrow-addon/index";
|
|
5
|
+
import { CloserProps } from "./components/closer/index";
|
|
6
|
+
type NavigationBarPrivateProps = {
|
|
7
|
+
/**
|
|
8
|
+
* Контент шапки
|
|
9
|
+
*/
|
|
10
|
+
children?: ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* Заголовок шапки
|
|
13
|
+
*/
|
|
14
|
+
title?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Подзаголовок (доступен только в мобильной версии)
|
|
17
|
+
*/
|
|
18
|
+
subtitle?: ReactNode;
|
|
19
|
+
/**
|
|
20
|
+
* Размер заголовка (compact доступен только в мобильной версии)
|
|
21
|
+
*/
|
|
22
|
+
titleSize?: 'default' | 'compact';
|
|
23
|
+
/**
|
|
24
|
+
* Доп. класс для аддонов
|
|
25
|
+
*/
|
|
26
|
+
addonClassName?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Слот слева
|
|
29
|
+
*/
|
|
30
|
+
leftAddons?: ReactNode;
|
|
31
|
+
/**
|
|
32
|
+
* Слот справа
|
|
33
|
+
*/
|
|
34
|
+
rightAddons?: ReactNode;
|
|
35
|
+
/**
|
|
36
|
+
* Дополнительный класс для closer
|
|
37
|
+
*/
|
|
38
|
+
closerClassName?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Слот снизу
|
|
41
|
+
*/
|
|
42
|
+
bottomAddons?: ReactNode;
|
|
43
|
+
/**
|
|
44
|
+
* Наличие компонента крестика
|
|
45
|
+
*/
|
|
46
|
+
hasCloser?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Наличие кнопки "Назад"
|
|
49
|
+
*/
|
|
50
|
+
hasBackButton?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Дополнительный класс для правого аддона
|
|
53
|
+
*/
|
|
54
|
+
backButtonClassName?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Дополнительные пропсы для кнопки "Назад"
|
|
57
|
+
*/
|
|
58
|
+
backButtonProps?: Omit<BackArrowAddonProps, 'view' | 'textOpacity' | 'onClick'>;
|
|
59
|
+
/**
|
|
60
|
+
* Дополнительный класс
|
|
61
|
+
*/
|
|
62
|
+
className?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Дополнительный класс для контента
|
|
65
|
+
*/
|
|
66
|
+
contentClassName?: string;
|
|
67
|
+
/**
|
|
68
|
+
* Дополнительный класс для нижнего аддона
|
|
69
|
+
*/
|
|
70
|
+
bottomAddonsClassName?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Выравнивание заголовка
|
|
73
|
+
*/
|
|
74
|
+
align?: 'left' | 'center';
|
|
75
|
+
/**
|
|
76
|
+
* Обрезать ли заголовок
|
|
77
|
+
*/
|
|
78
|
+
trim?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Фиксирует шапку
|
|
81
|
+
*/
|
|
82
|
+
sticky?: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Идентификатор для систем автоматизированного тестирования
|
|
85
|
+
*/
|
|
86
|
+
dataTestId?: string;
|
|
87
|
+
/**
|
|
88
|
+
* Фоновое изображение
|
|
89
|
+
*/
|
|
90
|
+
imageUrl?: string;
|
|
91
|
+
/**
|
|
92
|
+
* Иконка closer.
|
|
93
|
+
*/
|
|
94
|
+
closerIcon?: React.ElementType;
|
|
95
|
+
/**
|
|
96
|
+
* Обработчик закрытия
|
|
97
|
+
*/
|
|
98
|
+
onClose?: CloserProps['onClose'];
|
|
99
|
+
/**
|
|
100
|
+
* обработчик клика по кнопке "назад"
|
|
101
|
+
*/
|
|
102
|
+
onBack?: () => void;
|
|
103
|
+
/**
|
|
104
|
+
* Вид шапки - мобильный или десктоп
|
|
105
|
+
*/
|
|
106
|
+
view: 'desktop' | 'mobile';
|
|
107
|
+
/**
|
|
108
|
+
* Ссылка на родительскую ноду overflow: auto
|
|
109
|
+
*/
|
|
110
|
+
scrollableParentRef?: React.RefObject<HTMLDivElement>;
|
|
111
|
+
};
|
|
112
|
+
type ContentParams = {
|
|
113
|
+
extraClassName?: string;
|
|
114
|
+
wrapperRef?: React.RefObject<HTMLDivElement>;
|
|
115
|
+
style?: React.CSSProperties;
|
|
116
|
+
hidden?: boolean;
|
|
117
|
+
};
|
|
118
|
+
export { NavigationBarPrivateProps, ContentParams };
|
package/esm/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/index.css
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/* hash: 21se8 */
|
|
2
|
+
:root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
3
|
+
} /* deprecated */ :root {
|
|
4
|
+
--color-light-text-primary: rgba(3, 3, 6, 0.88);
|
|
5
|
+
--color-light-text-secondary: rgba(4, 4, 19, 0.55); /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
6
|
+
} :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
7
|
+
} :root {
|
|
8
|
+
} :root {
|
|
9
|
+
|
|
10
|
+
/* Hard */
|
|
11
|
+
|
|
12
|
+
/* Up */
|
|
13
|
+
|
|
14
|
+
/* Hard up */
|
|
15
|
+
} :root {
|
|
16
|
+
} :root {
|
|
17
|
+
--gap-2xs: 4px;
|
|
18
|
+
--gap-s: 12px;
|
|
19
|
+
} :root {
|
|
20
|
+
} :root {
|
|
21
|
+
} .navigation-bar-private__header_16jqi {
|
|
22
|
+
width: 100%;
|
|
23
|
+
box-sizing: border-box;
|
|
24
|
+
transition: box-shadow 0.2s ease, background 0.2s ease
|
|
25
|
+
} .navigation-bar-private__header_16jqi.navigation-bar-private__header_16jqi.navigation-bar-private__backgroundImage_16jqi {
|
|
26
|
+
background-repeat: no-repeat;
|
|
27
|
+
background-position: center;
|
|
28
|
+
background-size: cover;
|
|
29
|
+
} .navigation-bar-private__mainLine_16jqi {
|
|
30
|
+
display: flex;
|
|
31
|
+
align-items: stretch;
|
|
32
|
+
justify-content: space-between;
|
|
33
|
+
z-index: 1;
|
|
34
|
+
background-color: inherit;
|
|
35
|
+
} .navigation-bar-private__mainLineSticky_16jqi {
|
|
36
|
+
position: sticky;
|
|
37
|
+
top: 0;
|
|
38
|
+
} .navigation-bar-private__mainLineWithImageBg_16jqi {
|
|
39
|
+
background-color: initial;
|
|
40
|
+
} .navigation-bar-private__content_16jqi {
|
|
41
|
+
color: var(--color-light-text-primary);
|
|
42
|
+
display: flex;
|
|
43
|
+
flex-flow: column nowrap;
|
|
44
|
+
justify-content: center;
|
|
45
|
+
flex-grow: 1;
|
|
46
|
+
align-self: baseline;
|
|
47
|
+
box-sizing: border-box;
|
|
48
|
+
min-height: 48px
|
|
49
|
+
} .navigation-bar-private__content_16jqi.navigation-bar-private__withBothAddons_16jqi,
|
|
50
|
+
.navigation-bar-private__content_16jqi.navigation-bar-private__withCompactTitle_16jqi {
|
|
51
|
+
font-size: 16px;
|
|
52
|
+
line-height: 20px;
|
|
53
|
+
font-weight: 500;
|
|
54
|
+
align-self: center;
|
|
55
|
+
padding-top: var(--gap-2xs);
|
|
56
|
+
padding-bottom: var(--gap-2xs)
|
|
57
|
+
} .navigation-bar-private__content_16jqi.navigation-bar-private__withBothAddons_16jqi > .navigation-bar-private__children_16jqi,
|
|
58
|
+
.navigation-bar-private__content_16jqi.navigation-bar-private__withBothAddons_16jqi > .navigation-bar-private__title_16jqi,
|
|
59
|
+
.navigation-bar-private__content_16jqi.navigation-bar-private__withCompactTitle_16jqi > .navigation-bar-private__children_16jqi,
|
|
60
|
+
.navigation-bar-private__content_16jqi.navigation-bar-private__withCompactTitle_16jqi > .navigation-bar-private__title_16jqi {
|
|
61
|
+
-webkit-line-clamp: 1;
|
|
62
|
+
word-break: break-all;
|
|
63
|
+
} .navigation-bar-private__content_16jqi.navigation-bar-private__contentOnBotDesktop_16jqi.navigation-bar-private__contentOnBotDesktop_16jqi {
|
|
64
|
+
padding-top: var(--gap-s);
|
|
65
|
+
} .navigation-bar-private__content_16jqi.navigation-bar-private__contentOnBotMobile_16jqi.navigation-bar-private__contentOnBotMobile_16jqi {
|
|
66
|
+
padding-top: var(--gap-s);
|
|
67
|
+
} .navigation-bar-private__title_16jqi {
|
|
68
|
+
word-break: break-word;
|
|
69
|
+
} .navigation-bar-private__subtitle_16jqi {
|
|
70
|
+
font-size: 14px;
|
|
71
|
+
line-height: 20px;
|
|
72
|
+
font-weight: 400;
|
|
73
|
+
-webkit-line-clamp: 1;
|
|
74
|
+
display: -webkit-box;
|
|
75
|
+
-webkit-box-orient: vertical;
|
|
76
|
+
overflow: hidden;
|
|
77
|
+
|
|
78
|
+
color: var(--color-light-text-secondary);
|
|
79
|
+
word-break: break-all;
|
|
80
|
+
} .navigation-bar-private__addonsWrapper_16jqi {
|
|
81
|
+
display: flex;
|
|
82
|
+
} .navigation-bar-private__rightAddons_16jqi {
|
|
83
|
+
margin-left: auto;
|
|
84
|
+
} .navigation-bar-private__addon_16jqi {
|
|
85
|
+
min-width: 48px;
|
|
86
|
+
height: 48px;
|
|
87
|
+
display: flex;
|
|
88
|
+
justify-content: center;
|
|
89
|
+
align-items: center;
|
|
90
|
+
flex-shrink: 0;
|
|
91
|
+
pointer-events: all;
|
|
92
|
+
} .navigation-bar-private__bottomAddons_16jqi {
|
|
93
|
+
pointer-events: all;
|
|
94
|
+
} .navigation-bar-private__closer_16jqi {
|
|
95
|
+
margin-left: auto;
|
|
96
|
+
} .navigation-bar-private__left_16jqi {
|
|
97
|
+
text-align: left;
|
|
98
|
+
} .navigation-bar-private__center_16jqi {
|
|
99
|
+
text-align: center;
|
|
100
|
+
} .navigation-bar-private__trim_16jqi {
|
|
101
|
+
overflow: hidden
|
|
102
|
+
} .navigation-bar-private__trim_16jqi .navigation-bar-private__title_16jqi,
|
|
103
|
+
.navigation-bar-private__trim_16jqi .navigation-bar-private__children_16jqi {
|
|
104
|
+
-webkit-line-clamp: 2;
|
|
105
|
+
display: -webkit-box;
|
|
106
|
+
-webkit-box-orient: vertical;
|
|
107
|
+
overflow: hidden;
|
|
108
|
+
}
|
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { NavigationBarPrivateProps } from "./types";
|
|
4
|
+
declare const NavigationBarPrivate: React.ForwardRefExoticComponent<NavigationBarPrivateProps & React.RefAttributes<HTMLDivElement>>;
|
|
5
|
+
export { NavigationBarPrivate };
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import React, { forwardRef, useState, useRef, useEffect } from 'react';
|
|
2
|
+
import mergeRefs from 'react-merge-refs';
|
|
3
|
+
import cn from 'classnames';
|
|
4
|
+
import { getDataTestId } from '@alfalab/core-components-shared/modern';
|
|
5
|
+
import { useLayoutEffect_SAFE_FOR_SSR } from '@alfalab/hooks';
|
|
6
|
+
import { BackArrowAddon } from './components/back-arrow-addon/Component.js';
|
|
7
|
+
import { Closer } from './components/closer/Component.js';
|
|
8
|
+
|
|
9
|
+
const styles = {"header":"navigation-bar-private__header_16jqi","backgroundImage":"navigation-bar-private__backgroundImage_16jqi","mainLine":"navigation-bar-private__mainLine_16jqi","mainLineSticky":"navigation-bar-private__mainLineSticky_16jqi","mainLineWithImageBg":"navigation-bar-private__mainLineWithImageBg_16jqi","content":"navigation-bar-private__content_16jqi","withBothAddons":"navigation-bar-private__withBothAddons_16jqi","withCompactTitle":"navigation-bar-private__withCompactTitle_16jqi","children":"navigation-bar-private__children_16jqi","title":"navigation-bar-private__title_16jqi","contentOnBotDesktop":"navigation-bar-private__contentOnBotDesktop_16jqi","contentOnBotMobile":"navigation-bar-private__contentOnBotMobile_16jqi","subtitle":"navigation-bar-private__subtitle_16jqi","addonsWrapper":"navigation-bar-private__addonsWrapper_16jqi","rightAddons":"navigation-bar-private__rightAddons_16jqi","addon":"navigation-bar-private__addon_16jqi","bottomAddons":"navigation-bar-private__bottomAddons_16jqi","closer":"navigation-bar-private__closer_16jqi","left":"navigation-bar-private__left_16jqi","center":"navigation-bar-private__center_16jqi","trim":"navigation-bar-private__trim_16jqi"};
|
|
10
|
+
require('./index.css')
|
|
11
|
+
|
|
12
|
+
/* eslint-disable complexity */
|
|
13
|
+
const ADDONS_HEIGHT = 48;
|
|
14
|
+
const NavigationBarPrivate = forwardRef(({ addonClassName, className, contentClassName, closerClassName, leftAddons, rightAddons, bottomAddons, bottomAddonsClassName, children, align = 'left', trim = true, title, titleSize = 'default', subtitle, hasCloser, hasBackButton, backButtonClassName, backButtonProps, dataTestId, imageUrl, closerIcon, onClose, view, scrollableParentRef, sticky, onBack, }, ref) => {
|
|
15
|
+
const [scrollTop, setScrollTop] = useState(0);
|
|
16
|
+
const [titleMargin, setTitleMargin] = useState({ left: 0, right: 0 });
|
|
17
|
+
const bottomContentRef = useRef(null);
|
|
18
|
+
const headerRef = useRef(null);
|
|
19
|
+
const mainLinePaddingTopRef = useRef('0px');
|
|
20
|
+
const leftAddonsRef = useRef(null);
|
|
21
|
+
const rightAddonsRef = useRef(null);
|
|
22
|
+
const compactTitle = view === 'mobile' && titleSize === 'compact';
|
|
23
|
+
const hasLeftPart = Boolean(leftAddons || hasBackButton);
|
|
24
|
+
const hasRightPart = Boolean(rightAddons || hasCloser);
|
|
25
|
+
const hasContent = Boolean(title || children);
|
|
26
|
+
const withAnimation = Boolean(view === 'mobile' && hasLeftPart && sticky && !compactTitle);
|
|
27
|
+
const showContentOnTop = hasContent && (compactTitle || !hasLeftPart);
|
|
28
|
+
const showContentOnBot = hasContent && !compactTitle && hasLeftPart;
|
|
29
|
+
const showStaticContentOnTop = !withAnimation && showContentOnTop;
|
|
30
|
+
const showStaticContentOnBot = !withAnimation && showContentOnBot;
|
|
31
|
+
const showAnimatedContentOnTop = withAnimation && showContentOnBot && scrollTop > ADDONS_HEIGHT;
|
|
32
|
+
const showAnimatedContentOnBot = withAnimation && showContentOnBot;
|
|
33
|
+
const headerPaddingTop = mainLinePaddingTopRef.current;
|
|
34
|
+
useLayoutEffect_SAFE_FOR_SSR(() => {
|
|
35
|
+
if (align === 'center' && (showStaticContentOnTop || showAnimatedContentOnTop)) {
|
|
36
|
+
const leftAddonsWidth = leftAddonsRef.current?.offsetWidth || 0;
|
|
37
|
+
const rightAddonsWidth = rightAddonsRef.current?.offsetWidth || 0;
|
|
38
|
+
const marginSize = Math.abs(rightAddonsWidth - leftAddonsWidth);
|
|
39
|
+
const shouldAddLeftMargin = rightAddonsWidth - leftAddonsWidth > 0;
|
|
40
|
+
setTitleMargin((prev) => {
|
|
41
|
+
const newState = shouldAddLeftMargin
|
|
42
|
+
? { left: marginSize, right: 0 }
|
|
43
|
+
: { left: 0, right: marginSize };
|
|
44
|
+
const isStateChanged = prev.left !== newState.left || prev.right !== newState.right;
|
|
45
|
+
return isStateChanged ? newState : prev;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}, [
|
|
49
|
+
align,
|
|
50
|
+
showStaticContentOnTop,
|
|
51
|
+
showAnimatedContentOnTop,
|
|
52
|
+
leftAddons,
|
|
53
|
+
rightAddons,
|
|
54
|
+
hasBackButton,
|
|
55
|
+
hasCloser,
|
|
56
|
+
]);
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
const parent = scrollableParentRef?.current;
|
|
59
|
+
const handleScroll = (ev) => {
|
|
60
|
+
const divElement = ev.target;
|
|
61
|
+
setScrollTop(divElement.scrollTop);
|
|
62
|
+
};
|
|
63
|
+
if (withAnimation && headerRef.current) {
|
|
64
|
+
mainLinePaddingTopRef.current = getComputedStyle(headerRef.current).paddingTop;
|
|
65
|
+
}
|
|
66
|
+
if (withAnimation && parent) {
|
|
67
|
+
parent.addEventListener('scroll', handleScroll);
|
|
68
|
+
}
|
|
69
|
+
return () => parent?.removeEventListener('scroll', handleScroll);
|
|
70
|
+
}, [scrollableParentRef, withAnimation]);
|
|
71
|
+
const renderBackButton = () => {
|
|
72
|
+
let textOpacity = 1;
|
|
73
|
+
if (withAnimation) {
|
|
74
|
+
const height = hasContent ? ADDONS_HEIGHT : ADDONS_HEIGHT / 2;
|
|
75
|
+
textOpacity = Math.max(0, 1 - scrollTop / height);
|
|
76
|
+
}
|
|
77
|
+
else if (compactTitle) {
|
|
78
|
+
textOpacity = 0;
|
|
79
|
+
}
|
|
80
|
+
return (React.createElement("div", { className: cn(styles.addon, backButtonClassName) },
|
|
81
|
+
React.createElement(BackArrowAddon, { "data-test-id": getDataTestId(dataTestId, 'back-button'), ...backButtonProps, textOpacity: textOpacity, view: view, onClick: onBack })));
|
|
82
|
+
};
|
|
83
|
+
const renderContent = (args = {}) => {
|
|
84
|
+
const { extraClassName, wrapperRef, style, hidden } = args;
|
|
85
|
+
return (React.createElement("div", { style: { ...style, visibility: hidden ? 'hidden' : 'visible' }, ref: wrapperRef, className: cn(styles.content, extraClassName, contentClassName, styles[align], {
|
|
86
|
+
[styles.trim]: trim,
|
|
87
|
+
[styles.withCompactTitle]: view === 'mobile' && compactTitle && hasContent,
|
|
88
|
+
}), "aria-hidden": hidden },
|
|
89
|
+
children && React.createElement("div", { className: styles.children }, children),
|
|
90
|
+
title && (React.createElement("div", { className: styles.title, "data-test-id": hidden ? undefined : getDataTestId(dataTestId, 'title') }, title)),
|
|
91
|
+
compactTitle && subtitle && React.createElement("div", { className: styles.subtitle }, subtitle)));
|
|
92
|
+
};
|
|
93
|
+
const renderCloser = () => (React.createElement("div", { className: cn(styles.addon, styles.closer, closerClassName) },
|
|
94
|
+
React.createElement(Closer, { view: view, icon: closerIcon, dataTestId: getDataTestId(dataTestId, 'closer'), onClose: onClose })));
|
|
95
|
+
return (React.createElement("div", { ref: mergeRefs([ref, headerRef]), className: cn(styles.header, className, { [styles.backgroundImage]: imageUrl }), "data-test-id": getDataTestId(dataTestId), style: {
|
|
96
|
+
...(imageUrl && { backgroundImage: `url(${imageUrl})` }),
|
|
97
|
+
...(withAnimation &&
|
|
98
|
+
bottomContentRef.current && {
|
|
99
|
+
top: -bottomContentRef.current.scrollHeight,
|
|
100
|
+
}),
|
|
101
|
+
} },
|
|
102
|
+
React.createElement("div", { className: cn(styles.mainLine, {
|
|
103
|
+
[styles.mainLineSticky]: withAnimation,
|
|
104
|
+
[styles.mainLineWithImageBg]: imageUrl,
|
|
105
|
+
}), style: {
|
|
106
|
+
...(withAnimation
|
|
107
|
+
? {
|
|
108
|
+
marginTop: `-${headerPaddingTop}`,
|
|
109
|
+
paddingTop: headerPaddingTop,
|
|
110
|
+
}
|
|
111
|
+
: null),
|
|
112
|
+
} },
|
|
113
|
+
hasLeftPart && (React.createElement("div", { className: styles.addonsWrapper, ref: leftAddonsRef },
|
|
114
|
+
hasBackButton && renderBackButton(),
|
|
115
|
+
leftAddons && (React.createElement("div", { className: cn(styles.addon, addonClassName) }, leftAddons)))),
|
|
116
|
+
showStaticContentOnTop &&
|
|
117
|
+
renderContent({
|
|
118
|
+
...(align === 'center'
|
|
119
|
+
? {
|
|
120
|
+
style: {
|
|
121
|
+
marginLeft: titleMargin.left,
|
|
122
|
+
marginRight: titleMargin.right,
|
|
123
|
+
},
|
|
124
|
+
}
|
|
125
|
+
: null),
|
|
126
|
+
}),
|
|
127
|
+
showAnimatedContentOnTop &&
|
|
128
|
+
renderContent({
|
|
129
|
+
extraClassName: styles.withBothAddons,
|
|
130
|
+
style: {
|
|
131
|
+
opacity: Math.min(1, (scrollTop - ADDONS_HEIGHT) / ADDONS_HEIGHT),
|
|
132
|
+
...(align === 'center'
|
|
133
|
+
? {
|
|
134
|
+
marginLeft: titleMargin.left,
|
|
135
|
+
marginRight: titleMargin.right,
|
|
136
|
+
}
|
|
137
|
+
: null),
|
|
138
|
+
},
|
|
139
|
+
}),
|
|
140
|
+
hasRightPart && (React.createElement("div", { className: cn(styles.addonsWrapper, styles.rightAddons), ref: rightAddonsRef },
|
|
141
|
+
rightAddons && (React.createElement("div", { className: cn(styles.addon, addonClassName) }, rightAddons)),
|
|
142
|
+
hasCloser && renderCloser()))),
|
|
143
|
+
showAnimatedContentOnBot &&
|
|
144
|
+
renderContent({
|
|
145
|
+
wrapperRef: bottomContentRef,
|
|
146
|
+
extraClassName: styles.underAddons,
|
|
147
|
+
style: { opacity: Math.max(0, 1 - scrollTop / ADDONS_HEIGHT) },
|
|
148
|
+
hidden: scrollTop / ADDONS_HEIGHT > 1,
|
|
149
|
+
}),
|
|
150
|
+
showStaticContentOnBot &&
|
|
151
|
+
renderContent({
|
|
152
|
+
extraClassName: cn({
|
|
153
|
+
[styles.contentOnBotDesktop]: view === 'desktop',
|
|
154
|
+
[styles.contentOnBotMobile]: view === 'mobile',
|
|
155
|
+
}),
|
|
156
|
+
}),
|
|
157
|
+
bottomAddons && (React.createElement("div", { className: cn(styles.bottomAddons, bottomAddonsClassName) }, bottomAddons))));
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
export { NavigationBarPrivate };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React from 'react';
|
|
3
|
+
interface BackArrowAddonProps extends React.HTMLAttributes<HTMLButtonElement> {
|
|
4
|
+
/**
|
|
5
|
+
* Текст после иконки
|
|
6
|
+
*/
|
|
7
|
+
text?: string | null;
|
|
8
|
+
/**
|
|
9
|
+
* Дополнительный класс
|
|
10
|
+
*/
|
|
11
|
+
className?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Вид компонента
|
|
14
|
+
*/
|
|
15
|
+
view: 'mobile' | 'desktop';
|
|
16
|
+
/**
|
|
17
|
+
* Прозрачность текста
|
|
18
|
+
*/
|
|
19
|
+
textOpacity?: number;
|
|
20
|
+
/**
|
|
21
|
+
* Обработчик клика
|
|
22
|
+
*/
|
|
23
|
+
onClick?: () => void;
|
|
24
|
+
}
|
|
25
|
+
declare const BackArrowAddon: React.FC<BackArrowAddonProps>;
|
|
26
|
+
export { BackArrowAddonProps, BackArrowAddon };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
import { ButtonDesktop } from '@alfalab/core-components-button/modern/desktop';
|
|
4
|
+
import { Typography } from '@alfalab/core-components-typography/modern';
|
|
5
|
+
import { ArrowLeftMediumMIcon } from '@alfalab/icons-glyph/ArrowLeftMediumMIcon';
|
|
6
|
+
import { ArrowLeftMIcon } from '@alfalab/icons-glyph/ArrowLeftMIcon';
|
|
7
|
+
|
|
8
|
+
const styles = {"component":"navigation-bar-private__component_rqdd8","mobileComponent":"navigation-bar-private__mobileComponent_rqdd8","flex":"navigation-bar-private__flex_rqdd8","iconWrapper":"navigation-bar-private__iconWrapper_rqdd8","text":"navigation-bar-private__text_rqdd8","mobileWrapper":"navigation-bar-private__mobileWrapper_rqdd8"};
|
|
9
|
+
require('./index.css')
|
|
10
|
+
|
|
11
|
+
const BackArrowAddon = ({ text = 'Назад', onClick, className, textOpacity = 1, view, ...htmlAttributes }) => {
|
|
12
|
+
const Icon = view === 'desktop' ? ArrowLeftMediumMIcon : ArrowLeftMIcon;
|
|
13
|
+
const isMobileView = view === 'mobile';
|
|
14
|
+
return (React.createElement(ButtonDesktop, { view: 'text', size: isMobileView ? 'xxs' : 's', onClick: onClick, "aria-label": '\u043D\u0430\u0437\u0430\u0434', className: cn(styles.component, { [styles.mobileComponent]: isMobileView }, className), ...htmlAttributes },
|
|
15
|
+
React.createElement("div", { className: styles.flex },
|
|
16
|
+
React.createElement("div", { className: cn(styles.iconWrapper, {
|
|
17
|
+
[styles.mobileWrapper]: isMobileView,
|
|
18
|
+
}) },
|
|
19
|
+
React.createElement(Icon, null)),
|
|
20
|
+
textOpacity > 0 && text && (React.createElement(Typography.Text, { className: styles.text, view: view === 'desktop' ? 'primary-large' : 'component', weight: 'medium', style: { opacity: textOpacity } }, text)))));
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { BackArrowAddon };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/* hash: 1pg68 */
|
|
2
|
+
:root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
3
|
+
} /* deprecated */ :root {
|
|
4
|
+
--color-light-neutral-1500: #121213;
|
|
5
|
+
--color-light-neutral-1500-hover: #3f3f45;
|
|
6
|
+
--color-light-neutral-1500-press: #5f5f66;
|
|
7
|
+
--color-light-neutral-translucent-100: rgba(38, 55, 88, 0.06);
|
|
8
|
+
--color-light-neutral-translucent-700: rgba(4, 4, 21, 0.47); /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
9
|
+
--color-light-bg-primary-alpha-40: rgba(255, 255, 255, 0.4);
|
|
10
|
+
} :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
11
|
+
} :root {
|
|
12
|
+
} :root {
|
|
13
|
+
|
|
14
|
+
/* Hard */
|
|
15
|
+
|
|
16
|
+
/* Up */
|
|
17
|
+
|
|
18
|
+
/* Hard up */
|
|
19
|
+
} :root {
|
|
20
|
+
--border-radius-circle: 50%;
|
|
21
|
+
--border-radius-pill: 99px;
|
|
22
|
+
} :root {
|
|
23
|
+
--gap-xs: 8px;
|
|
24
|
+
--gap-s: 12px;
|
|
25
|
+
} :root {
|
|
26
|
+
} :root {
|
|
27
|
+
} :root {
|
|
28
|
+
/* closer-mobile */
|
|
29
|
+
|
|
30
|
+
/* back-arrow */
|
|
31
|
+
--navigation-bar-back-arrow-mobile-fill: var(--color-light-neutral-translucent-700);
|
|
32
|
+
} .navigation-bar-private__component_rqdd8 {
|
|
33
|
+
height: 100%;
|
|
34
|
+
background: var(--color-light-bg-primary-alpha-40);
|
|
35
|
+
-webkit-backdrop-filter: blur(10px);
|
|
36
|
+
backdrop-filter: blur(10px);
|
|
37
|
+
border-radius: var(--border-radius-pill);
|
|
38
|
+
min-width: 48px
|
|
39
|
+
} .navigation-bar-private__component_rqdd8 svg > path {
|
|
40
|
+
transition: fill 0.2s ease;
|
|
41
|
+
fill: var(--color-light-neutral-1500);
|
|
42
|
+
} .navigation-bar-private__component_rqdd8:hover svg > path {
|
|
43
|
+
fill: var(--color-light-neutral-1500-hover);
|
|
44
|
+
} .navigation-bar-private__component_rqdd8:active svg > path {
|
|
45
|
+
fill: var(--color-light-neutral-1500-press);
|
|
46
|
+
} .navigation-bar-private__mobileComponent_rqdd8 {
|
|
47
|
+
height: 32px;
|
|
48
|
+
min-width: 32px;
|
|
49
|
+
margin: 0 var(--gap-xs);
|
|
50
|
+
-webkit-backdrop-filter: none;
|
|
51
|
+
backdrop-filter: none;
|
|
52
|
+
background: none;
|
|
53
|
+
} .navigation-bar-private__flex_rqdd8 {
|
|
54
|
+
display: flex;
|
|
55
|
+
align-items: center;
|
|
56
|
+
} .navigation-bar-private__iconWrapper_rqdd8 {
|
|
57
|
+
display: inline-flex;
|
|
58
|
+
align-items: center;
|
|
59
|
+
justify-content: center;
|
|
60
|
+
height: 48px;
|
|
61
|
+
margin: 0 var(--gap-xs) 0 var(--gap-s);
|
|
62
|
+
border-radius: var(--border-radius-circle)
|
|
63
|
+
} .navigation-bar-private__iconWrapper_rqdd8 + .navigation-bar-private__text_rqdd8 {
|
|
64
|
+
margin-right: var(--gap-s);
|
|
65
|
+
} .navigation-bar-private__mobileWrapper_rqdd8 {
|
|
66
|
+
width: 32px;
|
|
67
|
+
height: 32px;
|
|
68
|
+
background: var(--color-light-neutral-translucent-100);
|
|
69
|
+
-webkit-backdrop-filter: blur(10px);
|
|
70
|
+
backdrop-filter: blur(10px);
|
|
71
|
+
margin: 0
|
|
72
|
+
} .navigation-bar-private__mobileWrapper_rqdd8 + .navigation-bar-private__text_rqdd8 {
|
|
73
|
+
margin: 0 var(--gap-s) 0 var(--gap-xs);
|
|
74
|
+
} .navigation-bar-private__mobileWrapper_rqdd8 svg > path {
|
|
75
|
+
fill: var(--navigation-bar-back-arrow-mobile-fill);
|
|
76
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Component";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { BackArrowAddon } from './Component.js';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { ButtonHTMLAttributes, ElementType, FC } from "react";
|
|
4
|
+
interface CloserProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
5
|
+
/**
|
|
6
|
+
* Вид компонента
|
|
7
|
+
*/
|
|
8
|
+
view: 'desktop' | 'mobile';
|
|
9
|
+
/**
|
|
10
|
+
* Дополнительный класс
|
|
11
|
+
*/
|
|
12
|
+
className?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Позиция крестика
|
|
15
|
+
*/
|
|
16
|
+
align?: 'left' | 'right';
|
|
17
|
+
/**
|
|
18
|
+
* Фиксирует крестик
|
|
19
|
+
*/
|
|
20
|
+
sticky?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Иконка
|
|
23
|
+
*/
|
|
24
|
+
icon?: ElementType;
|
|
25
|
+
/**
|
|
26
|
+
* Идентификатор для систем автоматизированного тестирования
|
|
27
|
+
*/
|
|
28
|
+
dataTestId?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Коллбэк закрытия.
|
|
31
|
+
*/
|
|
32
|
+
onClose?: (event: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>, reason?: 'backdropClick' | 'escapeKeyDown' | 'closerClick') => void;
|
|
33
|
+
}
|
|
34
|
+
declare const Closer: FC<CloserProps>;
|
|
35
|
+
export { CloserProps, Closer };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
import { IconButton } from '@alfalab/core-components-icon-button/modern';
|
|
4
|
+
import { CrossHeavyMIcon } from '@alfalab/icons-glyph/CrossHeavyMIcon';
|
|
5
|
+
import { CrossMIcon } from '@alfalab/icons-glyph/CrossMIcon';
|
|
6
|
+
|
|
7
|
+
const styles = {"closer":"navigation-bar-private__closer_1bwy4","button":"navigation-bar-private__button_1bwy4","mobile":"navigation-bar-private__mobile_1bwy4","sticky":"navigation-bar-private__sticky_1bwy4"};
|
|
8
|
+
require('./index.css')
|
|
9
|
+
|
|
10
|
+
const Closer = ({ view, className, sticky, icon = view === 'desktop' ? CrossHeavyMIcon : CrossMIcon, dataTestId, onClose, ...restProps }) => {
|
|
11
|
+
const handleClick = (event) => {
|
|
12
|
+
onClose?.(event, 'closerClick');
|
|
13
|
+
};
|
|
14
|
+
return (React.createElement("div", { className: cn(styles.closer, className, {
|
|
15
|
+
[styles.sticky]: sticky,
|
|
16
|
+
}) },
|
|
17
|
+
React.createElement(IconButton, { size: view === 'desktop' ? 's' : 'xs', className: cn(styles.button, { [styles.mobile]: view === 'mobile' }), "aria-label": '\u0437\u0430\u043A\u0440\u044B\u0442\u044C', onClick: handleClick, icon: icon, dataTestId: dataTestId, ...restProps })));
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { Closer };
|