@alfalab/core-components-navigation-bar 0.1.1 → 0.1.3
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.js +45 -7
- package/components/back-arrow-addon/Component.js +3 -1
- package/components/back-arrow-addon/index.css +18 -18
- package/components/back-arrow-addon/index.js +2 -0
- package/components/closer/Component.js +3 -1
- package/components/closer/index.css +9 -9
- package/components/closer/index.js +2 -0
- package/cssm/Component.js +44 -6
- package/cssm/components/back-arrow-addon/Component.js +2 -0
- package/cssm/components/back-arrow-addon/index.js +2 -0
- package/cssm/components/back-arrow-addon/index.module.css +6 -6
- package/cssm/components/closer/Component.js +2 -0
- package/cssm/components/closer/index.js +2 -0
- package/cssm/components/closer/index.module.css +4 -4
- package/cssm/index.js +3 -0
- package/cssm/index.module.css +3 -3
- package/esm/Component.js +43 -7
- package/esm/components/back-arrow-addon/Component.js +1 -1
- package/esm/components/back-arrow-addon/index.css +18 -18
- package/esm/components/closer/Component.js +1 -1
- package/esm/components/closer/index.css +9 -9
- package/esm/index.css +30 -30
- package/esm/index.js +1 -0
- package/index.css +30 -30
- package/index.js +3 -0
- package/modern/Component.js +44 -4
- package/modern/components/back-arrow-addon/Component.js +1 -1
- package/modern/components/back-arrow-addon/index.css +18 -18
- package/modern/components/closer/Component.js +1 -1
- package/modern/components/closer/index.css +9 -9
- package/modern/index.css +30 -30
- package/modern/index.js +1 -0
- package/package.json +5 -4
package/Component.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
3
5
|
var tslib = require('tslib');
|
|
4
6
|
var React = require('react');
|
|
5
7
|
var cn = require('classnames');
|
|
8
|
+
var hooks = require('@alfalab/hooks');
|
|
6
9
|
var components_backArrowAddon_Component = require('./components/back-arrow-addon/Component.js');
|
|
7
10
|
var components_closer_Component = require('./components/closer/Component.js');
|
|
8
11
|
require('@alfalab/core-components-button');
|
|
@@ -23,7 +26,7 @@ var getDataTestId = function (dataTestId, element) {
|
|
|
23
26
|
return dataTestId ? "".concat(dataTestId).concat(elementPart) : undefined;
|
|
24
27
|
};
|
|
25
28
|
|
|
26
|
-
var styles = {"header":"navigation-
|
|
29
|
+
var styles = {"header":"navigation-bar__header_1holh","backgroundImage":"navigation-bar__backgroundImage_1holh","mainLine":"navigation-bar__mainLine_1holh","mainLineSticky":"navigation-bar__mainLineSticky_1holh","mainLineWithImageBg":"navigation-bar__mainLineWithImageBg_1holh","content":"navigation-bar__content_1holh","withBothAddons":"navigation-bar__withBothAddons_1holh","withCompactTitle":"navigation-bar__withCompactTitle_1holh","children":"navigation-bar__children_1holh","title":"navigation-bar__title_1holh","contentOnBotDesktop":"navigation-bar__contentOnBotDesktop_1holh","contentOnBotMobile":"navigation-bar__contentOnBotMobile_1holh","subtitle":"navigation-bar__subtitle_1holh","addonsWrapper":"navigation-bar__addonsWrapper_1holh","rightAddons":"navigation-bar__rightAddons_1holh","addon":"navigation-bar__addon_1holh","bottomAddons":"navigation-bar__bottomAddons_1holh","closer":"navigation-bar__closer_1holh","left":"navigation-bar__left_1holh","center":"navigation-bar__center_1holh","trim":"navigation-bar__trim_1holh"};
|
|
27
30
|
require('./index.css')
|
|
28
31
|
|
|
29
32
|
var ADDONS_HEIGHT = 48;
|
|
@@ -31,9 +34,12 @@ var NavigationBar = function (_a) {
|
|
|
31
34
|
var _b, _c, _d;
|
|
32
35
|
var addonClassName = _a.addonClassName, className = _a.className, contentClassName = _a.contentClassName, closerClassName = _a.closerClassName, leftAddons = _a.leftAddons, rightAddons = _a.rightAddons, bottomAddons = _a.bottomAddons, bottomAddonsClassName = _a.bottomAddonsClassName, children = _a.children, _e = _a.align, align = _e === void 0 ? 'left' : _e, _f = _a.trim, trim = _f === void 0 ? true : _f, title = _a.title, _g = _a.titleSize, titleSize = _g === void 0 ? 'default' : _g, subtitle = _a.subtitle, hasCloser = _a.hasCloser, hasBackButton = _a.hasBackButton, backButtonClassName = _a.backButtonClassName, dataTestId = _a.dataTestId, imageUrl = _a.imageUrl, closerIcon = _a.closerIcon, onClose = _a.onClose, view = _a.view, scrollableParentRef = _a.scrollableParentRef, sticky = _a.sticky, onBack = _a.onBack;
|
|
33
36
|
var _h = React.useState(0), scrollTop = _h[0], setScrollTop = _h[1];
|
|
37
|
+
var _j = React.useState({ left: 0, right: 0 }), titleMargin = _j[0], setTitleMargin = _j[1];
|
|
34
38
|
var bottomContentRef = React.useRef(null);
|
|
35
39
|
var headerRef = React.useRef(null);
|
|
36
40
|
var mainLinePaddingTopRef = React.useRef('0px');
|
|
41
|
+
var leftAddonsRef = React.useRef(null);
|
|
42
|
+
var rightAddonsRef = React.useRef(null);
|
|
37
43
|
var compactTitle = view === 'mobile' && titleSize === 'compact';
|
|
38
44
|
var hasLeftPart = Boolean(leftAddons || hasBackButton);
|
|
39
45
|
var hasRightPart = Boolean(rightAddons || hasCloser);
|
|
@@ -46,6 +52,30 @@ var NavigationBar = function (_a) {
|
|
|
46
52
|
var showAnimatedContentOnTop = withAnimation && showContentOnBot && scrollTop > ADDONS_HEIGHT;
|
|
47
53
|
var showAnimatedContentOnBot = withAnimation && showContentOnBot;
|
|
48
54
|
var headerPaddingTop = mainLinePaddingTopRef.current;
|
|
55
|
+
hooks.useLayoutEffect_SAFE_FOR_SSR(function () {
|
|
56
|
+
var _a, _b;
|
|
57
|
+
if (align === 'center' && (showStaticContentOnTop || showAnimatedContentOnTop)) {
|
|
58
|
+
var leftAddonsWidth = ((_a = leftAddonsRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth) || 0;
|
|
59
|
+
var rightAddonsWidth = ((_b = rightAddonsRef.current) === null || _b === void 0 ? void 0 : _b.offsetWidth) || 0;
|
|
60
|
+
var marginSize_1 = Math.abs(rightAddonsWidth - leftAddonsWidth);
|
|
61
|
+
var shouldAddLeftMargin_1 = rightAddonsWidth - leftAddonsWidth > 0;
|
|
62
|
+
setTitleMargin(function (prev) {
|
|
63
|
+
var newState = shouldAddLeftMargin_1
|
|
64
|
+
? { left: marginSize_1, right: 0 }
|
|
65
|
+
: { left: 0, right: marginSize_1 };
|
|
66
|
+
var isStateChanged = prev.left !== newState.left || prev.right !== newState.right;
|
|
67
|
+
return isStateChanged ? newState : prev;
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}, [
|
|
71
|
+
align,
|
|
72
|
+
showStaticContentOnTop,
|
|
73
|
+
showAnimatedContentOnTop,
|
|
74
|
+
leftAddons,
|
|
75
|
+
rightAddons,
|
|
76
|
+
hasBackButton,
|
|
77
|
+
hasCloser,
|
|
78
|
+
]);
|
|
49
79
|
React.useEffect(function () {
|
|
50
80
|
var parent = scrollableParentRef === null || scrollableParentRef === void 0 ? void 0 : scrollableParentRef.current;
|
|
51
81
|
var handleScroll = function (ev) {
|
|
@@ -97,18 +127,26 @@ var NavigationBar = function (_a) {
|
|
|
97
127
|
paddingTop: headerPaddingTop,
|
|
98
128
|
}
|
|
99
129
|
: null)) },
|
|
100
|
-
hasLeftPart && (React__default.default.createElement("div", { className: styles.addonsWrapper },
|
|
130
|
+
hasLeftPart && (React__default.default.createElement("div", { className: styles.addonsWrapper, ref: leftAddonsRef },
|
|
101
131
|
hasBackButton && renderBackButton(),
|
|
102
132
|
leftAddons && (React__default.default.createElement("div", { className: cn__default.default(styles.addon, addonClassName) }, leftAddons)))),
|
|
103
|
-
showStaticContentOnTop &&
|
|
133
|
+
showStaticContentOnTop &&
|
|
134
|
+
renderContent(tslib.__assign({}, (align === 'center'
|
|
135
|
+
? {
|
|
136
|
+
style: {
|
|
137
|
+
marginLeft: titleMargin.left,
|
|
138
|
+
marginRight: titleMargin.right,
|
|
139
|
+
},
|
|
140
|
+
}
|
|
141
|
+
: null))),
|
|
104
142
|
showAnimatedContentOnTop &&
|
|
105
143
|
renderContent({
|
|
106
144
|
extraClassName: styles.withBothAddons,
|
|
107
|
-
style: {
|
|
108
|
-
|
|
109
|
-
|
|
145
|
+
style: tslib.__assign({ opacity: Math.min(1, (scrollTop - ADDONS_HEIGHT) / ADDONS_HEIGHT) }, (align === 'center'
|
|
146
|
+
? { marginLeft: titleMargin.left, marginRight: titleMargin.right }
|
|
147
|
+
: null)),
|
|
110
148
|
}),
|
|
111
|
-
hasRightPart && (React__default.default.createElement("div", { className: cn__default.default(styles.addonsWrapper, styles.rightAddons) },
|
|
149
|
+
hasRightPart && (React__default.default.createElement("div", { className: cn__default.default(styles.addonsWrapper, styles.rightAddons), ref: rightAddonsRef },
|
|
112
150
|
rightAddons && (React__default.default.createElement("div", { className: cn__default.default(styles.addon, addonClassName) }, rightAddons)),
|
|
113
151
|
hasCloser && renderCloser()))),
|
|
114
152
|
showAnimatedContentOnBot &&
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
3
5
|
var tslib = require('tslib');
|
|
4
6
|
var React = require('react');
|
|
5
7
|
var cn = require('classnames');
|
|
@@ -13,7 +15,7 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
13
15
|
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
14
16
|
var cn__default = /*#__PURE__*/_interopDefaultCompat(cn);
|
|
15
17
|
|
|
16
|
-
var styles = {"component":"navigation-
|
|
18
|
+
var styles = {"component":"navigation-bar__component_65af1","mobileComponent":"navigation-bar__mobileComponent_65af1","flex":"navigation-bar__flex_65af1","iconWrapper":"navigation-bar__iconWrapper_65af1","text":"navigation-bar__text_65af1","mobileWrapper":"navigation-bar__mobileWrapper_65af1"};
|
|
17
19
|
require('./index.css')
|
|
18
20
|
|
|
19
21
|
var BackArrowAddon = function (_a) {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: 1iw35 */
|
|
2
2
|
:root {
|
|
3
3
|
} /* deprecated */ :root {
|
|
4
|
-
--color-light-graphic-primary: #
|
|
5
|
-
--color-light-graphic-secondary: #
|
|
6
|
-
--color-light-specialbg-secondary-transparent: rgba(11, 31, 53, 0.05);
|
|
4
|
+
--color-light-graphic-primary: #0e0e0e;
|
|
5
|
+
--color-light-graphic-secondary: #86868a;
|
|
6
|
+
--color-light-specialbg-secondary-transparent: rgba(11, 31, 53, 0.05); /* 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 */
|
|
7
7
|
--color-light-bg-primary-alpha-40: rgba(255, 255, 255, 0.4);
|
|
8
|
-
--color-light-graphic-primary-tint-20: rgb(
|
|
9
|
-
--color-light-graphic-primary-tint-30: rgb(
|
|
10
|
-
} :root {
|
|
8
|
+
--color-light-graphic-primary-tint-20: rgb(62, 62, 62);
|
|
9
|
+
--color-light-graphic-primary-tint-30: rgb(86, 86, 86);
|
|
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
11
|
} :root {
|
|
12
12
|
} :root {
|
|
13
13
|
|
|
@@ -24,46 +24,46 @@
|
|
|
24
24
|
--gap-s: 12px;
|
|
25
25
|
} :root {
|
|
26
26
|
} :root {
|
|
27
|
-
} .navigation-
|
|
27
|
+
} .navigation-bar__component_65af1 {
|
|
28
28
|
height: 100%;
|
|
29
29
|
background: var(--color-light-bg-primary-alpha-40);
|
|
30
30
|
-webkit-backdrop-filter: blur(10px);
|
|
31
31
|
backdrop-filter: blur(10px);
|
|
32
32
|
border-radius: var(--border-radius-pill)
|
|
33
|
-
} .navigation-
|
|
33
|
+
} .navigation-bar__component_65af1 svg > path {
|
|
34
34
|
transition: fill 0.2s ease;
|
|
35
35
|
fill: var(--color-light-graphic-primary);
|
|
36
|
-
} .navigation-
|
|
36
|
+
} .navigation-bar__component_65af1:hover svg > path {
|
|
37
37
|
fill: var(--color-light-graphic-primary-tint-20);
|
|
38
|
-
} .navigation-
|
|
38
|
+
} .navigation-bar__component_65af1:active svg > path {
|
|
39
39
|
fill: var(--color-light-graphic-primary-tint-30);
|
|
40
|
-
} .navigation-
|
|
40
|
+
} .navigation-bar__mobileComponent_65af1 {
|
|
41
41
|
height: 32px;
|
|
42
42
|
margin: 0 var(--gap-xs);
|
|
43
43
|
-webkit-backdrop-filter: none;
|
|
44
44
|
backdrop-filter: none;
|
|
45
45
|
background: none;
|
|
46
|
-
} .navigation-
|
|
46
|
+
} .navigation-bar__flex_65af1 {
|
|
47
47
|
display: flex;
|
|
48
48
|
align-items: center;
|
|
49
|
-
} .navigation-
|
|
49
|
+
} .navigation-bar__iconWrapper_65af1 {
|
|
50
50
|
display: inline-flex;
|
|
51
51
|
align-items: center;
|
|
52
52
|
justify-content: center;
|
|
53
53
|
height: 48px;
|
|
54
54
|
margin: 0 var(--gap-xs) 0 var(--gap-s);
|
|
55
55
|
border-radius: var(--border-radius-circle)
|
|
56
|
-
} .navigation-
|
|
56
|
+
} .navigation-bar__iconWrapper_65af1 + .navigation-bar__text_65af1 {
|
|
57
57
|
margin-right: var(--gap-s);
|
|
58
|
-
} .navigation-
|
|
58
|
+
} .navigation-bar__mobileWrapper_65af1 {
|
|
59
59
|
width: 32px;
|
|
60
60
|
height: 32px;
|
|
61
61
|
background: var(--color-light-specialbg-secondary-transparent);
|
|
62
62
|
-webkit-backdrop-filter: blur(10px);
|
|
63
63
|
backdrop-filter: blur(10px);
|
|
64
64
|
margin: 0
|
|
65
|
-
} .navigation-
|
|
65
|
+
} .navigation-bar__mobileWrapper_65af1 + .navigation-bar__text_65af1 {
|
|
66
66
|
margin: 0 var(--gap-s) 0 var(--gap-xs);
|
|
67
|
-
} .navigation-
|
|
67
|
+
} .navigation-bar__mobileWrapper_65af1 svg > path {
|
|
68
68
|
fill: var(--color-light-graphic-secondary);
|
|
69
69
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
3
5
|
var tslib = require('tslib');
|
|
4
6
|
var React = require('react');
|
|
5
7
|
var cn = require('classnames');
|
|
@@ -12,7 +14,7 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
12
14
|
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
13
15
|
var cn__default = /*#__PURE__*/_interopDefaultCompat(cn);
|
|
14
16
|
|
|
15
|
-
var styles = {"closer":"navigation-
|
|
17
|
+
var styles = {"closer":"navigation-bar__closer_1wm0n","button":"navigation-bar__button_1wm0n","mobile":"navigation-bar__mobile_1wm0n","sticky":"navigation-bar__sticky_1wm0n"};
|
|
16
18
|
require('./index.css')
|
|
17
19
|
|
|
18
20
|
var Closer = function (_a) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: 1hg1i */
|
|
2
2
|
:root {
|
|
3
3
|
} /* deprecated */ :root {
|
|
4
|
-
--color-light-graphic-primary: #
|
|
5
|
-
--color-light-graphic-secondary: #
|
|
6
|
-
--color-light-specialbg-secondary-transparent: rgba(11, 31, 53, 0.05);
|
|
4
|
+
--color-light-graphic-primary: #0e0e0e;
|
|
5
|
+
--color-light-graphic-secondary: #86868a;
|
|
6
|
+
--color-light-specialbg-secondary-transparent: rgba(11, 31, 53, 0.05); /* 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 */
|
|
7
7
|
--color-light-bg-primary-alpha-40: rgba(255, 255, 255, 0.4);
|
|
8
|
-
} :root {
|
|
8
|
+
} :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 */
|
|
9
9
|
} :root {
|
|
10
10
|
} :root {
|
|
11
11
|
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
} :root {
|
|
19
19
|
} :root {
|
|
20
20
|
} :root {
|
|
21
|
-
} .navigation-
|
|
21
|
+
} .navigation-bar__closer_1wm0n {
|
|
22
22
|
flex-shrink: 0;
|
|
23
23
|
width: 48px;
|
|
24
24
|
height: 48px;
|
|
@@ -26,16 +26,16 @@
|
|
|
26
26
|
display: flex;
|
|
27
27
|
align-items: center;
|
|
28
28
|
justify-content: center;
|
|
29
|
-
} .navigation-
|
|
29
|
+
} .navigation-bar__button_1wm0n {
|
|
30
30
|
background: var(--color-light-bg-primary-alpha-40);
|
|
31
31
|
-webkit-backdrop-filter: blur(10px);
|
|
32
32
|
backdrop-filter: blur(10px);
|
|
33
33
|
border-radius: 50px;
|
|
34
34
|
color: var(--color-light-graphic-primary)
|
|
35
|
-
} .navigation-
|
|
35
|
+
} .navigation-bar__button_1wm0n.navigation-bar__mobile_1wm0n {
|
|
36
36
|
background: var(--color-light-specialbg-secondary-transparent);
|
|
37
37
|
color: var(--color-light-graphic-secondary);
|
|
38
|
-
} .navigation-
|
|
38
|
+
} .navigation-bar__sticky_1wm0n {
|
|
39
39
|
position: sticky;
|
|
40
40
|
top: 0;
|
|
41
41
|
}
|
package/cssm/Component.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
3
5
|
var tslib = require('tslib');
|
|
4
6
|
var React = require('react');
|
|
5
7
|
var cn = require('classnames');
|
|
8
|
+
var hooks = require('@alfalab/hooks');
|
|
6
9
|
var components_backArrowAddon_Component = require('./components/back-arrow-addon/Component.js');
|
|
7
10
|
var components_closer_Component = require('./components/closer/Component.js');
|
|
8
11
|
var styles = require('./index.module.css');
|
|
@@ -32,9 +35,12 @@ var NavigationBar = function (_a) {
|
|
|
32
35
|
var _b, _c, _d;
|
|
33
36
|
var addonClassName = _a.addonClassName, className = _a.className, contentClassName = _a.contentClassName, closerClassName = _a.closerClassName, leftAddons = _a.leftAddons, rightAddons = _a.rightAddons, bottomAddons = _a.bottomAddons, bottomAddonsClassName = _a.bottomAddonsClassName, children = _a.children, _e = _a.align, align = _e === void 0 ? 'left' : _e, _f = _a.trim, trim = _f === void 0 ? true : _f, title = _a.title, _g = _a.titleSize, titleSize = _g === void 0 ? 'default' : _g, subtitle = _a.subtitle, hasCloser = _a.hasCloser, hasBackButton = _a.hasBackButton, backButtonClassName = _a.backButtonClassName, dataTestId = _a.dataTestId, imageUrl = _a.imageUrl, closerIcon = _a.closerIcon, onClose = _a.onClose, view = _a.view, scrollableParentRef = _a.scrollableParentRef, sticky = _a.sticky, onBack = _a.onBack;
|
|
34
37
|
var _h = React.useState(0), scrollTop = _h[0], setScrollTop = _h[1];
|
|
38
|
+
var _j = React.useState({ left: 0, right: 0 }), titleMargin = _j[0], setTitleMargin = _j[1];
|
|
35
39
|
var bottomContentRef = React.useRef(null);
|
|
36
40
|
var headerRef = React.useRef(null);
|
|
37
41
|
var mainLinePaddingTopRef = React.useRef('0px');
|
|
42
|
+
var leftAddonsRef = React.useRef(null);
|
|
43
|
+
var rightAddonsRef = React.useRef(null);
|
|
38
44
|
var compactTitle = view === 'mobile' && titleSize === 'compact';
|
|
39
45
|
var hasLeftPart = Boolean(leftAddons || hasBackButton);
|
|
40
46
|
var hasRightPart = Boolean(rightAddons || hasCloser);
|
|
@@ -47,6 +53,30 @@ var NavigationBar = function (_a) {
|
|
|
47
53
|
var showAnimatedContentOnTop = withAnimation && showContentOnBot && scrollTop > ADDONS_HEIGHT;
|
|
48
54
|
var showAnimatedContentOnBot = withAnimation && showContentOnBot;
|
|
49
55
|
var headerPaddingTop = mainLinePaddingTopRef.current;
|
|
56
|
+
hooks.useLayoutEffect_SAFE_FOR_SSR(function () {
|
|
57
|
+
var _a, _b;
|
|
58
|
+
if (align === 'center' && (showStaticContentOnTop || showAnimatedContentOnTop)) {
|
|
59
|
+
var leftAddonsWidth = ((_a = leftAddonsRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth) || 0;
|
|
60
|
+
var rightAddonsWidth = ((_b = rightAddonsRef.current) === null || _b === void 0 ? void 0 : _b.offsetWidth) || 0;
|
|
61
|
+
var marginSize_1 = Math.abs(rightAddonsWidth - leftAddonsWidth);
|
|
62
|
+
var shouldAddLeftMargin_1 = rightAddonsWidth - leftAddonsWidth > 0;
|
|
63
|
+
setTitleMargin(function (prev) {
|
|
64
|
+
var newState = shouldAddLeftMargin_1
|
|
65
|
+
? { left: marginSize_1, right: 0 }
|
|
66
|
+
: { left: 0, right: marginSize_1 };
|
|
67
|
+
var isStateChanged = prev.left !== newState.left || prev.right !== newState.right;
|
|
68
|
+
return isStateChanged ? newState : prev;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}, [
|
|
72
|
+
align,
|
|
73
|
+
showStaticContentOnTop,
|
|
74
|
+
showAnimatedContentOnTop,
|
|
75
|
+
leftAddons,
|
|
76
|
+
rightAddons,
|
|
77
|
+
hasBackButton,
|
|
78
|
+
hasCloser,
|
|
79
|
+
]);
|
|
50
80
|
React.useEffect(function () {
|
|
51
81
|
var parent = scrollableParentRef === null || scrollableParentRef === void 0 ? void 0 : scrollableParentRef.current;
|
|
52
82
|
var handleScroll = function (ev) {
|
|
@@ -98,18 +128,26 @@ var NavigationBar = function (_a) {
|
|
|
98
128
|
paddingTop: headerPaddingTop,
|
|
99
129
|
}
|
|
100
130
|
: null)) },
|
|
101
|
-
hasLeftPart && (React__default.default.createElement("div", { className: styles__default.default.addonsWrapper },
|
|
131
|
+
hasLeftPart && (React__default.default.createElement("div", { className: styles__default.default.addonsWrapper, ref: leftAddonsRef },
|
|
102
132
|
hasBackButton && renderBackButton(),
|
|
103
133
|
leftAddons && (React__default.default.createElement("div", { className: cn__default.default(styles__default.default.addon, addonClassName) }, leftAddons)))),
|
|
104
|
-
showStaticContentOnTop &&
|
|
134
|
+
showStaticContentOnTop &&
|
|
135
|
+
renderContent(tslib.__assign({}, (align === 'center'
|
|
136
|
+
? {
|
|
137
|
+
style: {
|
|
138
|
+
marginLeft: titleMargin.left,
|
|
139
|
+
marginRight: titleMargin.right,
|
|
140
|
+
},
|
|
141
|
+
}
|
|
142
|
+
: null))),
|
|
105
143
|
showAnimatedContentOnTop &&
|
|
106
144
|
renderContent({
|
|
107
145
|
extraClassName: styles__default.default.withBothAddons,
|
|
108
|
-
style: {
|
|
109
|
-
|
|
110
|
-
|
|
146
|
+
style: tslib.__assign({ opacity: Math.min(1, (scrollTop - ADDONS_HEIGHT) / ADDONS_HEIGHT) }, (align === 'center'
|
|
147
|
+
? { marginLeft: titleMargin.left, marginRight: titleMargin.right }
|
|
148
|
+
: null)),
|
|
111
149
|
}),
|
|
112
|
-
hasRightPart && (React__default.default.createElement("div", { className: cn__default.default(styles__default.default.addonsWrapper, styles__default.default.rightAddons) },
|
|
150
|
+
hasRightPart && (React__default.default.createElement("div", { className: cn__default.default(styles__default.default.addonsWrapper, styles__default.default.rightAddons), ref: rightAddonsRef },
|
|
113
151
|
rightAddons && (React__default.default.createElement("div", { className: cn__default.default(styles__default.default.addon, addonClassName) }, rightAddons)),
|
|
114
152
|
hasCloser && renderCloser()))),
|
|
115
153
|
showAnimatedContentOnBot &&
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
:root {
|
|
2
2
|
} /* deprecated */ :root {
|
|
3
|
-
--color-light-graphic-primary: #
|
|
4
|
-
--color-light-graphic-secondary: #
|
|
5
|
-
--color-light-specialbg-secondary-transparent: rgba(11, 31, 53, 0.05);
|
|
3
|
+
--color-light-graphic-primary: #0e0e0e;
|
|
4
|
+
--color-light-graphic-secondary: #86868a;
|
|
5
|
+
--color-light-specialbg-secondary-transparent: rgba(11, 31, 53, 0.05); /* 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
6
|
--color-light-bg-primary-alpha-40: rgba(255, 255, 255, 0.4);
|
|
7
|
-
--color-light-graphic-primary-tint-20: rgb(
|
|
8
|
-
--color-light-graphic-primary-tint-30: rgb(
|
|
9
|
-
} :root {
|
|
7
|
+
--color-light-graphic-primary-tint-20: rgb(62, 62, 62);
|
|
8
|
+
--color-light-graphic-primary-tint-30: rgb(86, 86, 86);
|
|
9
|
+
} :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 */
|
|
10
10
|
} :root {
|
|
11
11
|
} :root {
|
|
12
12
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
:root {
|
|
2
2
|
} /* deprecated */ :root {
|
|
3
|
-
--color-light-graphic-primary: #
|
|
4
|
-
--color-light-graphic-secondary: #
|
|
5
|
-
--color-light-specialbg-secondary-transparent: rgba(11, 31, 53, 0.05);
|
|
3
|
+
--color-light-graphic-primary: #0e0e0e;
|
|
4
|
+
--color-light-graphic-secondary: #86868a;
|
|
5
|
+
--color-light-specialbg-secondary-transparent: rgba(11, 31, 53, 0.05); /* 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
6
|
--color-light-bg-primary-alpha-40: rgba(255, 255, 255, 0.4);
|
|
7
|
-
} :root {
|
|
7
|
+
} :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 */
|
|
8
8
|
} :root {
|
|
9
9
|
} :root {
|
|
10
10
|
|
package/cssm/index.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
3
5
|
var Component = require('./Component.js');
|
|
4
6
|
var components_closer_Component = require('./components/closer/Component.js');
|
|
5
7
|
require('tslib');
|
|
6
8
|
require('react');
|
|
7
9
|
require('classnames');
|
|
10
|
+
require('@alfalab/hooks');
|
|
8
11
|
require('./components/back-arrow-addon/Component.js');
|
|
9
12
|
require('@alfalab/core-components-button/cssm');
|
|
10
13
|
require('@alfalab/core-components-typography/cssm');
|
package/cssm/index.module.css
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
:root {
|
|
2
2
|
} /* deprecated */ :root {
|
|
3
|
-
--color-light-text-primary: #
|
|
4
|
-
--color-light-text-secondary: rgba(
|
|
5
|
-
} :root {
|
|
3
|
+
--color-light-text-primary: #0e0e0e;
|
|
4
|
+
--color-light-text-secondary: rgba(60, 60, 67, 0.66); /* 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 */
|
|
5
|
+
} :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 */
|
|
6
6
|
} :root {
|
|
7
7
|
} :root {
|
|
8
8
|
|
package/esm/Component.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { __assign } from 'tslib';
|
|
2
2
|
import React, { useState, useRef, useEffect } from 'react';
|
|
3
3
|
import cn from 'classnames';
|
|
4
|
+
import { useLayoutEffect_SAFE_FOR_SSR } from '@alfalab/hooks';
|
|
4
5
|
import { BackArrowAddon } from './components/back-arrow-addon/Component.js';
|
|
5
6
|
import { Closer } from './components/closer/Component.js';
|
|
6
7
|
import '@alfalab/core-components-button/esm';
|
|
@@ -16,7 +17,7 @@ var getDataTestId = function (dataTestId, element) {
|
|
|
16
17
|
return dataTestId ? "".concat(dataTestId).concat(elementPart) : undefined;
|
|
17
18
|
};
|
|
18
19
|
|
|
19
|
-
var styles = {"header":"navigation-
|
|
20
|
+
var styles = {"header":"navigation-bar__header_1holh","backgroundImage":"navigation-bar__backgroundImage_1holh","mainLine":"navigation-bar__mainLine_1holh","mainLineSticky":"navigation-bar__mainLineSticky_1holh","mainLineWithImageBg":"navigation-bar__mainLineWithImageBg_1holh","content":"navigation-bar__content_1holh","withBothAddons":"navigation-bar__withBothAddons_1holh","withCompactTitle":"navigation-bar__withCompactTitle_1holh","children":"navigation-bar__children_1holh","title":"navigation-bar__title_1holh","contentOnBotDesktop":"navigation-bar__contentOnBotDesktop_1holh","contentOnBotMobile":"navigation-bar__contentOnBotMobile_1holh","subtitle":"navigation-bar__subtitle_1holh","addonsWrapper":"navigation-bar__addonsWrapper_1holh","rightAddons":"navigation-bar__rightAddons_1holh","addon":"navigation-bar__addon_1holh","bottomAddons":"navigation-bar__bottomAddons_1holh","closer":"navigation-bar__closer_1holh","left":"navigation-bar__left_1holh","center":"navigation-bar__center_1holh","trim":"navigation-bar__trim_1holh"};
|
|
20
21
|
require('./index.css')
|
|
21
22
|
|
|
22
23
|
var ADDONS_HEIGHT = 48;
|
|
@@ -24,9 +25,12 @@ var NavigationBar = function (_a) {
|
|
|
24
25
|
var _b, _c, _d;
|
|
25
26
|
var addonClassName = _a.addonClassName, className = _a.className, contentClassName = _a.contentClassName, closerClassName = _a.closerClassName, leftAddons = _a.leftAddons, rightAddons = _a.rightAddons, bottomAddons = _a.bottomAddons, bottomAddonsClassName = _a.bottomAddonsClassName, children = _a.children, _e = _a.align, align = _e === void 0 ? 'left' : _e, _f = _a.trim, trim = _f === void 0 ? true : _f, title = _a.title, _g = _a.titleSize, titleSize = _g === void 0 ? 'default' : _g, subtitle = _a.subtitle, hasCloser = _a.hasCloser, hasBackButton = _a.hasBackButton, backButtonClassName = _a.backButtonClassName, dataTestId = _a.dataTestId, imageUrl = _a.imageUrl, closerIcon = _a.closerIcon, onClose = _a.onClose, view = _a.view, scrollableParentRef = _a.scrollableParentRef, sticky = _a.sticky, onBack = _a.onBack;
|
|
26
27
|
var _h = useState(0), scrollTop = _h[0], setScrollTop = _h[1];
|
|
28
|
+
var _j = useState({ left: 0, right: 0 }), titleMargin = _j[0], setTitleMargin = _j[1];
|
|
27
29
|
var bottomContentRef = useRef(null);
|
|
28
30
|
var headerRef = useRef(null);
|
|
29
31
|
var mainLinePaddingTopRef = useRef('0px');
|
|
32
|
+
var leftAddonsRef = useRef(null);
|
|
33
|
+
var rightAddonsRef = useRef(null);
|
|
30
34
|
var compactTitle = view === 'mobile' && titleSize === 'compact';
|
|
31
35
|
var hasLeftPart = Boolean(leftAddons || hasBackButton);
|
|
32
36
|
var hasRightPart = Boolean(rightAddons || hasCloser);
|
|
@@ -39,6 +43,30 @@ var NavigationBar = function (_a) {
|
|
|
39
43
|
var showAnimatedContentOnTop = withAnimation && showContentOnBot && scrollTop > ADDONS_HEIGHT;
|
|
40
44
|
var showAnimatedContentOnBot = withAnimation && showContentOnBot;
|
|
41
45
|
var headerPaddingTop = mainLinePaddingTopRef.current;
|
|
46
|
+
useLayoutEffect_SAFE_FOR_SSR(function () {
|
|
47
|
+
var _a, _b;
|
|
48
|
+
if (align === 'center' && (showStaticContentOnTop || showAnimatedContentOnTop)) {
|
|
49
|
+
var leftAddonsWidth = ((_a = leftAddonsRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth) || 0;
|
|
50
|
+
var rightAddonsWidth = ((_b = rightAddonsRef.current) === null || _b === void 0 ? void 0 : _b.offsetWidth) || 0;
|
|
51
|
+
var marginSize_1 = Math.abs(rightAddonsWidth - leftAddonsWidth);
|
|
52
|
+
var shouldAddLeftMargin_1 = rightAddonsWidth - leftAddonsWidth > 0;
|
|
53
|
+
setTitleMargin(function (prev) {
|
|
54
|
+
var newState = shouldAddLeftMargin_1
|
|
55
|
+
? { left: marginSize_1, right: 0 }
|
|
56
|
+
: { left: 0, right: marginSize_1 };
|
|
57
|
+
var isStateChanged = prev.left !== newState.left || prev.right !== newState.right;
|
|
58
|
+
return isStateChanged ? newState : prev;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}, [
|
|
62
|
+
align,
|
|
63
|
+
showStaticContentOnTop,
|
|
64
|
+
showAnimatedContentOnTop,
|
|
65
|
+
leftAddons,
|
|
66
|
+
rightAddons,
|
|
67
|
+
hasBackButton,
|
|
68
|
+
hasCloser,
|
|
69
|
+
]);
|
|
42
70
|
useEffect(function () {
|
|
43
71
|
var parent = scrollableParentRef === null || scrollableParentRef === void 0 ? void 0 : scrollableParentRef.current;
|
|
44
72
|
var handleScroll = function (ev) {
|
|
@@ -90,18 +118,26 @@ var NavigationBar = function (_a) {
|
|
|
90
118
|
paddingTop: headerPaddingTop,
|
|
91
119
|
}
|
|
92
120
|
: null)) },
|
|
93
|
-
hasLeftPart && (React.createElement("div", { className: styles.addonsWrapper },
|
|
121
|
+
hasLeftPart && (React.createElement("div", { className: styles.addonsWrapper, ref: leftAddonsRef },
|
|
94
122
|
hasBackButton && renderBackButton(),
|
|
95
123
|
leftAddons && (React.createElement("div", { className: cn(styles.addon, addonClassName) }, leftAddons)))),
|
|
96
|
-
showStaticContentOnTop &&
|
|
124
|
+
showStaticContentOnTop &&
|
|
125
|
+
renderContent(__assign({}, (align === 'center'
|
|
126
|
+
? {
|
|
127
|
+
style: {
|
|
128
|
+
marginLeft: titleMargin.left,
|
|
129
|
+
marginRight: titleMargin.right,
|
|
130
|
+
},
|
|
131
|
+
}
|
|
132
|
+
: null))),
|
|
97
133
|
showAnimatedContentOnTop &&
|
|
98
134
|
renderContent({
|
|
99
135
|
extraClassName: styles.withBothAddons,
|
|
100
|
-
style: {
|
|
101
|
-
|
|
102
|
-
|
|
136
|
+
style: __assign({ opacity: Math.min(1, (scrollTop - ADDONS_HEIGHT) / ADDONS_HEIGHT) }, (align === 'center'
|
|
137
|
+
? { marginLeft: titleMargin.left, marginRight: titleMargin.right }
|
|
138
|
+
: null)),
|
|
103
139
|
}),
|
|
104
|
-
hasRightPart && (React.createElement("div", { className: cn(styles.addonsWrapper, styles.rightAddons) },
|
|
140
|
+
hasRightPart && (React.createElement("div", { className: cn(styles.addonsWrapper, styles.rightAddons), ref: rightAddonsRef },
|
|
105
141
|
rightAddons && (React.createElement("div", { className: cn(styles.addon, addonClassName) }, rightAddons)),
|
|
106
142
|
hasCloser && renderCloser()))),
|
|
107
143
|
showAnimatedContentOnBot &&
|
|
@@ -6,7 +6,7 @@ import { Typography } from '@alfalab/core-components-typography/esm';
|
|
|
6
6
|
import { ArrowLeftMediumMIcon } from '@alfalab/icons-glyph/ArrowLeftMediumMIcon';
|
|
7
7
|
import { ArrowLeftMIcon } from '@alfalab/icons-glyph/ArrowLeftMIcon';
|
|
8
8
|
|
|
9
|
-
var styles = {"component":"navigation-
|
|
9
|
+
var styles = {"component":"navigation-bar__component_65af1","mobileComponent":"navigation-bar__mobileComponent_65af1","flex":"navigation-bar__flex_65af1","iconWrapper":"navigation-bar__iconWrapper_65af1","text":"navigation-bar__text_65af1","mobileWrapper":"navigation-bar__mobileWrapper_65af1"};
|
|
10
10
|
require('./index.css')
|
|
11
11
|
|
|
12
12
|
var BackArrowAddon = function (_a) {
|