@gravity-ui/page-constructor 3.11.0 → 3.12.1
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/README.md +6 -6
- package/build/cjs/components/Media/Image/Image.js +3 -2
- package/build/cjs/hooks/useHeightCalculator.js +1 -1
- package/build/cjs/models/navigation.d.ts +3 -2
- package/build/{esm/navigation/components/Header/Header.css → cjs/navigation/components/DesktopNavigation/DesktopNavigation.css} +28 -36
- package/build/cjs/navigation/components/DesktopNavigation/DesktopNavigation.d.ts +4 -0
- package/build/cjs/navigation/components/DesktopNavigation/DesktopNavigation.js +21 -0
- package/build/cjs/navigation/components/MobileMenuButton/MobileMenuButton.css +7 -0
- package/build/cjs/navigation/components/MobileMenuButton/MobileMenuButton.d.ts +3 -0
- package/build/cjs/navigation/components/MobileMenuButton/MobileMenuButton.js +15 -0
- package/build/cjs/navigation/components/MobileNavigation/MobileNavigation.css +10 -5
- package/build/cjs/navigation/components/MobileNavigation/MobileNavigation.d.ts +1 -10
- package/build/cjs/navigation/components/MobileNavigation/MobileNavigation.js +7 -30
- package/build/cjs/navigation/components/Navigation/Navigation.css +8 -13
- package/build/cjs/navigation/components/Navigation/Navigation.d.ts +4 -7
- package/build/cjs/navigation/components/Navigation/Navigation.js +37 -15
- package/build/cjs/navigation/components/NavigationItem/NavigationItem.css +28 -0
- package/build/cjs/navigation/components/NavigationItem/NavigationItem.d.ts +3 -9
- package/build/cjs/navigation/components/NavigationItem/NavigationItem.js +15 -6
- package/build/cjs/navigation/components/NavigationItem/components/GithubButton/GithubButton.d.ts +1 -1
- package/build/cjs/navigation/components/NavigationItem/components/NavigationButton/NavigationButton.d.ts +1 -1
- package/build/cjs/navigation/components/NavigationItem/components/NavigationDropdown/NavigationDropdown.d.ts +5 -4
- package/build/cjs/navigation/components/NavigationItem/components/NavigationDropdown/NavigationDropdown.js +12 -7
- package/build/cjs/navigation/components/NavigationItem/components/NavigationLink/NavigationLink.d.ts +1 -1
- package/build/cjs/navigation/components/NavigationList/NavigationList.d.ts +3 -0
- package/build/cjs/navigation/components/NavigationList/NavigationList.js +11 -0
- package/build/cjs/navigation/components/NavigationListItem/NavigationListItem.d.ts +4 -13
- package/build/cjs/navigation/components/NavigationListItem/NavigationListItem.js +6 -13
- package/build/cjs/navigation/components/NavigationPopup/NavigationPopup.css +5 -4
- package/build/cjs/navigation/components/NavigationPopup/NavigationPopup.d.ts +1 -8
- package/build/cjs/navigation/components/NavigationPopup/NavigationPopup.js +6 -6
- package/build/cjs/navigation/containers/Layout/Layout.js +2 -2
- package/build/cjs/navigation/models.d.ts +63 -0
- package/build/cjs/navigation/{constants.js → models.js} +7 -1
- package/build/cjs/navigation/utils.d.ts +11 -1
- package/build/cjs/navigation/utils.js +19 -1
- package/build/esm/components/Media/Image/Image.js +3 -2
- package/build/esm/hooks/useHeightCalculator.js +1 -1
- package/build/esm/models/navigation.d.ts +3 -2
- package/build/{cjs/navigation/components/Header/Header.css → esm/navigation/components/DesktopNavigation/DesktopNavigation.css} +28 -36
- package/build/esm/navigation/components/DesktopNavigation/DesktopNavigation.d.ts +5 -0
- package/build/esm/navigation/components/DesktopNavigation/DesktopNavigation.js +19 -0
- package/build/esm/navigation/components/MobileMenuButton/MobileMenuButton.css +7 -0
- package/build/esm/navigation/components/MobileMenuButton/MobileMenuButton.d.ts +4 -0
- package/build/esm/navigation/components/MobileMenuButton/MobileMenuButton.js +11 -0
- package/build/esm/navigation/components/MobileNavigation/MobileNavigation.css +10 -5
- package/build/esm/navigation/components/MobileNavigation/MobileNavigation.d.ts +1 -10
- package/build/esm/navigation/components/MobileNavigation/MobileNavigation.js +9 -31
- package/build/esm/navigation/components/Navigation/Navigation.css +8 -13
- package/build/esm/navigation/components/Navigation/Navigation.d.ts +4 -7
- package/build/esm/navigation/components/Navigation/Navigation.js +35 -15
- package/build/esm/navigation/components/NavigationItem/NavigationItem.css +28 -0
- package/build/esm/navigation/components/NavigationItem/NavigationItem.d.ts +4 -9
- package/build/esm/navigation/components/NavigationItem/NavigationItem.js +16 -6
- package/build/esm/navigation/components/NavigationItem/components/GithubButton/GithubButton.d.ts +1 -1
- package/build/esm/navigation/components/NavigationItem/components/NavigationButton/NavigationButton.d.ts +1 -1
- package/build/esm/navigation/components/NavigationItem/components/NavigationDropdown/NavigationDropdown.d.ts +5 -4
- package/build/esm/navigation/components/NavigationItem/components/NavigationDropdown/NavigationDropdown.js +12 -7
- package/build/esm/navigation/components/NavigationItem/components/NavigationLink/NavigationLink.d.ts +1 -1
- package/build/esm/navigation/components/NavigationList/NavigationList.d.ts +3 -0
- package/build/esm/navigation/components/NavigationList/NavigationList.js +7 -0
- package/build/esm/navigation/components/NavigationListItem/NavigationListItem.d.ts +4 -14
- package/build/esm/navigation/components/NavigationListItem/NavigationListItem.js +5 -10
- package/build/esm/navigation/components/NavigationPopup/NavigationPopup.css +5 -4
- package/build/esm/navigation/components/NavigationPopup/NavigationPopup.d.ts +1 -8
- package/build/esm/navigation/components/NavigationPopup/NavigationPopup.js +6 -6
- package/build/esm/navigation/containers/Layout/Layout.js +2 -2
- package/build/esm/navigation/models.d.ts +63 -0
- package/build/esm/navigation/{constants.js → models.js} +6 -0
- package/build/esm/navigation/utils.d.ts +11 -1
- package/build/esm/navigation/utils.js +17 -0
- package/package.json +20 -13
- package/server/models/navigation.d.ts +3 -2
- package/widget/index.js +1 -1
- package/CHANGELOG.md +0 -1484
- package/build/cjs/navigation/components/Header/Header.d.ts +0 -8
- package/build/cjs/navigation/components/Header/Header.js +0 -86
- package/build/cjs/navigation/components/NavigationDropdownItem/NavigationDropdownItem.d.ts +0 -11
- package/build/cjs/navigation/components/NavigationDropdownItem/NavigationDropdownItem.js +0 -15
- package/build/cjs/navigation/components/NavigationListItem/NavigationListItem.css +0 -27
- package/build/cjs/navigation/constants.d.ts +0 -6
- package/build/esm/navigation/components/Header/Header.d.ts +0 -9
- package/build/esm/navigation/components/Header/Header.js +0 -82
- package/build/esm/navigation/components/NavigationDropdownItem/NavigationDropdownItem.d.ts +0 -11
- package/build/esm/navigation/components/NavigationDropdownItem/NavigationDropdownItem.js +0 -13
- package/build/esm/navigation/components/NavigationListItem/NavigationListItem.css +0 -27
- package/build/esm/navigation/constants.d.ts +0 -6
package/build/cjs/navigation/components/NavigationItem/components/NavigationLink/NavigationLink.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { NavigationLinkItem } from '../../../../../models';
|
|
3
|
-
import { NavigationItemProps } from '
|
|
3
|
+
import { NavigationItemProps } from '../../../../models';
|
|
4
4
|
type NavigationLinkProps = NavigationItemProps & NavigationLinkItem;
|
|
5
5
|
export declare const NavigationLink: React.FC<NavigationLinkProps>;
|
|
6
6
|
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NavigationList = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
+
const NavigationListItem_1 = tslib_1.__importDefault(require("../NavigationListItem/NavigationListItem"));
|
|
7
|
+
const NavigationList = (_a) => {
|
|
8
|
+
var { className, itemClassName, items } = _a, props = tslib_1.__rest(_a, ["className", "itemClassName", "items"]);
|
|
9
|
+
return (react_1.default.createElement("ul", { className: className }, items.map((item, index) => (react_1.default.createElement(NavigationListItem_1.default, Object.assign({ key: index, index: index, data: item, className: itemClassName }, props))))));
|
|
10
|
+
};
|
|
11
|
+
exports.NavigationList = NavigationList;
|
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
index: number;
|
|
6
|
-
column: ItemColumnName;
|
|
7
|
-
activeItemId?: string;
|
|
8
|
-
highlightActiveItem?: boolean;
|
|
9
|
-
hidePopup: () => void;
|
|
10
|
-
onActiveItemChange: (id?: string) => void;
|
|
11
|
-
} & ClassNameProps;
|
|
12
|
-
export declare const NavigationListItem: ({ item, className, index, activeItemId, highlightActiveItem, hidePopup, column, onActiveItemChange, }: NavigationListItemProps) => JSX.Element;
|
|
13
|
-
export {};
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { NavigationListItemProps } from '../../models';
|
|
3
|
+
declare const NavigationListItem: React.FC<NavigationListItemProps>;
|
|
4
|
+
export default NavigationListItem;
|
|
@@ -1,26 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NavigationListItem = void 0;
|
|
4
3
|
const tslib_1 = require("tslib");
|
|
5
4
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
-
const
|
|
7
|
-
const utils_1 = require("../../../utils");
|
|
8
|
-
const utils_2 = require("../../utils");
|
|
9
|
-
const NavigationDropdownItem_1 = tslib_1.__importDefault(require("../NavigationDropdownItem/NavigationDropdownItem"));
|
|
5
|
+
const utils_1 = require("../../utils");
|
|
10
6
|
const NavigationItem_1 = tslib_1.__importDefault(require("../NavigationItem/NavigationItem"));
|
|
11
|
-
const
|
|
12
|
-
|
|
7
|
+
const NavigationListItem = (_a) => {
|
|
8
|
+
var { column, index, activeItemId, onActiveItemChange } = _a, props = tslib_1.__rest(_a, ["column", "index", "activeItemId", "onActiveItemChange"]);
|
|
13
9
|
const id = `${column}-${index}`;
|
|
14
10
|
const isActive = id === activeItemId;
|
|
15
|
-
const onClick = (0,
|
|
11
|
+
const onClick = (0, utils_1.getItemClickHandler)({
|
|
16
12
|
column,
|
|
17
13
|
index,
|
|
18
14
|
activeItemId,
|
|
19
15
|
onActiveItemChange,
|
|
20
16
|
});
|
|
21
|
-
return (react_1.default.createElement(
|
|
22
|
-
item.type === models_1.NavigationItemType.Dropdown ? (react_1.default.createElement(NavigationDropdownItem_1.default, { className: b('content'), data: item, onClick: onClick, isActive: isActive, hidePopup: hidePopup })) : (react_1.default.createElement(NavigationItem_1.default, { className: b('content'), data: item, onClick: onClick })),
|
|
23
|
-
highlightActiveItem && isActive && (react_1.default.createElement("div", { className: b('slider-container') },
|
|
24
|
-
react_1.default.createElement("div", { className: b('slider') })))));
|
|
17
|
+
return (react_1.default.createElement(NavigationItem_1.default, Object.assign({ isActive: isActive, onClick: onClick, hidePopup: onActiveItemChange }, props)));
|
|
25
18
|
};
|
|
26
|
-
exports.
|
|
19
|
+
exports.default = NavigationListItem;
|
|
@@ -14,13 +14,14 @@ unpredictable css rules order in build */
|
|
|
14
14
|
background: var(--yc-color-base-float);
|
|
15
15
|
box-shadow: 0 3px 10px var(--yc-color-sfx-shadow);
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
.pc-navigation-popup__list {
|
|
18
|
+
margin: 0;
|
|
19
|
+
padding: 0;
|
|
20
|
+
list-style: none;
|
|
21
21
|
}
|
|
22
22
|
.pc-navigation-popup__link {
|
|
23
23
|
height: 36px;
|
|
24
|
+
line-height: 20px;
|
|
24
25
|
padding: 8px 12px;
|
|
25
26
|
border-radius: 8px;
|
|
26
27
|
}
|
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
export interface NavigationPopupProps {
|
|
4
|
-
open: boolean;
|
|
5
|
-
items: NavigationLinkItem[];
|
|
6
|
-
onClose: () => void;
|
|
7
|
-
className?: string;
|
|
8
|
-
anchorRef: React.RefObject<Element>;
|
|
9
|
-
}
|
|
2
|
+
import { NavigationPopupProps } from '../../models';
|
|
10
3
|
export declare const NavigationPopup: React.FC<NavigationPopupProps>;
|
|
11
4
|
export default NavigationPopup;
|
|
@@ -5,15 +5,15 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
6
|
const uikit_1 = require("@gravity-ui/uikit");
|
|
7
7
|
const utils_1 = require("../../../utils");
|
|
8
|
+
const models_1 = require("../../models");
|
|
8
9
|
const NavigationItem_1 = tslib_1.__importDefault(require("../NavigationItem/NavigationItem"));
|
|
9
10
|
const b = (0, utils_1.block)('navigation-popup');
|
|
10
11
|
const OFFSET_RESET = [0, 0];
|
|
11
|
-
const NavigationPopup = ({ anchorRef, items, onClose, className, open, }) =>
|
|
12
|
-
|
|
12
|
+
const NavigationPopup = ({ anchorRef, items, onClose, className, open, }) => (react_1.default.createElement(uikit_1.Popup
|
|
13
|
+
// Workaround to recalculate position on every opening. Required for valid position calculation for scrolled header links.
|
|
14
|
+
, {
|
|
13
15
|
// Workaround to recalculate position on every opening. Required for valid position calculation for scrolled header links.
|
|
14
|
-
,
|
|
15
|
-
|
|
16
|
-
anchorRef: open ? anchorRef : undefined, className: b(null, className), open: open, onClose: onClose, onOutsideClick: onClose, keepMounted: true, disablePortal: true, strategy: "fixed", placement: "bottom-start", offset: OFFSET_RESET }, items.map((item) => (react_1.default.createElement(NavigationItem_1.default, { key: item.text, className: b('link'), data: item })))));
|
|
17
|
-
};
|
|
16
|
+
anchorRef: open ? anchorRef : undefined, className: b(null, className), open: open, onClose: onClose, onOutsideClick: onClose, keepMounted: true, disablePortal: true, strategy: "fixed", placement: "bottom-start", offset: OFFSET_RESET },
|
|
17
|
+
react_1.default.createElement("ul", { className: b('list') }, items.map((item) => (react_1.default.createElement(NavigationItem_1.default, { key: item.text, className: b('link'), data: item, menuLayout: models_1.NavigationLayout.Dropdown }))))));
|
|
18
18
|
exports.NavigationPopup = NavigationPopup;
|
|
19
19
|
exports.default = exports.NavigationPopup;
|
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
5
5
|
const utils_1 = require("../../../utils");
|
|
6
|
-
const
|
|
6
|
+
const Navigation_1 = tslib_1.__importDefault(require("../../components/Navigation/Navigation"));
|
|
7
7
|
const b = (0, utils_1.block)('layout');
|
|
8
8
|
const Layout = ({ children, navigation }) => (react_1.default.createElement("div", { className: b() },
|
|
9
|
-
navigation && react_1.default.createElement(
|
|
9
|
+
navigation && react_1.default.createElement(Navigation_1.default, { data: navigation.header, logo: navigation.logo }),
|
|
10
10
|
react_1.default.createElement("main", { className: b('content') }, children)));
|
|
11
11
|
exports.default = Layout;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { MouseEventHandler } from 'react';
|
|
2
|
+
import { ClassNameProps, NavigationItemData, NavigationItemModel, NavigationLinkItem, ThemedNavigationLogoData } from '../models';
|
|
3
|
+
export interface MobileMenuButtonProps {
|
|
4
|
+
isSidebarOpened: boolean;
|
|
5
|
+
onSidebarOpenedChange: (arg: boolean) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare enum ItemColumnName {
|
|
8
|
+
Left = "left",
|
|
9
|
+
Right = "right",
|
|
10
|
+
Top = "top",
|
|
11
|
+
Bottom = "bottom"
|
|
12
|
+
}
|
|
13
|
+
export declare enum NavigationLayout {
|
|
14
|
+
Desktop = "desktop",
|
|
15
|
+
Mobile = "mobile",
|
|
16
|
+
Dropdown = "dropdown"
|
|
17
|
+
}
|
|
18
|
+
export interface ActiveItemProps {
|
|
19
|
+
activeItemId?: string;
|
|
20
|
+
onActiveItemChange: (id?: string) => void;
|
|
21
|
+
}
|
|
22
|
+
export interface MenuLayoutProps {
|
|
23
|
+
menuLayout?: NavigationLayout;
|
|
24
|
+
}
|
|
25
|
+
export interface NavigationItemProps extends ClassNameProps, MenuLayoutProps {
|
|
26
|
+
data: NavigationItemData;
|
|
27
|
+
onClick?: MouseEventHandler;
|
|
28
|
+
isActive?: boolean;
|
|
29
|
+
isTopLevel?: boolean;
|
|
30
|
+
hidePopup?: () => void;
|
|
31
|
+
}
|
|
32
|
+
export interface NavigationListItemProps extends MenuLayoutProps, ActiveItemProps, ClassNameProps {
|
|
33
|
+
data: NavigationItemModel;
|
|
34
|
+
column: ItemColumnName;
|
|
35
|
+
index: number;
|
|
36
|
+
}
|
|
37
|
+
export interface NavigationListProps extends Pick<NavigationListItemProps, 'column'>, MenuLayoutProps, ActiveItemProps, ClassNameProps {
|
|
38
|
+
items: NavigationItemModel[];
|
|
39
|
+
itemClassName?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface ItemsWrapperProps extends Pick<NavigationListProps, 'items'>, ActiveItemProps, ClassNameProps {
|
|
42
|
+
}
|
|
43
|
+
export interface DesktopNavigationProps extends MobileMenuButtonProps, ActiveItemProps {
|
|
44
|
+
logo: ThemedNavigationLogoData;
|
|
45
|
+
leftItemsWithIconSize: NavigationItemModel[];
|
|
46
|
+
rightItemsWithIconSize?: NavigationItemModel[];
|
|
47
|
+
}
|
|
48
|
+
export interface MobileNavigationProps extends ClassNameProps, ActiveItemProps {
|
|
49
|
+
isOpened?: boolean;
|
|
50
|
+
topItems?: NavigationItemModel[];
|
|
51
|
+
bottomItems?: NavigationItemModel[];
|
|
52
|
+
}
|
|
53
|
+
export interface NavigationProps extends MobileMenuButtonProps, ActiveItemProps {
|
|
54
|
+
logo: ThemedNavigationLogoData;
|
|
55
|
+
leftItemsWithIconSize: NavigationItemModel[];
|
|
56
|
+
rightItemsWithIconSize?: NavigationItemModel[];
|
|
57
|
+
}
|
|
58
|
+
export interface NavigationPopupProps extends ClassNameProps {
|
|
59
|
+
open: boolean;
|
|
60
|
+
items: NavigationLinkItem[];
|
|
61
|
+
onClose: () => void;
|
|
62
|
+
anchorRef: React.RefObject<Element>;
|
|
63
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ItemColumnName = void 0;
|
|
3
|
+
exports.NavigationLayout = exports.ItemColumnName = void 0;
|
|
4
4
|
var ItemColumnName;
|
|
5
5
|
(function (ItemColumnName) {
|
|
6
6
|
ItemColumnName["Left"] = "left";
|
|
@@ -8,3 +8,9 @@ var ItemColumnName;
|
|
|
8
8
|
ItemColumnName["Top"] = "top";
|
|
9
9
|
ItemColumnName["Bottom"] = "bottom";
|
|
10
10
|
})(ItemColumnName = exports.ItemColumnName || (exports.ItemColumnName = {}));
|
|
11
|
+
var NavigationLayout;
|
|
12
|
+
(function (NavigationLayout) {
|
|
13
|
+
NavigationLayout["Desktop"] = "desktop";
|
|
14
|
+
NavigationLayout["Mobile"] = "mobile";
|
|
15
|
+
NavigationLayout["Dropdown"] = "dropdown";
|
|
16
|
+
})(NavigationLayout = exports.NavigationLayout || (exports.NavigationLayout = {}));
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { MouseEventHandler } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { NavigationButtonItem, NavigationDropdownItem, NavigationItemModel, NavigationItemType } from '../models';
|
|
3
|
+
import { ItemColumnName } from './models';
|
|
3
4
|
type GetItemClickHandlerArgs = {
|
|
4
5
|
column: ItemColumnName;
|
|
5
6
|
index: number;
|
|
@@ -7,4 +8,13 @@ type GetItemClickHandlerArgs = {
|
|
|
7
8
|
onActiveItemChange: (id?: string) => void;
|
|
8
9
|
};
|
|
9
10
|
export declare const getItemClickHandler: ({ column, index, onActiveItemChange, }: GetItemClickHandlerArgs) => MouseEventHandler;
|
|
11
|
+
export declare function getNavigationItemWithIconSize(iconSize?: number): (item: NavigationItemModel) => NavigationButtonItem | NavigationDropdownItem | {
|
|
12
|
+
type: NavigationItemType.Link;
|
|
13
|
+
url: string;
|
|
14
|
+
arrow?: boolean | undefined;
|
|
15
|
+
target?: string | undefined;
|
|
16
|
+
text: string;
|
|
17
|
+
icon?: import("../models").ImageProps | undefined;
|
|
18
|
+
iconSize?: number | undefined;
|
|
19
|
+
};
|
|
10
20
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getItemClickHandler = void 0;
|
|
3
|
+
exports.getNavigationItemWithIconSize = exports.getItemClickHandler = void 0;
|
|
4
|
+
const models_1 = require("../models");
|
|
4
5
|
const getItemClickHandler = ({ column, index, onActiveItemChange, activeItemId }) => (e) => {
|
|
5
6
|
const id = `${column}-${index}`;
|
|
6
7
|
if (e) {
|
|
@@ -9,3 +10,20 @@ const getItemClickHandler = ({ column, index, onActiveItemChange, activeItemId }
|
|
|
9
10
|
onActiveItemChange(id === activeItemId ? undefined : `${column}-${index}`);
|
|
10
11
|
};
|
|
11
12
|
exports.getItemClickHandler = getItemClickHandler;
|
|
13
|
+
const isButtonItem = (item) => item.type === models_1.NavigationItemType.Button;
|
|
14
|
+
const isDropdownItem = (item) => item.type === models_1.NavigationItemType.Dropdown;
|
|
15
|
+
const iconSizeKey = 'iconSize';
|
|
16
|
+
function getNavigationItemWithIconSize(iconSize = 20) {
|
|
17
|
+
const getItem = (item) => {
|
|
18
|
+
const newItem = Object.assign({}, item);
|
|
19
|
+
if ('items' in newItem && isDropdownItem(newItem)) {
|
|
20
|
+
newItem.items = newItem.items.map(getItem);
|
|
21
|
+
}
|
|
22
|
+
if (!(iconSizeKey in newItem) && !isButtonItem(newItem)) {
|
|
23
|
+
newItem.iconSize = iconSize;
|
|
24
|
+
}
|
|
25
|
+
return newItem;
|
|
26
|
+
};
|
|
27
|
+
return getItem;
|
|
28
|
+
}
|
|
29
|
+
exports.getNavigationItemWithIconSize = getNavigationItemWithIconSize;
|
|
@@ -21,8 +21,9 @@ const Image = (props) => {
|
|
|
21
21
|
useEffect(() => {
|
|
22
22
|
if (parallax) {
|
|
23
23
|
const handleScroll = () => setScrollY(window.scrollY);
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
const debouncedHandler = _.debounce(handleScroll, 5);
|
|
25
|
+
window.addEventListener('scroll', debouncedHandler, { passive: true });
|
|
26
|
+
return () => window.removeEventListener('scroll', debouncedHandler);
|
|
26
27
|
}
|
|
27
28
|
return () => { };
|
|
28
29
|
});
|
|
@@ -13,7 +13,7 @@ const useHeightCalculator = (containerRef, options = DEFAULT_OPTIONS) => {
|
|
|
13
13
|
}, [containerRef, containerHeight, setContainerHeight]);
|
|
14
14
|
useEffect(() => {
|
|
15
15
|
const handleResize = _.debounce(calculateContainerHeight, recalculateOnResizeDelay);
|
|
16
|
-
|
|
16
|
+
handleResize();
|
|
17
17
|
window.addEventListener('resize', handleResize, { passive: true });
|
|
18
18
|
return () => {
|
|
19
19
|
window.removeEventListener('resize', handleResize);
|
|
@@ -44,6 +44,8 @@ export interface NavigationButtonItem extends ButtonProps {
|
|
|
44
44
|
export interface NavigationDropdownItem extends NavigationItemBase {
|
|
45
45
|
type: NavigationItemType.Dropdown;
|
|
46
46
|
items: NavigationLinkItem[];
|
|
47
|
+
hidePopup: () => void;
|
|
48
|
+
isActive: boolean;
|
|
47
49
|
}
|
|
48
50
|
export interface NavigationSocialItem extends Omit<NavigationItemBase, 'text'> {
|
|
49
51
|
type: NavigationItemType.Social;
|
|
@@ -51,8 +53,7 @@ export interface NavigationSocialItem extends Omit<NavigationItemBase, 'text'> {
|
|
|
51
53
|
url: string;
|
|
52
54
|
}
|
|
53
55
|
export type NavigationItemModel = NavigationLinkItem | NavigationButtonItem | NavigationDropdownItem;
|
|
54
|
-
export type NavigationItemData = NavigationLinkItem | NavigationButtonItem | NavigationSocialItem |
|
|
55
|
-
export type DropdownItemData = Omit<NavigationDropdownItem, 'items'>;
|
|
56
|
+
export type NavigationItemData = NavigationLinkItem | NavigationButtonItem | NavigationSocialItem | NavigationDropdownItem;
|
|
56
57
|
export interface NavigationLogoData {
|
|
57
58
|
icon: ImageProps;
|
|
58
59
|
text?: string;
|
|
@@ -1,52 +1,39 @@
|
|
|
1
1
|
/* use this for style redefinitions to awoid problems with
|
|
2
2
|
unpredictable css rules order in build */
|
|
3
|
-
.pc-
|
|
4
|
-
position: sticky;
|
|
5
|
-
z-index: 98;
|
|
6
|
-
top: 0;
|
|
7
|
-
display: flex;
|
|
8
|
-
justify-content: center;
|
|
9
|
-
align-items: center;
|
|
10
|
-
height: var(--header-height);
|
|
11
|
-
background-color: var(--yc-color-base-background);
|
|
12
|
-
}
|
|
13
|
-
.pc-header_with-border {
|
|
14
|
-
box-shadow: inset 0 -1px 0 var(--yc-color-line-generic);
|
|
15
|
-
}
|
|
16
|
-
.pc-header__wrapper {
|
|
3
|
+
.pc-desktop-navigation__wrapper {
|
|
17
4
|
display: flex;
|
|
18
5
|
justify-content: space-between;
|
|
19
6
|
align-items: center;
|
|
20
7
|
height: var(--header-height);
|
|
21
8
|
}
|
|
22
9
|
@media (min-width: 769px) {
|
|
23
|
-
.pc-
|
|
10
|
+
.pc-desktop-navigation__mobile-menu-button.pc-desktop-navigation__mobile-menu-button {
|
|
24
11
|
display: none;
|
|
25
12
|
}
|
|
26
13
|
}
|
|
27
14
|
|
|
28
|
-
.pc-
|
|
15
|
+
.pc-desktop-navigation__navigation, .pc-desktop-navigation__left, .pc-desktop-navigation__right {
|
|
29
16
|
display: flex;
|
|
30
17
|
align-items: center;
|
|
31
18
|
}
|
|
32
|
-
.pc-
|
|
19
|
+
.pc-desktop-navigation__navigation.pc-desktop-navigation__navigation {
|
|
33
20
|
position: relative;
|
|
34
21
|
flex: 1 0 0;
|
|
35
22
|
justify-content: flex-start;
|
|
36
23
|
}
|
|
37
24
|
@media (max-width: 768px) {
|
|
38
|
-
.pc-
|
|
25
|
+
.pc-desktop-navigation__navigation.pc-desktop-navigation__navigation {
|
|
39
26
|
display: none;
|
|
40
27
|
}
|
|
41
28
|
}
|
|
42
29
|
|
|
43
|
-
.pc-
|
|
30
|
+
.pc-desktop-navigation__right {
|
|
44
31
|
flex: 0;
|
|
45
32
|
justify-content: flex-end;
|
|
46
33
|
font-size: var(--yc-text-body-2-font-size);
|
|
47
34
|
line-height: var(--yc-text-body-2-line-height);
|
|
48
35
|
}
|
|
49
|
-
.pc-
|
|
36
|
+
.pc-desktop-navigation__navigation-container {
|
|
50
37
|
display: flex;
|
|
51
38
|
overflow-x: hidden;
|
|
52
39
|
flex: 1 0 0;
|
|
@@ -54,7 +41,14 @@ unpredictable css rules order in build */
|
|
|
54
41
|
align-items: center;
|
|
55
42
|
margin-right: 32px;
|
|
56
43
|
}
|
|
57
|
-
.pc-
|
|
44
|
+
.pc-desktop-navigation__button {
|
|
45
|
+
margin-top: 0;
|
|
46
|
+
}
|
|
47
|
+
.pc-desktop-navigation__logo {
|
|
48
|
+
margin: 0 32px 0 0;
|
|
49
|
+
cursor: pointer;
|
|
50
|
+
}
|
|
51
|
+
.pc-desktop-navigation__buttons, .pc-desktop-navigation__links {
|
|
58
52
|
display: flex;
|
|
59
53
|
align-items: center;
|
|
60
54
|
margin: 0;
|
|
@@ -62,39 +56,37 @@ unpredictable css rules order in build */
|
|
|
62
56
|
list-style: none;
|
|
63
57
|
}
|
|
64
58
|
@media (max-width: 768px) {
|
|
65
|
-
.pc-
|
|
59
|
+
.pc-desktop-navigation__buttons {
|
|
66
60
|
display: none;
|
|
67
61
|
}
|
|
68
62
|
}
|
|
69
|
-
.pc-
|
|
63
|
+
.pc-desktop-navigation__buttons > *:not(:last-child) {
|
|
70
64
|
margin-right: 16px;
|
|
71
65
|
}
|
|
72
|
-
.pc-
|
|
66
|
+
.pc-desktop-navigation__links {
|
|
73
67
|
position: relative;
|
|
68
|
+
font-size: var(--yc-text-body-2-font-size);
|
|
69
|
+
line-height: var(--yc-text-body-2-line-height);
|
|
74
70
|
}
|
|
75
|
-
.pc-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
.pc-header__button {
|
|
79
|
-
margin-top: 0;
|
|
71
|
+
.pc-desktop-navigation__item {
|
|
72
|
+
position: relative;
|
|
80
73
|
}
|
|
81
|
-
.pc-
|
|
82
|
-
margin:
|
|
83
|
-
cursor: pointer;
|
|
74
|
+
.pc-desktop-navigation__item:not(:last-child) {
|
|
75
|
+
margin-right: 20px;
|
|
84
76
|
}
|
|
85
77
|
@media (max-width: 768px) {
|
|
86
|
-
.pc-
|
|
78
|
+
.pc-desktop-navigation__navigation-container {
|
|
87
79
|
justify-content: flex-end;
|
|
88
80
|
}
|
|
89
|
-
.pc-
|
|
81
|
+
.pc-desktop-navigation__left {
|
|
90
82
|
flex: 1 0 0;
|
|
91
83
|
}
|
|
92
84
|
}
|
|
93
85
|
@media (max-width: 576px) {
|
|
94
|
-
.pc-
|
|
86
|
+
.pc-desktop-navigation__navigation-container {
|
|
95
87
|
margin-right: 12px;
|
|
96
88
|
}
|
|
97
|
-
.pc-
|
|
89
|
+
.pc-desktop-navigation__logo {
|
|
98
90
|
margin-right: 0;
|
|
99
91
|
}
|
|
100
92
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import OverflowScroller from '../../../components/OverflowScroller/OverflowScroller';
|
|
3
|
+
import { block } from '../../../utils';
|
|
4
|
+
import { ItemColumnName, NavigationLayout } from '../../models';
|
|
5
|
+
import Logo from '../Logo/Logo';
|
|
6
|
+
import { MobileMenuButton } from '../MobileMenuButton/MobileMenuButton';
|
|
7
|
+
import { NavigationList } from '../NavigationList/NavigationList';
|
|
8
|
+
import './DesktopNavigation.css';
|
|
9
|
+
const b = block('desktop-navigation');
|
|
10
|
+
const DesktopNavigation = ({ logo, leftItemsWithIconSize, rightItemsWithIconSize, isSidebarOpened, onSidebarOpenedChange, onActiveItemChange, activeItemId, }) => (React.createElement("div", { className: b('wrapper') },
|
|
11
|
+
logo && (React.createElement("div", { className: b('left') },
|
|
12
|
+
React.createElement(Logo, Object.assign({}, logo, { className: b('logo') })))),
|
|
13
|
+
React.createElement("div", { className: b('navigation-container') },
|
|
14
|
+
React.createElement(OverflowScroller, { className: b('navigation'), onScrollStart: onActiveItemChange },
|
|
15
|
+
React.createElement(NavigationList, { items: leftItemsWithIconSize, onActiveItemChange: onActiveItemChange, className: b('links'), itemClassName: b('item'), column: ItemColumnName.Left, activeItemId: activeItemId, menuLayout: NavigationLayout.Desktop }))),
|
|
16
|
+
React.createElement("div", { className: b('right') },
|
|
17
|
+
React.createElement(MobileMenuButton, { isSidebarOpened: isSidebarOpened, onSidebarOpenedChange: onSidebarOpenedChange }),
|
|
18
|
+
rightItemsWithIconSize && (React.createElement(NavigationList, { onActiveItemChange: onActiveItemChange, column: ItemColumnName.Right, items: rightItemsWithIconSize, activeItemId: activeItemId, className: b('buttons'), itemClassName: b('item'), menuLayout: NavigationLayout.Desktop })))));
|
|
19
|
+
export default DesktopNavigation;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Control } from '../../../components';
|
|
3
|
+
import { NavigationClose, NavigationOpen } from '../../../icons';
|
|
4
|
+
import { block } from '../../../utils';
|
|
5
|
+
import './MobileMenuButton.css';
|
|
6
|
+
const b = block('mobile-menu-button');
|
|
7
|
+
const ICON_SIZE = 36;
|
|
8
|
+
export const MobileMenuButton = ({ isSidebarOpened, onSidebarOpenedChange, }) => (React.createElement(Control, { className: b(), onClick: (e) => {
|
|
9
|
+
e.stopPropagation();
|
|
10
|
+
onSidebarOpenedChange(!isSidebarOpened);
|
|
11
|
+
}, size: "l", icon: isSidebarOpened ? NavigationClose : NavigationOpen, iconSize: ICON_SIZE }));
|
|
@@ -10,9 +10,16 @@ unpredictable css rules order in build */
|
|
|
10
10
|
border-bottom-left-radius: var(--pc-border-radius);
|
|
11
11
|
background-color: var(--yc-color-base-background);
|
|
12
12
|
box-shadow: 0 3px 10px var(--yc-color-sfx-shadow);
|
|
13
|
+
max-height: calc(100vh - 2 * var(--header-height));
|
|
14
|
+
overflow-y: scroll;
|
|
15
|
+
scrollbar-width: none;
|
|
16
|
+
-ms-overflow-style: none;
|
|
13
17
|
font-size: var(--yc-text-body-2-font-size);
|
|
14
18
|
line-height: var(--yc-text-body-2-line-height);
|
|
15
19
|
}
|
|
20
|
+
.pc-mobile-navigation::-webkit-scrollbar {
|
|
21
|
+
display: none;
|
|
22
|
+
}
|
|
16
23
|
@media (min-width: 769px) {
|
|
17
24
|
.pc-mobile-navigation {
|
|
18
25
|
display: none;
|
|
@@ -24,9 +31,6 @@ unpredictable css rules order in build */
|
|
|
24
31
|
.pc-mobile-navigation__button {
|
|
25
32
|
margin-top: 24px;
|
|
26
33
|
}
|
|
27
|
-
.pc-mobile-navigation__nav {
|
|
28
|
-
margin-bottom: 24px;
|
|
29
|
-
}
|
|
30
34
|
.pc-mobile-navigation__rows {
|
|
31
35
|
position: relative;
|
|
32
36
|
display: flex;
|
|
@@ -35,10 +39,11 @@ unpredictable css rules order in build */
|
|
|
35
39
|
margin: 0;
|
|
36
40
|
padding: 0;
|
|
37
41
|
list-style: none;
|
|
38
|
-
}
|
|
39
|
-
.pc-mobile-navigation__rows-item:not(:last-child) {
|
|
40
42
|
margin-bottom: 24px;
|
|
41
43
|
}
|
|
44
|
+
.pc-mobile-navigation__rows:last-child {
|
|
45
|
+
margin-bottom: 0;
|
|
46
|
+
}
|
|
42
47
|
.pc-mobile-navigation__dropdown-item:not(:last-child) {
|
|
43
48
|
margin-bottom: 16px;
|
|
44
49
|
}
|
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { MobileNavigationProps } from '../../models';
|
|
3
3
|
import './MobileNavigation.css';
|
|
4
|
-
export interface MobileNavigationProps {
|
|
5
|
-
className?: string;
|
|
6
|
-
isOpened?: boolean;
|
|
7
|
-
topItems?: NavigationItemModel[];
|
|
8
|
-
bottomItems?: NavigationItemModel[];
|
|
9
|
-
activeItemId?: string;
|
|
10
|
-
onClose: () => void;
|
|
11
|
-
onActiveItemChange: (id?: string) => void;
|
|
12
|
-
}
|
|
13
4
|
declare const MobileNavigation: React.FC<MobileNavigationProps>;
|
|
14
5
|
export default MobileNavigation;
|
|
@@ -1,43 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Portal } from '@gravity-ui/uikit';
|
|
3
4
|
import Foldable from '../../../components/Foldable/Foldable';
|
|
4
|
-
import { NavigationItemType } from '../../../models';
|
|
5
5
|
import { block } from '../../../utils';
|
|
6
|
-
import { ItemColumnName } from '../../
|
|
7
|
-
import
|
|
6
|
+
import { ItemColumnName, NavigationLayout } from '../../models';
|
|
7
|
+
import { NavigationList } from '../NavigationList/NavigationList';
|
|
8
8
|
import './MobileNavigation.css';
|
|
9
9
|
const b = block('mobile-navigation');
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
return (React.createElement("div", { ref: ref, className: b('dropdown') },
|
|
13
|
-
React.createElement(NavigationItem, { data: data, onClick: onToggle, isOpened: isOpened }),
|
|
14
|
-
isOpened && (React.createElement(Popup, { anchorRef: ref, open: isOpened, className: b('popup') }, data.items.map((item) => (React.createElement(NavigationItem, { key: item.text, data: item, className: b('dropdown-item'), onClick: onItemClick })))))));
|
|
15
|
-
};
|
|
16
|
-
const MobileNavigationItem = ({ item, index, isOpened, activeItemId, onActiveItemChange, column, onClose, }) => {
|
|
17
|
-
const id = `${column}-${index}`;
|
|
18
|
-
const isActive = id === activeItemId && isOpened;
|
|
19
|
-
const toggleActive = useCallback((e) => {
|
|
20
|
-
e.stopPropagation();
|
|
21
|
-
if (onActiveItemChange) {
|
|
22
|
-
onActiveItemChange(isActive ? undefined : `${column}-${index}`);
|
|
23
|
-
}
|
|
24
|
-
}, [onActiveItemChange, isActive, column, index]);
|
|
25
|
-
const onItemClick = useCallback((e) => {
|
|
26
|
-
toggleActive(e);
|
|
27
|
-
onClose();
|
|
28
|
-
}, [toggleActive, onClose]);
|
|
29
|
-
return (React.createElement("li", { key: index, className: b('rows-item') }, item.type === NavigationItemType.Dropdown ? (React.createElement(MobileNavigationDropdown, { data: item, onToggle: toggleActive, isOpened: isActive, onItemClick: onItemClick })) : (React.createElement(NavigationItem, { data: item, onClick: onItemClick }))));
|
|
30
|
-
};
|
|
31
|
-
const MobileNavigation = (props) => {
|
|
10
|
+
const MobileNavigation = (_a) => {
|
|
11
|
+
var { isOpened, topItems, bottomItems } = _a, props = __rest(_a, ["isOpened", "topItems", "bottomItems"]);
|
|
32
12
|
if (typeof window === 'undefined') {
|
|
33
13
|
return null;
|
|
34
14
|
}
|
|
35
|
-
const { isOpened, topItems, bottomItems, activeItemId, onActiveItemChange, onClose } = props;
|
|
36
15
|
return (React.createElement(Portal, null,
|
|
37
16
|
React.createElement(Foldable, { key: topItems === null || topItems === void 0 ? void 0 : topItems.length, className: b(), isOpened: Boolean(isOpened) },
|
|
38
17
|
React.createElement("div", { className: b('wrapper') },
|
|
39
|
-
React.createElement(
|
|
40
|
-
|
|
41
|
-
React.createElement("ul", { className: b('rows') }, bottomItems === null || bottomItems === void 0 ? void 0 : bottomItems.map((item, index) => (React.createElement(MobileNavigationItem, { key: index, item: item, column: ItemColumnName.Bottom, index: index, isOpened: isOpened, activeItemId: activeItemId, onClose: onClose, onActiveItemChange: onActiveItemChange }))))))));
|
|
18
|
+
topItems && (React.createElement(NavigationList, Object.assign({ className: b('rows'), items: topItems, column: ItemColumnName.Top, menuLayout: NavigationLayout.Mobile }, props))),
|
|
19
|
+
bottomItems && (React.createElement(NavigationList, Object.assign({ className: b('rows'), items: bottomItems, column: ItemColumnName.Bottom, menuLayout: NavigationLayout.Mobile }, props)))))));
|
|
42
20
|
};
|
|
43
21
|
export default MobileNavigation;
|