@alfalab/core-components-navigation-bar 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 +4 -0
- package/Component.js +131 -0
- package/components/back-arrow-addon/Component.d.ts +26 -0
- package/components/back-arrow-addon/Component.js +32 -0
- package/components/back-arrow-addon/index.css +69 -0
- package/components/back-arrow-addon/index.d.ts +1 -0
- package/components/back-arrow-addon/index.js +14 -0
- package/components/closer/Component.d.ts +35 -0
- package/components/closer/Component.js +30 -0
- package/components/closer/index.css +41 -0
- package/components/closer/index.d.ts +1 -0
- package/components/closer/index.js +13 -0
- package/cssm/Component.d.ts +4 -0
- package/cssm/Component.js +132 -0
- package/cssm/components/back-arrow-addon/Component.d.ts +26 -0
- package/cssm/components/back-arrow-addon/Component.js +31 -0
- package/cssm/components/back-arrow-addon/index.d.ts +1 -0
- package/cssm/components/back-arrow-addon/index.js +15 -0
- package/cssm/components/back-arrow-addon/index.module.css +68 -0
- package/cssm/components/closer/Component.d.ts +35 -0
- package/cssm/components/closer/Component.js +29 -0
- package/cssm/components/closer/index.d.ts +1 -0
- package/cssm/components/closer/index.js +14 -0
- package/cssm/components/closer/index.module.css +40 -0
- package/cssm/index.d.ts +3 -0
- package/cssm/index.js +23 -0
- package/cssm/index.module.css +108 -0
- package/cssm/types.d.ts +113 -0
- package/cssm/types.js +2 -0
- package/esm/Component.d.ts +4 -0
- package/esm/Component.js +124 -0
- package/esm/components/back-arrow-addon/Component.d.ts +26 -0
- package/esm/components/back-arrow-addon/Component.js +25 -0
- package/esm/components/back-arrow-addon/index.css +69 -0
- package/esm/components/back-arrow-addon/index.d.ts +1 -0
- package/esm/components/back-arrow-addon/index.js +8 -0
- package/esm/components/closer/Component.d.ts +35 -0
- package/esm/components/closer/Component.js +23 -0
- package/esm/components/closer/index.css +41 -0
- package/esm/components/closer/index.d.ts +1 -0
- package/esm/components/closer/index.js +7 -0
- package/esm/index.css +108 -0
- package/esm/index.d.ts +3 -0
- package/esm/index.js +13 -0
- package/esm/types.d.ts +113 -0
- package/esm/types.js +1 -0
- package/index.css +108 -0
- package/index.d.ts +3 -0
- package/index.js +20 -0
- package/modern/Component.d.ts +4 -0
- package/modern/Component.js +125 -0
- package/modern/components/back-arrow-addon/Component.d.ts +26 -0
- package/modern/components/back-arrow-addon/Component.js +22 -0
- package/modern/components/back-arrow-addon/index.css +69 -0
- package/modern/components/back-arrow-addon/index.d.ts +1 -0
- package/modern/components/back-arrow-addon/index.js +7 -0
- package/modern/components/closer/Component.d.ts +35 -0
- package/modern/components/closer/Component.js +20 -0
- package/modern/components/closer/index.css +41 -0
- package/modern/components/closer/index.d.ts +1 -0
- package/modern/components/closer/index.js +6 -0
- package/modern/index.css +108 -0
- package/modern/index.d.ts +3 -0
- package/modern/index.js +12 -0
- package/modern/types.d.ts +113 -0
- package/modern/types.js +1 -0
- package/package.json +24 -0
- package/send-stats.js +82 -0
- package/types.d.ts +113 -0
- package/types.js +2 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import React, { useState, useRef, useEffect } from 'react';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
import { BackArrowAddon } from './components/back-arrow-addon/Component.js';
|
|
4
|
+
import { Closer } from './components/closer/Component.js';
|
|
5
|
+
import '@alfalab/core-components-button/modern';
|
|
6
|
+
import '@alfalab/core-components-typography/modern';
|
|
7
|
+
import '@alfalab/icons-glyph/ArrowLeftMediumMIcon';
|
|
8
|
+
import '@alfalab/icons-glyph/ArrowLeftMIcon';
|
|
9
|
+
import '@alfalab/core-components-icon-button/modern';
|
|
10
|
+
import '@alfalab/icons-glyph/CrossHeavyMIcon';
|
|
11
|
+
import '@alfalab/icons-glyph/CrossMIcon';
|
|
12
|
+
|
|
13
|
+
const getDataTestId = (dataTestId, element) => {
|
|
14
|
+
const elementPart = element ? `-${element.toLowerCase()}` : '';
|
|
15
|
+
return dataTestId ? `${dataTestId}${elementPart}` : undefined;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const styles = {"header":"navigation-bar__header_1ssvj","backgroundImage":"navigation-bar__backgroundImage_1ssvj","mainLine":"navigation-bar__mainLine_1ssvj","mainLineSticky":"navigation-bar__mainLineSticky_1ssvj","mainLineWithImageBg":"navigation-bar__mainLineWithImageBg_1ssvj","content":"navigation-bar__content_1ssvj","withBothAddons":"navigation-bar__withBothAddons_1ssvj","withCompactTitle":"navigation-bar__withCompactTitle_1ssvj","children":"navigation-bar__children_1ssvj","title":"navigation-bar__title_1ssvj","contentOnBotDesktop":"navigation-bar__contentOnBotDesktop_1ssvj","contentOnBotMobile":"navigation-bar__contentOnBotMobile_1ssvj","subtitle":"navigation-bar__subtitle_1ssvj","addonsWrapper":"navigation-bar__addonsWrapper_1ssvj","rightAddons":"navigation-bar__rightAddons_1ssvj","addon":"navigation-bar__addon_1ssvj","bottomAddons":"navigation-bar__bottomAddons_1ssvj","closer":"navigation-bar__closer_1ssvj","left":"navigation-bar__left_1ssvj","center":"navigation-bar__center_1ssvj","trim":"navigation-bar__trim_1ssvj"};
|
|
19
|
+
require('./index.css')
|
|
20
|
+
|
|
21
|
+
/* eslint-disable complexity */
|
|
22
|
+
const ADDONS_HEIGHT = 48;
|
|
23
|
+
const NavigationBar = ({ addonClassName, className, contentClassName, closerClassName, leftAddons, rightAddons, bottomAddons, bottomAddonsClassName, children, align = 'left', trim = true, title, titleSize = 'default', subtitle, hasCloser, hasBackButton, backButtonClassName, dataTestId, imageUrl, closerIcon, onClose, view, parentRef, sticky, onBack, }) => {
|
|
24
|
+
const [scrollTop, setScrollTop] = useState(0);
|
|
25
|
+
const bottomContentRef = useRef(null);
|
|
26
|
+
const headerRef = useRef(null);
|
|
27
|
+
const mainLinePaddingTopRef = useRef('0px');
|
|
28
|
+
const compactTitle = view === 'mobile' && titleSize === 'compact';
|
|
29
|
+
const hasLeftPart = Boolean(leftAddons || hasBackButton);
|
|
30
|
+
const hasRightPart = Boolean(rightAddons || hasCloser);
|
|
31
|
+
const hasContent = Boolean(title || children);
|
|
32
|
+
const withAnimation = Boolean(view === 'mobile' && hasLeftPart && sticky && !compactTitle);
|
|
33
|
+
const showContentOnTop = hasContent && (compactTitle || !hasLeftPart);
|
|
34
|
+
const showContentOnBot = hasContent && !compactTitle && hasLeftPart;
|
|
35
|
+
const showStaticContentOnTop = !withAnimation && showContentOnTop;
|
|
36
|
+
const showStaticContentOnBot = !withAnimation && showContentOnBot;
|
|
37
|
+
const showAnimatedContentOnTop = withAnimation && showContentOnBot && scrollTop > ADDONS_HEIGHT;
|
|
38
|
+
const showAnimatedContentOnBot = withAnimation && showContentOnBot;
|
|
39
|
+
const headerPaddingTop = mainLinePaddingTopRef.current;
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
const parent = parentRef?.current;
|
|
42
|
+
const handleScroll = (ev) => {
|
|
43
|
+
const divElement = ev.target;
|
|
44
|
+
setScrollTop(divElement.scrollTop);
|
|
45
|
+
};
|
|
46
|
+
if (withAnimation && headerRef.current) {
|
|
47
|
+
mainLinePaddingTopRef.current = getComputedStyle(headerRef.current).paddingTop;
|
|
48
|
+
}
|
|
49
|
+
if (withAnimation && parent) {
|
|
50
|
+
parent.addEventListener('scroll', handleScroll);
|
|
51
|
+
}
|
|
52
|
+
return () => parent?.removeEventListener('scroll', handleScroll);
|
|
53
|
+
}, [parentRef, withAnimation]);
|
|
54
|
+
const renderBackButton = () => {
|
|
55
|
+
let textOpacity = 1;
|
|
56
|
+
if (withAnimation) {
|
|
57
|
+
const height = hasContent ? ADDONS_HEIGHT : ADDONS_HEIGHT / 2;
|
|
58
|
+
textOpacity = Math.max(0, 1 - scrollTop / height);
|
|
59
|
+
}
|
|
60
|
+
else if (compactTitle) {
|
|
61
|
+
textOpacity = 0;
|
|
62
|
+
}
|
|
63
|
+
return (React.createElement("div", { className: cn(styles.addon, backButtonClassName) },
|
|
64
|
+
React.createElement(BackArrowAddon, { textOpacity: textOpacity, view: view, onClick: onBack, "data-test-id": getDataTestId(dataTestId, 'back-button') })));
|
|
65
|
+
};
|
|
66
|
+
const renderContent = (args = {}) => {
|
|
67
|
+
const { extraClassName, ref, style, hidden } = args;
|
|
68
|
+
return (React.createElement("div", { style: { ...style, visibility: hidden ? 'hidden' : 'visible' }, ref: ref, className: cn(styles.content, extraClassName, contentClassName, styles[align], {
|
|
69
|
+
[styles.trim]: trim,
|
|
70
|
+
[styles.withCompactTitle]: view === 'mobile' && compactTitle && hasContent,
|
|
71
|
+
}), "aria-hidden": hidden },
|
|
72
|
+
children && React.createElement("div", { className: styles.children }, children),
|
|
73
|
+
title && (React.createElement("div", { className: styles.title, "data-test-id": hidden ? undefined : getDataTestId(dataTestId, 'title') }, title)),
|
|
74
|
+
compactTitle && subtitle && React.createElement("div", { className: styles.subtitle }, subtitle)));
|
|
75
|
+
};
|
|
76
|
+
const renderCloser = () => (React.createElement("div", { className: cn(styles.addon, styles.closer, closerClassName) },
|
|
77
|
+
React.createElement(Closer, { view: view, icon: closerIcon, dataTestId: getDataTestId(dataTestId, 'closer'), onClose: onClose })));
|
|
78
|
+
return (React.createElement("div", { ref: headerRef, className: cn(styles.header, className, { [styles.backgroundImage]: imageUrl }), "data-test-id": getDataTestId(dataTestId), style: {
|
|
79
|
+
...(imageUrl && { backgroundImage: `url(${imageUrl})` }),
|
|
80
|
+
...(withAnimation &&
|
|
81
|
+
bottomContentRef.current && { top: -bottomContentRef.current.scrollHeight }),
|
|
82
|
+
} },
|
|
83
|
+
React.createElement("div", { className: cn(styles.mainLine, {
|
|
84
|
+
[styles.mainLineSticky]: withAnimation,
|
|
85
|
+
[styles.mainLineWithImageBg]: imageUrl,
|
|
86
|
+
}), style: {
|
|
87
|
+
...(withAnimation
|
|
88
|
+
? {
|
|
89
|
+
marginTop: `-${headerPaddingTop}`,
|
|
90
|
+
paddingTop: headerPaddingTop,
|
|
91
|
+
}
|
|
92
|
+
: null),
|
|
93
|
+
} },
|
|
94
|
+
hasLeftPart && (React.createElement("div", { className: styles.addonsWrapper },
|
|
95
|
+
hasBackButton && renderBackButton(),
|
|
96
|
+
leftAddons && (React.createElement("div", { className: cn(styles.addon, addonClassName) }, leftAddons)))),
|
|
97
|
+
showStaticContentOnTop && renderContent(),
|
|
98
|
+
showAnimatedContentOnTop &&
|
|
99
|
+
renderContent({
|
|
100
|
+
extraClassName: styles.withBothAddons,
|
|
101
|
+
style: {
|
|
102
|
+
opacity: Math.min(1, (scrollTop - ADDONS_HEIGHT) / ADDONS_HEIGHT),
|
|
103
|
+
},
|
|
104
|
+
}),
|
|
105
|
+
hasRightPart && (React.createElement("div", { className: cn(styles.addonsWrapper, styles.rightAddons) },
|
|
106
|
+
rightAddons && (React.createElement("div", { className: cn(styles.addon, addonClassName) }, rightAddons)),
|
|
107
|
+
hasCloser && renderCloser()))),
|
|
108
|
+
showAnimatedContentOnBot &&
|
|
109
|
+
renderContent({
|
|
110
|
+
ref: bottomContentRef,
|
|
111
|
+
extraClassName: styles.underAddons,
|
|
112
|
+
style: { opacity: Math.max(0, 1 - scrollTop / ADDONS_HEIGHT) },
|
|
113
|
+
hidden: scrollTop / ADDONS_HEIGHT > 1,
|
|
114
|
+
}),
|
|
115
|
+
showStaticContentOnBot &&
|
|
116
|
+
renderContent({
|
|
117
|
+
extraClassName: cn({
|
|
118
|
+
[styles.contentOnBotDesktop]: view === 'desktop',
|
|
119
|
+
[styles.contentOnBotMobile]: view === 'mobile',
|
|
120
|
+
}),
|
|
121
|
+
}),
|
|
122
|
+
bottomAddons && (React.createElement("div", { className: cn(styles.bottomAddons, bottomAddonsClassName) }, bottomAddons))));
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export { NavigationBar };
|
|
@@ -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;
|
|
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,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
import { Button } from '@alfalab/core-components-button/modern';
|
|
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__component_17er7","mobileComponent":"navigation-bar__mobileComponent_17er7","flex":"navigation-bar__flex_17er7","iconWrapper":"navigation-bar__iconWrapper_17er7","text":"navigation-bar__text_17er7","mobileWrapper":"navigation-bar__mobileWrapper_17er7"};
|
|
9
|
+
require('./index.css')
|
|
10
|
+
|
|
11
|
+
const BackArrowAddon = ({ text = 'Назад', onClick, className, textOpacity = 1, view, ...htmlAttributes }) => {
|
|
12
|
+
const Icon = view === 'desktop' ? ArrowLeftMediumMIcon : ArrowLeftMIcon;
|
|
13
|
+
return (React.createElement(Button, { view: 'ghost', size: view === 'mobile' ? 'xxs' : 's', onClick: onClick, "aria-label": '\u043D\u0430\u0437\u0430\u0434', className: cn(styles.component, { [styles.mobileComponent]: view === 'mobile' }, className), ...htmlAttributes },
|
|
14
|
+
React.createElement("div", { className: styles.flex },
|
|
15
|
+
React.createElement("div", { className: cn(styles.iconWrapper, {
|
|
16
|
+
[styles.mobileWrapper]: view === 'mobile',
|
|
17
|
+
}) },
|
|
18
|
+
React.createElement(Icon, null)),
|
|
19
|
+
textOpacity > 0 && (React.createElement(Typography.Text, { className: styles.text, view: view === 'desktop' ? 'primary-large' : 'component', weight: 'medium', style: { opacity: textOpacity } }, text)))));
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { BackArrowAddon };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/* hash: 18yu8 */
|
|
2
|
+
:root {
|
|
3
|
+
} /* deprecated */ :root {
|
|
4
|
+
--color-light-graphic-primary: #0b1f35;
|
|
5
|
+
--color-light-graphic-secondary: #6d7986;
|
|
6
|
+
--color-light-specialbg-secondary-transparent: rgba(11, 31, 53, 0.05);
|
|
7
|
+
--color-light-bg-primary-alpha-40: rgba(255, 255, 255, 0.4);
|
|
8
|
+
--color-light-graphic-primary-tint-20: rgb(60, 76, 93);
|
|
9
|
+
--color-light-graphic-primary-tint-30: rgb(84, 98, 114);
|
|
10
|
+
} :root {
|
|
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
|
+
} .navigation-bar__component_17er7 {
|
|
28
|
+
height: 100%;
|
|
29
|
+
background: var(--color-light-bg-primary-alpha-40);
|
|
30
|
+
-webkit-backdrop-filter: blur(10px);
|
|
31
|
+
backdrop-filter: blur(10px);
|
|
32
|
+
border-radius: var(--border-radius-pill)
|
|
33
|
+
} .navigation-bar__component_17er7 svg > path {
|
|
34
|
+
transition: fill 0.2s ease;
|
|
35
|
+
fill: var(--color-light-graphic-primary);
|
|
36
|
+
} .navigation-bar__component_17er7:hover svg > path {
|
|
37
|
+
fill: var(--color-light-graphic-primary-tint-20);
|
|
38
|
+
} .navigation-bar__component_17er7:active svg > path {
|
|
39
|
+
fill: var(--color-light-graphic-primary-tint-30);
|
|
40
|
+
} .navigation-bar__mobileComponent_17er7 {
|
|
41
|
+
height: 32px;
|
|
42
|
+
margin: 0 var(--gap-xs);
|
|
43
|
+
-webkit-backdrop-filter: none;
|
|
44
|
+
backdrop-filter: none;
|
|
45
|
+
background: none;
|
|
46
|
+
} .navigation-bar__flex_17er7 {
|
|
47
|
+
display: flex;
|
|
48
|
+
align-items: center;
|
|
49
|
+
} .navigation-bar__iconWrapper_17er7 {
|
|
50
|
+
display: inline-flex;
|
|
51
|
+
align-items: center;
|
|
52
|
+
justify-content: center;
|
|
53
|
+
height: 48px;
|
|
54
|
+
margin: 0 var(--gap-xs) 0 var(--gap-s);
|
|
55
|
+
border-radius: var(--border-radius-circle)
|
|
56
|
+
} .navigation-bar__iconWrapper_17er7 + .navigation-bar__text_17er7 {
|
|
57
|
+
margin-right: var(--gap-s);
|
|
58
|
+
} .navigation-bar__mobileWrapper_17er7 {
|
|
59
|
+
width: 32px;
|
|
60
|
+
height: 32px;
|
|
61
|
+
background: var(--color-light-specialbg-secondary-transparent);
|
|
62
|
+
-webkit-backdrop-filter: blur(10px);
|
|
63
|
+
backdrop-filter: blur(10px);
|
|
64
|
+
margin: 0
|
|
65
|
+
} .navigation-bar__mobileWrapper_17er7 + .navigation-bar__text_17er7 {
|
|
66
|
+
margin: 0 var(--gap-s) 0 var(--gap-xs);
|
|
67
|
+
} .navigation-bar__mobileWrapper_17er7 svg > path {
|
|
68
|
+
fill: var(--color-light-graphic-secondary);
|
|
69
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Component";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { BackArrowAddon } from './Component.js';
|
|
2
|
+
import 'react';
|
|
3
|
+
import 'classnames';
|
|
4
|
+
import '@alfalab/core-components-button/modern';
|
|
5
|
+
import '@alfalab/core-components-typography/modern';
|
|
6
|
+
import '@alfalab/icons-glyph/ArrowLeftMediumMIcon';
|
|
7
|
+
import '@alfalab/icons-glyph/ArrowLeftMIcon';
|
|
@@ -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__closer_8p6nd","button":"navigation-bar__button_8p6nd","mobile":"navigation-bar__mobile_8p6nd","sticky":"navigation-bar__sticky_8p6nd"};
|
|
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 };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/* hash: tfros */
|
|
2
|
+
:root {
|
|
3
|
+
} /* deprecated */ :root {
|
|
4
|
+
--color-light-graphic-primary: #0b1f35;
|
|
5
|
+
--color-light-graphic-secondary: #6d7986;
|
|
6
|
+
--color-light-specialbg-secondary-transparent: rgba(11, 31, 53, 0.05);
|
|
7
|
+
--color-light-bg-primary-alpha-40: rgba(255, 255, 255, 0.4);
|
|
8
|
+
} :root {
|
|
9
|
+
} :root {
|
|
10
|
+
} :root {
|
|
11
|
+
|
|
12
|
+
/* Hard */
|
|
13
|
+
|
|
14
|
+
/* Up */
|
|
15
|
+
|
|
16
|
+
/* Hard up */
|
|
17
|
+
} :root {
|
|
18
|
+
} :root {
|
|
19
|
+
} :root {
|
|
20
|
+
} :root {
|
|
21
|
+
} .navigation-bar__closer_8p6nd {
|
|
22
|
+
flex-shrink: 0;
|
|
23
|
+
width: 48px;
|
|
24
|
+
height: 48px;
|
|
25
|
+
margin-left: auto;
|
|
26
|
+
display: flex;
|
|
27
|
+
align-items: center;
|
|
28
|
+
justify-content: center;
|
|
29
|
+
} .navigation-bar__button_8p6nd {
|
|
30
|
+
background: var(--color-light-bg-primary-alpha-40);
|
|
31
|
+
-webkit-backdrop-filter: blur(10px);
|
|
32
|
+
backdrop-filter: blur(10px);
|
|
33
|
+
border-radius: 50px;
|
|
34
|
+
color: var(--color-light-graphic-primary)
|
|
35
|
+
} .navigation-bar__button_8p6nd.navigation-bar__mobile_8p6nd {
|
|
36
|
+
background: var(--color-light-specialbg-secondary-transparent);
|
|
37
|
+
color: var(--color-light-graphic-secondary);
|
|
38
|
+
} .navigation-bar__sticky_8p6nd {
|
|
39
|
+
position: sticky;
|
|
40
|
+
top: 0;
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Component";
|
package/modern/index.css
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/* hash: 72dgh */
|
|
2
|
+
:root {
|
|
3
|
+
} /* deprecated */ :root {
|
|
4
|
+
--color-light-text-primary: #0b1f35;
|
|
5
|
+
--color-light-text-secondary: rgba(11, 31, 53, 0.7);
|
|
6
|
+
} :root {
|
|
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__header_1ssvj {
|
|
22
|
+
width: 100%;
|
|
23
|
+
box-sizing: border-box;
|
|
24
|
+
transition: box-shadow 0.2s ease, background 0.2s ease
|
|
25
|
+
} .navigation-bar__header_1ssvj.navigation-bar__header_1ssvj.navigation-bar__backgroundImage_1ssvj {
|
|
26
|
+
background-repeat: no-repeat;
|
|
27
|
+
background-position: center;
|
|
28
|
+
background-size: cover;
|
|
29
|
+
} .navigation-bar__mainLine_1ssvj {
|
|
30
|
+
display: flex;
|
|
31
|
+
align-items: stretch;
|
|
32
|
+
justify-content: space-between;
|
|
33
|
+
z-index: 1;
|
|
34
|
+
background-color: inherit;
|
|
35
|
+
} .navigation-bar__mainLineSticky_1ssvj {
|
|
36
|
+
position: sticky;
|
|
37
|
+
top: 0;
|
|
38
|
+
} .navigation-bar__mainLineWithImageBg_1ssvj {
|
|
39
|
+
background-color: initial;
|
|
40
|
+
} .navigation-bar__content_1ssvj {
|
|
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__content_1ssvj.navigation-bar__withBothAddons_1ssvj,
|
|
50
|
+
.navigation-bar__content_1ssvj.navigation-bar__withCompactTitle_1ssvj {
|
|
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__content_1ssvj.navigation-bar__withBothAddons_1ssvj > .navigation-bar__children_1ssvj,
|
|
58
|
+
.navigation-bar__content_1ssvj.navigation-bar__withBothAddons_1ssvj > .navigation-bar__title_1ssvj,
|
|
59
|
+
.navigation-bar__content_1ssvj.navigation-bar__withCompactTitle_1ssvj > .navigation-bar__children_1ssvj,
|
|
60
|
+
.navigation-bar__content_1ssvj.navigation-bar__withCompactTitle_1ssvj > .navigation-bar__title_1ssvj {
|
|
61
|
+
-webkit-line-clamp: 1;
|
|
62
|
+
word-break: break-all;
|
|
63
|
+
} .navigation-bar__content_1ssvj.navigation-bar__contentOnBotDesktop_1ssvj.navigation-bar__contentOnBotDesktop_1ssvj {
|
|
64
|
+
padding-top: var(--gap-s);
|
|
65
|
+
} .navigation-bar__content_1ssvj.navigation-bar__contentOnBotMobile_1ssvj.navigation-bar__contentOnBotMobile_1ssvj {
|
|
66
|
+
padding-top: var(--gap-s);
|
|
67
|
+
} .navigation-bar__title_1ssvj {
|
|
68
|
+
word-break: break-word;
|
|
69
|
+
} .navigation-bar__subtitle_1ssvj {
|
|
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__addonsWrapper_1ssvj {
|
|
81
|
+
display: flex;
|
|
82
|
+
} .navigation-bar__rightAddons_1ssvj {
|
|
83
|
+
margin-left: auto;
|
|
84
|
+
} .navigation-bar__addon_1ssvj {
|
|
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__bottomAddons_1ssvj {
|
|
93
|
+
pointer-events: all;
|
|
94
|
+
} .navigation-bar__closer_1ssvj {
|
|
95
|
+
margin-left: auto;
|
|
96
|
+
} .navigation-bar__left_1ssvj {
|
|
97
|
+
text-align: left;
|
|
98
|
+
} .navigation-bar__center_1ssvj {
|
|
99
|
+
text-align: center;
|
|
100
|
+
} .navigation-bar__trim_1ssvj {
|
|
101
|
+
overflow: hidden
|
|
102
|
+
} .navigation-bar__trim_1ssvj .navigation-bar__title_1ssvj,
|
|
103
|
+
.navigation-bar__trim_1ssvj .navigation-bar__children_1ssvj {
|
|
104
|
+
-webkit-line-clamp: 2;
|
|
105
|
+
display: -webkit-box;
|
|
106
|
+
-webkit-box-orient: vertical;
|
|
107
|
+
overflow: hidden;
|
|
108
|
+
}
|
package/modern/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { NavigationBar } from './Component.js';
|
|
2
|
+
export { Closer } from './components/closer/Component.js';
|
|
3
|
+
import 'react';
|
|
4
|
+
import 'classnames';
|
|
5
|
+
import './components/back-arrow-addon/Component.js';
|
|
6
|
+
import '@alfalab/core-components-button/modern';
|
|
7
|
+
import '@alfalab/core-components-typography/modern';
|
|
8
|
+
import '@alfalab/icons-glyph/ArrowLeftMediumMIcon';
|
|
9
|
+
import '@alfalab/icons-glyph/ArrowLeftMIcon';
|
|
10
|
+
import '@alfalab/core-components-icon-button/modern';
|
|
11
|
+
import '@alfalab/icons-glyph/CrossHeavyMIcon';
|
|
12
|
+
import '@alfalab/icons-glyph/CrossMIcon';
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { ReactNode } from "react";
|
|
4
|
+
import { CloserProps } from "./components/closer/index";
|
|
5
|
+
type NavigationBarProps = {
|
|
6
|
+
/**
|
|
7
|
+
* Контент шапки
|
|
8
|
+
*/
|
|
9
|
+
children?: ReactNode;
|
|
10
|
+
/**
|
|
11
|
+
* Заголовок шапки
|
|
12
|
+
*/
|
|
13
|
+
title?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Подзаголовок (доступен только в мобильной версии)
|
|
16
|
+
*/
|
|
17
|
+
subtitle?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Размер заголовка (compact доступен только в мобильной версии)
|
|
20
|
+
*/
|
|
21
|
+
titleSize?: 'default' | 'compact';
|
|
22
|
+
/**
|
|
23
|
+
* Доп. класс для аддонов
|
|
24
|
+
*/
|
|
25
|
+
addonClassName?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Слот слева
|
|
28
|
+
*/
|
|
29
|
+
leftAddons?: ReactNode;
|
|
30
|
+
/**
|
|
31
|
+
* Слот справа
|
|
32
|
+
*/
|
|
33
|
+
rightAddons?: ReactNode;
|
|
34
|
+
/**
|
|
35
|
+
* Дополнительный класс для closer
|
|
36
|
+
*/
|
|
37
|
+
closerClassName?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Слот снизу
|
|
40
|
+
*/
|
|
41
|
+
bottomAddons?: ReactNode;
|
|
42
|
+
/**
|
|
43
|
+
* Наличие компонента крестика
|
|
44
|
+
*/
|
|
45
|
+
hasCloser?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Наличие кнопки "Назад"
|
|
48
|
+
*/
|
|
49
|
+
hasBackButton?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Дополнительный класс для правого аддона
|
|
52
|
+
*/
|
|
53
|
+
backButtonClassName?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Дополнительный класс
|
|
56
|
+
*/
|
|
57
|
+
className?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Дополнительный класс для контента
|
|
60
|
+
*/
|
|
61
|
+
contentClassName?: string;
|
|
62
|
+
/**
|
|
63
|
+
* Дополнительный класс для нижнего аддона
|
|
64
|
+
*/
|
|
65
|
+
bottomAddonsClassName?: string;
|
|
66
|
+
/**
|
|
67
|
+
* Выравнивание заголовка
|
|
68
|
+
*/
|
|
69
|
+
align?: 'left' | 'center';
|
|
70
|
+
/**
|
|
71
|
+
* Обрезать ли заголовок
|
|
72
|
+
*/
|
|
73
|
+
trim?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Фиксирует шапку
|
|
76
|
+
*/
|
|
77
|
+
sticky?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Идентификатор для систем автоматизированного тестирования
|
|
80
|
+
*/
|
|
81
|
+
dataTestId?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Фоновое изображение
|
|
84
|
+
*/
|
|
85
|
+
imageUrl?: string;
|
|
86
|
+
/**
|
|
87
|
+
* Иконка closer.
|
|
88
|
+
*/
|
|
89
|
+
closerIcon?: React.ElementType;
|
|
90
|
+
/**
|
|
91
|
+
* Обработчик закрытия
|
|
92
|
+
*/
|
|
93
|
+
onClose?: CloserProps['onClose'];
|
|
94
|
+
/**
|
|
95
|
+
* обработчик клика по кнопке "назад"
|
|
96
|
+
*/
|
|
97
|
+
onBack?: () => void;
|
|
98
|
+
/**
|
|
99
|
+
* Вид шапки - мобильный или десктоп
|
|
100
|
+
*/
|
|
101
|
+
view: 'desktop' | 'mobile';
|
|
102
|
+
/**
|
|
103
|
+
* Ссылка на родительскую ноду.
|
|
104
|
+
*/
|
|
105
|
+
parentRef?: React.RefObject<HTMLDivElement>;
|
|
106
|
+
};
|
|
107
|
+
type ContentParams = {
|
|
108
|
+
extraClassName?: string;
|
|
109
|
+
ref?: React.RefObject<HTMLDivElement>;
|
|
110
|
+
style?: React.CSSProperties;
|
|
111
|
+
hidden?: boolean;
|
|
112
|
+
};
|
|
113
|
+
export { NavigationBarProps, ContentParams };
|
package/modern/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@alfalab/core-components-navigation-bar",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Navigation bar component",
|
|
5
|
+
"keywords": [],
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "index.js",
|
|
8
|
+
"module": "./esm/index.js",
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public",
|
|
11
|
+
"directory": "dist"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@alfalab/core-components-icon-button": "^6.0.4",
|
|
15
|
+
"@alfalab/core-components-button": "^7.0.3",
|
|
16
|
+
"@alfalab/core-components-typography": "^3.2.0",
|
|
17
|
+
"@alfalab/icons-glyph": "^2.89.0",
|
|
18
|
+
"classnames": "^2.3.1",
|
|
19
|
+
"tslib": "^2.4.0"
|
|
20
|
+
},
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"react": "^16.9.0 || ^17.0.1 || ^18.0.0"
|
|
23
|
+
}
|
|
24
|
+
}
|