@gravity-ui/page-constructor 1.8.0-alfa.0 → 1.8.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.
Files changed (222) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +58 -36
  3. package/build/cjs/blocks/Banner/schema.d.ts +0 -12
  4. package/build/cjs/blocks/Banner/schema.js +0 -2
  5. package/build/cjs/blocks/CardLayout/schema.d.ts +0 -8
  6. package/build/cjs/blocks/CardLayout/schema.js +1 -2
  7. package/build/cjs/blocks/Companies/schema.d.ts +0 -2
  8. package/build/cjs/blocks/Companies/schema.js +0 -2
  9. package/build/cjs/blocks/ContentLayout/schema.d.ts +0 -6
  10. package/build/cjs/blocks/ExtendedFeatures/ExtendedFeatures.js +2 -2
  11. package/build/cjs/blocks/ExtendedFeatures/schema.d.ts +0 -7
  12. package/build/cjs/blocks/ExtendedFeatures/schema.js +1 -4
  13. package/build/cjs/blocks/Header/schema.d.ts +0 -16
  14. package/build/cjs/blocks/Header/schema.js +0 -5
  15. package/build/cjs/blocks/HeaderSlider/schema.d.ts +0 -11
  16. package/build/cjs/blocks/Icons/schema.d.ts +0 -6
  17. package/build/cjs/blocks/Icons/schema.js +0 -2
  18. package/build/cjs/blocks/Info/schema.d.ts +0 -10
  19. package/build/cjs/blocks/Info/schema.js +0 -2
  20. package/build/cjs/blocks/LinkTable/schema.d.ts +0 -2
  21. package/build/cjs/blocks/Media/schema.d.ts +0 -9
  22. package/build/cjs/blocks/Media/schema.js +1 -3
  23. package/build/cjs/blocks/Preview/schema.d.ts +0 -2
  24. package/build/cjs/blocks/Preview/schema.js +0 -4
  25. package/build/cjs/blocks/PromoFeaturesBlock/schema.d.ts +0 -7
  26. package/build/cjs/blocks/PromoFeaturesBlock/schema.js +1 -4
  27. package/build/cjs/blocks/Questions/schema.d.ts +0 -5
  28. package/build/cjs/blocks/Questions/schema.js +0 -2
  29. package/build/cjs/blocks/Security/schema.d.ts +0 -2
  30. package/build/cjs/blocks/Security/schema.js +0 -2
  31. package/build/cjs/blocks/Simple/schema.d.ts +0 -3
  32. package/build/cjs/blocks/Simple/schema.js +0 -1
  33. package/build/cjs/blocks/Slider/schema.d.ts +0 -7
  34. package/build/cjs/blocks/Slider/schema.js +0 -2
  35. package/build/cjs/blocks/Table/schema.d.ts +0 -4
  36. package/build/cjs/blocks/Table/schema.js +0 -3
  37. package/build/cjs/blocks/Tabs/schema.d.ts +0 -8
  38. package/build/cjs/blocks/Tabs/schema.js +0 -4
  39. package/build/cjs/components/Author/schema.d.ts +0 -3
  40. package/build/cjs/components/Image/schema.d.ts +0 -2
  41. package/build/cjs/components/Image/schema.js +0 -2
  42. package/build/cjs/components/OverflowScroller/OverflowScroller.css +2 -0
  43. package/build/cjs/components/RouterLink/RouterLink.d.ts +1 -0
  44. package/build/cjs/components/index.d.ts +2 -0
  45. package/build/cjs/components/index.js +40 -39
  46. package/build/cjs/components/navigation/components/Header/Header.css +85 -0
  47. package/build/cjs/components/navigation/components/Header/Header.d.ts +8 -0
  48. package/build/cjs/components/navigation/components/Header/Header.js +55 -0
  49. package/build/cjs/components/navigation/components/Logo/Logo.css +23 -0
  50. package/build/cjs/components/navigation/components/Logo/Logo.d.ts +7 -0
  51. package/build/cjs/components/navigation/components/Logo/Logo.js +17 -0
  52. package/build/cjs/components/navigation/components/MobileNavigation/MobileNavigation.css +64 -0
  53. package/build/cjs/components/navigation/components/MobileNavigation/MobileNavigation.d.ts +13 -0
  54. package/build/cjs/components/navigation/components/MobileNavigation/MobileNavigation.js +45 -0
  55. package/build/cjs/components/navigation/components/Navigation/Navigation.css +43 -0
  56. package/build/cjs/components/navigation/components/Navigation/Navigation.d.ts +18 -0
  57. package/build/cjs/components/navigation/components/Navigation/Navigation.js +69 -0
  58. package/build/cjs/components/navigation/components/NavigationItem/NavigationItem.css +40 -0
  59. package/build/cjs/components/navigation/components/NavigationItem/NavigationItem.d.ts +10 -0
  60. package/build/cjs/components/navigation/components/NavigationItem/NavigationItem.js +59 -0
  61. package/build/cjs/components/navigation/components/NavigationPopup/NavigationPopup.css +33 -0
  62. package/build/cjs/components/navigation/components/NavigationPopup/NavigationPopup.d.ts +10 -0
  63. package/build/cjs/components/navigation/components/NavigationPopup/NavigationPopup.js +45 -0
  64. package/build/cjs/components/navigation/components/SocialIcon/SocialIcon.css +20 -0
  65. package/build/cjs/components/navigation/components/SocialIcon/SocialIcon.d.ts +7 -0
  66. package/build/cjs/components/navigation/components/SocialIcon/SocialIcon.js +14 -0
  67. package/build/cjs/components/navigation/components/index.d.ts +7 -0
  68. package/build/cjs/components/navigation/components/index.js +20 -0
  69. package/build/cjs/components/navigation/containers/Layout/Layout.css +10 -0
  70. package/build/cjs/components/navigation/containers/Layout/Layout.d.ts +8 -0
  71. package/build/cjs/components/navigation/containers/Layout/Layout.js +11 -0
  72. package/build/cjs/containers/PageConstructor/PageConstructor.d.ts +3 -2
  73. package/build/cjs/containers/PageConstructor/PageConstructor.js +12 -10
  74. package/build/cjs/context/locationContext/locationContext.d.ts +1 -0
  75. package/build/cjs/icons/NavigationArrow.d.ts +2 -0
  76. package/build/cjs/icons/NavigationArrow.js +9 -0
  77. package/build/cjs/icons/NavigationClose.d.ts +2 -0
  78. package/build/cjs/icons/NavigationClose.js +9 -0
  79. package/build/cjs/icons/NavigationOpen.d.ts +2 -0
  80. package/build/cjs/icons/NavigationOpen.js +11 -0
  81. package/build/cjs/icons/index.d.ts +3 -0
  82. package/build/cjs/icons/index.js +3 -0
  83. package/build/cjs/models/constructor-items/blocks.d.ts +2 -4
  84. package/build/cjs/models/index.d.ts +1 -0
  85. package/build/cjs/models/index.js +1 -0
  86. package/build/cjs/models/navigation.d.ts +62 -0
  87. package/build/cjs/models/navigation.js +10 -0
  88. package/build/cjs/schema/index.d.ts +0 -2
  89. package/build/cjs/schema/validators/common.d.ts +0 -17
  90. package/build/cjs/schema/validators/common.js +0 -11
  91. package/build/cjs/sub-blocks/BackgroundCard/schema.d.ts +0 -5
  92. package/build/cjs/sub-blocks/BasicCard/schema.d.ts +0 -4
  93. package/build/cjs/sub-blocks/CardWithImage/schema.d.ts +0 -8
  94. package/build/cjs/sub-blocks/CardWithImage/schema.js +1 -4
  95. package/build/cjs/sub-blocks/Content/schema.d.ts +0 -8
  96. package/build/cjs/sub-blocks/Content/schema.js +1 -3
  97. package/build/cjs/sub-blocks/MediaCard/schema.d.ts +0 -1
  98. package/build/cjs/sub-blocks/NewsCard/schema.d.ts +0 -1
  99. package/build/cjs/sub-blocks/NewsCard/schema.js +0 -1
  100. package/build/cjs/sub-blocks/Partner/schema.d.ts +0 -1
  101. package/build/cjs/sub-blocks/Partner/schema.js +0 -1
  102. package/build/cjs/sub-blocks/PriceDetailed/schema.d.ts +0 -1
  103. package/build/cjs/sub-blocks/PriceDetailed/schema.js +0 -8
  104. package/build/cjs/sub-blocks/Quote/schema.d.ts +0 -4
  105. package/build/cjs/sub-blocks/Quote/schema.js +0 -1
  106. package/build/cjs/sub-blocks/TutorialCard/schema.d.ts +0 -2
  107. package/build/cjs/sub-blocks/TutorialCard/schema.js +0 -2
  108. package/build/cjs/text-transform/blocks.js +0 -1
  109. package/build/esm/blocks/Banner/schema.d.ts +0 -12
  110. package/build/esm/blocks/Banner/schema.js +0 -2
  111. package/build/esm/blocks/CardLayout/schema.d.ts +0 -8
  112. package/build/esm/blocks/CardLayout/schema.js +1 -2
  113. package/build/esm/blocks/Companies/schema.d.ts +0 -2
  114. package/build/esm/blocks/Companies/schema.js +0 -2
  115. package/build/esm/blocks/ContentLayout/schema.d.ts +0 -6
  116. package/build/esm/blocks/ExtendedFeatures/ExtendedFeatures.js +2 -2
  117. package/build/esm/blocks/ExtendedFeatures/schema.d.ts +0 -7
  118. package/build/esm/blocks/ExtendedFeatures/schema.js +1 -4
  119. package/build/esm/blocks/Header/schema.d.ts +0 -16
  120. package/build/esm/blocks/Header/schema.js +0 -5
  121. package/build/esm/blocks/HeaderSlider/schema.d.ts +0 -11
  122. package/build/esm/blocks/Icons/schema.d.ts +0 -6
  123. package/build/esm/blocks/Icons/schema.js +0 -2
  124. package/build/esm/blocks/Info/schema.d.ts +0 -10
  125. package/build/esm/blocks/Info/schema.js +0 -2
  126. package/build/esm/blocks/LinkTable/schema.d.ts +0 -2
  127. package/build/esm/blocks/Media/schema.d.ts +0 -9
  128. package/build/esm/blocks/Media/schema.js +1 -3
  129. package/build/esm/blocks/Preview/schema.d.ts +0 -2
  130. package/build/esm/blocks/Preview/schema.js +0 -4
  131. package/build/esm/blocks/PromoFeaturesBlock/schema.d.ts +0 -7
  132. package/build/esm/blocks/PromoFeaturesBlock/schema.js +1 -4
  133. package/build/esm/blocks/Questions/schema.d.ts +0 -5
  134. package/build/esm/blocks/Questions/schema.js +0 -2
  135. package/build/esm/blocks/Security/schema.d.ts +0 -2
  136. package/build/esm/blocks/Security/schema.js +0 -2
  137. package/build/esm/blocks/Simple/schema.d.ts +0 -3
  138. package/build/esm/blocks/Simple/schema.js +0 -1
  139. package/build/esm/blocks/Slider/schema.d.ts +0 -7
  140. package/build/esm/blocks/Slider/schema.js +0 -2
  141. package/build/esm/blocks/Table/schema.d.ts +0 -4
  142. package/build/esm/blocks/Table/schema.js +0 -3
  143. package/build/esm/blocks/Tabs/schema.d.ts +0 -8
  144. package/build/esm/blocks/Tabs/schema.js +0 -4
  145. package/build/esm/components/Author/schema.d.ts +0 -3
  146. package/build/esm/components/Image/schema.d.ts +0 -2
  147. package/build/esm/components/Image/schema.js +0 -2
  148. package/build/esm/components/OverflowScroller/OverflowScroller.css +2 -0
  149. package/build/esm/components/RouterLink/RouterLink.d.ts +1 -0
  150. package/build/esm/components/index.d.ts +2 -0
  151. package/build/esm/components/index.js +2 -0
  152. package/build/esm/components/navigation/components/Header/Header.css +85 -0
  153. package/build/esm/components/navigation/components/Header/Header.d.ts +9 -0
  154. package/build/esm/components/navigation/components/Header/Header.js +51 -0
  155. package/build/esm/components/navigation/components/Logo/Logo.css +23 -0
  156. package/build/esm/components/navigation/components/Logo/Logo.d.ts +8 -0
  157. package/build/esm/components/navigation/components/Logo/Logo.js +15 -0
  158. package/build/esm/components/navigation/components/MobileNavigation/MobileNavigation.css +64 -0
  159. package/build/esm/components/navigation/components/MobileNavigation/MobileNavigation.d.ts +14 -0
  160. package/build/esm/components/navigation/components/MobileNavigation/MobileNavigation.js +43 -0
  161. package/build/esm/components/navigation/components/Navigation/Navigation.css +43 -0
  162. package/build/esm/components/navigation/components/Navigation/Navigation.d.ts +19 -0
  163. package/build/esm/components/navigation/components/Navigation/Navigation.js +68 -0
  164. package/build/esm/components/navigation/components/NavigationItem/NavigationItem.css +40 -0
  165. package/build/esm/components/navigation/components/NavigationItem/NavigationItem.d.ts +11 -0
  166. package/build/esm/components/navigation/components/NavigationItem/NavigationItem.js +58 -0
  167. package/build/esm/components/navigation/components/NavigationPopup/NavigationPopup.css +33 -0
  168. package/build/esm/components/navigation/components/NavigationPopup/NavigationPopup.d.ts +11 -0
  169. package/build/esm/components/navigation/components/NavigationPopup/NavigationPopup.js +41 -0
  170. package/build/esm/components/navigation/components/SocialIcon/SocialIcon.css +20 -0
  171. package/build/esm/components/navigation/components/SocialIcon/SocialIcon.d.ts +8 -0
  172. package/build/esm/components/navigation/components/SocialIcon/SocialIcon.js +12 -0
  173. package/build/esm/components/navigation/components/index.d.ts +7 -0
  174. package/build/esm/components/navigation/components/index.js +7 -0
  175. package/build/esm/components/navigation/containers/Layout/Layout.css +10 -0
  176. package/build/esm/components/navigation/containers/Layout/Layout.d.ts +9 -0
  177. package/build/esm/components/navigation/containers/Layout/Layout.js +9 -0
  178. package/build/esm/containers/PageConstructor/PageConstructor.d.ts +3 -2
  179. package/build/esm/containers/PageConstructor/PageConstructor.js +12 -10
  180. package/build/esm/context/locationContext/locationContext.d.ts +1 -0
  181. package/build/esm/icons/NavigationArrow.d.ts +2 -0
  182. package/build/esm/icons/NavigationArrow.js +4 -0
  183. package/build/esm/icons/NavigationClose.d.ts +2 -0
  184. package/build/esm/icons/NavigationClose.js +4 -0
  185. package/build/esm/icons/NavigationOpen.d.ts +2 -0
  186. package/build/esm/icons/NavigationOpen.js +6 -0
  187. package/build/esm/icons/index.d.ts +3 -0
  188. package/build/esm/icons/index.js +3 -0
  189. package/build/esm/models/constructor-items/blocks.d.ts +2 -4
  190. package/build/esm/models/index.d.ts +1 -0
  191. package/build/esm/models/index.js +1 -0
  192. package/build/esm/models/navigation.d.ts +62 -0
  193. package/build/esm/models/navigation.js +7 -0
  194. package/build/esm/schema/index.d.ts +0 -2
  195. package/build/esm/schema/validators/common.d.ts +0 -17
  196. package/build/esm/schema/validators/common.js +0 -11
  197. package/build/esm/sub-blocks/BackgroundCard/schema.d.ts +0 -5
  198. package/build/esm/sub-blocks/BasicCard/schema.d.ts +0 -4
  199. package/build/esm/sub-blocks/CardWithImage/schema.d.ts +0 -8
  200. package/build/esm/sub-blocks/CardWithImage/schema.js +1 -4
  201. package/build/esm/sub-blocks/Content/schema.d.ts +0 -8
  202. package/build/esm/sub-blocks/Content/schema.js +1 -3
  203. package/build/esm/sub-blocks/MediaCard/schema.d.ts +0 -1
  204. package/build/esm/sub-blocks/NewsCard/schema.d.ts +0 -1
  205. package/build/esm/sub-blocks/NewsCard/schema.js +0 -1
  206. package/build/esm/sub-blocks/Partner/schema.d.ts +0 -1
  207. package/build/esm/sub-blocks/Partner/schema.js +0 -1
  208. package/build/esm/sub-blocks/PriceDetailed/schema.d.ts +0 -1
  209. package/build/esm/sub-blocks/PriceDetailed/schema.js +0 -8
  210. package/build/esm/sub-blocks/Quote/schema.d.ts +0 -4
  211. package/build/esm/sub-blocks/Quote/schema.js +0 -1
  212. package/build/esm/sub-blocks/TutorialCard/schema.d.ts +0 -2
  213. package/build/esm/sub-blocks/TutorialCard/schema.js +0 -2
  214. package/build/esm/text-transform/blocks.js +0 -1
  215. package/package.json +2 -5
  216. package/server/models/constructor-items/blocks.d.ts +2 -4
  217. package/server/models/index.d.ts +1 -0
  218. package/server/models/index.js +1 -0
  219. package/server/models/navigation.d.ts +62 -0
  220. package/server/models/navigation.js +10 -0
  221. package/server/text-transform/blocks.js +0 -1
  222. package/styles/mixins.scss +38 -0
@@ -0,0 +1,85 @@
1
+ /* use this for style redefinitions to awoid problems with
2
+ unpredictable css rules order in build */
3
+ .pc-header {
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
+ box-shadow: inset 0 -1px 0 var(--yc-color-line-generic);
13
+ }
14
+ .pc-header__wrapper {
15
+ display: flex;
16
+ justify-content: space-between;
17
+ align-items: center;
18
+ height: var(--header-height);
19
+ }
20
+ @media (min-width: 769px) {
21
+ .pc-header__mobile-menu-button {
22
+ display: none;
23
+ }
24
+ }
25
+ .pc-header__navigation, .pc-header__left, .pc-header__right {
26
+ display: flex;
27
+ align-items: center;
28
+ }
29
+ .pc-header__navigation {
30
+ position: relative;
31
+ margin-right: 20px;
32
+ flex: 1 0 0;
33
+ justify-content: flex-start;
34
+ }
35
+ @media (max-width: 768px) {
36
+ .pc-header__navigation {
37
+ display: none;
38
+ }
39
+ }
40
+ .pc-header__right {
41
+ flex: 0;
42
+ justify-content: flex-end;
43
+ }
44
+ .pc-header__navigation-container {
45
+ display: flex;
46
+ overflow-x: hidden;
47
+ flex: 1 0 0;
48
+ justify-content: space-between;
49
+ align-items: center;
50
+ margin-right: 20px;
51
+ }
52
+ .pc-header__buttons {
53
+ display: flex;
54
+ }
55
+ @media (max-width: 768px) {
56
+ .pc-header__buttons {
57
+ display: none;
58
+ }
59
+ }
60
+ .pc-header__buttons > *:not(:last-child) {
61
+ margin-right: 16px;
62
+ }
63
+ .pc-header__button {
64
+ margin-top: 0;
65
+ }
66
+ .pc-header__logo {
67
+ margin: 0 32px 0 0;
68
+ cursor: pointer;
69
+ }
70
+ @media (max-width: 768px) {
71
+ .pc-header__navigation-container {
72
+ justify-content: flex-end;
73
+ }
74
+ .pc-header__left {
75
+ flex: 1 0 0;
76
+ }
77
+ }
78
+ @media (max-width: 576px) {
79
+ .pc-header__navigation-container {
80
+ margin-right: 12px;
81
+ }
82
+ .pc-header__logo {
83
+ margin-right: 0;
84
+ }
85
+ }
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { HeaderData, NavigationLogo } from '../../../../models';
3
+ import './Header.css';
4
+ export interface HeaderProps {
5
+ logo: NavigationLogo;
6
+ data: HeaderData;
7
+ }
8
+ export declare const Header: React.FC<HeaderProps>;
9
+ export default Header;
@@ -0,0 +1,51 @@
1
+ import React, { useCallback, useState } from 'react';
2
+ import { block } from '../../../../utils';
3
+ import { Col, Grid, Row } from '../../../../grid';
4
+ import OutsideClick from '../../../OutsideClick/OutsideClick';
5
+ import Control from '../../../Control/Control';
6
+ import Navigation from '../Navigation/Navigation';
7
+ import MobileNavigation from '../MobileNavigation/MobileNavigation';
8
+ import NavigationItem from '../NavigationItem/NavigationItem';
9
+ import Logo from '../Logo/Logo';
10
+ import { NavigationClose, NavigationOpen } from '../../../../icons';
11
+ import './Header.css';
12
+ const b = block('header');
13
+ const ICON_SIZE = 36;
14
+ const MobileMenuButton = ({ isSidebarOpened, onSidebarOpenedChange, }) => {
15
+ const iconProps = {
16
+ icon: isSidebarOpened ? NavigationClose : NavigationOpen,
17
+ iconSize: ICON_SIZE,
18
+ };
19
+ return (React.createElement(Control, Object.assign({ className: b('mobile-menu-button'), onClick: (e) => {
20
+ e.stopPropagation();
21
+ onSidebarOpenedChange(!isSidebarOpened);
22
+ }, size: "l" }, iconProps)));
23
+ };
24
+ export const Header = ({ data, logo }) => {
25
+ const { leftItems, rightItems } = data;
26
+ const [isSidebarOpened, setIsSidebarOpened] = useState(false);
27
+ const [activeItemIndex, setActiveItemIndex] = useState(-1);
28
+ const onActiveItemChange = useCallback((index) => {
29
+ setActiveItemIndex(index);
30
+ }, []);
31
+ const onSidebarOpenedChange = useCallback((isOpen) => {
32
+ setIsSidebarOpened(isOpen);
33
+ }, []);
34
+ const hideSidebar = useCallback(() => {
35
+ setIsSidebarOpened(false);
36
+ }, []);
37
+ return (React.createElement(Grid, { className: b() },
38
+ React.createElement(Row, null,
39
+ React.createElement(Col, null,
40
+ React.createElement("header", { className: b('wrapper') },
41
+ logo && (React.createElement("div", { className: b('left') },
42
+ React.createElement(Logo, Object.assign({}, logo, { className: b('logo') })))),
43
+ React.createElement("div", { className: b('navigation-container') },
44
+ React.createElement(Navigation, { className: b('navigation'), links: leftItems, activeItemIndex: activeItemIndex, onActiveItemChange: onActiveItemChange })),
45
+ React.createElement("div", { className: b('right') },
46
+ React.createElement(MobileMenuButton, { isSidebarOpened: isSidebarOpened, onSidebarOpenedChange: onSidebarOpenedChange }),
47
+ rightItems && (React.createElement("div", { className: b('buttons') }, rightItems.map((button) => (React.createElement(NavigationItem, { key: button.text, data: button, className: b('button') })))))),
48
+ React.createElement(OutsideClick, { onOutsideClick: () => onSidebarOpenedChange(false) },
49
+ React.createElement(MobileNavigation, { topItems: leftItems, bottomItems: rightItems, isOpened: isSidebarOpened, activeItemIndex: activeItemIndex, onActiveItemChange: onActiveItemChange, onClose: hideSidebar })))))));
50
+ };
51
+ export default Header;
@@ -0,0 +1,23 @@
1
+ .pc-logo {
2
+ margin: 0;
3
+ }
4
+
5
+ /* use this for style redefinitions to awoid problems with
6
+ unpredictable css rules order in build */
7
+ .pc-logo {
8
+ display: flex;
9
+ align-items: center;
10
+ font-weight: var(--yc-text-accent-font-weight);
11
+ font-size: var(--yc-text-header-1-font-size);
12
+ line-height: var(--yc-text-header-1-line-height);
13
+ color: var(--pc-text-header-color);
14
+ font-weight: var(--yc-text-accent-font-weight);
15
+ }
16
+ .pc-logo__icon {
17
+ display: flex;
18
+ margin-right: 8px;
19
+ object-fit: contain;
20
+ }
21
+ .pc-logo__text {
22
+ white-space: nowrap;
23
+ }
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { NavigationLogo } from '../../../../models';
3
+ import './Logo.css';
4
+ export interface LogoProps extends NavigationLogo {
5
+ className?: string;
6
+ }
7
+ declare const Logo: React.FC<LogoProps>;
8
+ export default Logo;
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import { block } from '../../../../utils';
3
+ import RouterLink from '../../../RouterLink/RouterLink';
4
+ import { getMediaImage } from '../../../Media/Image/utils';
5
+ import { Image } from '../../../index';
6
+ import './Logo.css';
7
+ const b = block('logo');
8
+ const Logo = ({ icon, text, className }) => {
9
+ const imageData = getMediaImage(icon);
10
+ return (React.createElement(RouterLink, { href: "/", passHref: true },
11
+ React.createElement("div", { className: b(null, className) },
12
+ imageData && React.createElement(Image, Object.assign({ className: b('icon') }, imageData)),
13
+ React.createElement("span", { className: b('text') }, text))));
14
+ };
15
+ export default Logo;
@@ -0,0 +1,64 @@
1
+ /* use this for style redefinitions to awoid problems with
2
+ unpredictable css rules order in build */
3
+ .pc-mobile-navigation {
4
+ position: fixed;
5
+ z-index: 100;
6
+ top: var(--header-height);
7
+ left: 0;
8
+ width: 100%;
9
+ border-bottom-right-radius: var(--pc-border-radius);
10
+ border-bottom-left-radius: var(--pc-border-radius);
11
+ background-color: var(--yc-color-base-background);
12
+ box-shadow: 0 3px 10px var(--yc-color-sfx-shadow);
13
+ font-size: var(--yc-text-body-2-font-size);
14
+ line-height: var(--yc-text-body-2-line-height);
15
+ }
16
+ @media (min-width: 769px) {
17
+ .pc-mobile-navigation {
18
+ display: none;
19
+ }
20
+ }
21
+ .pc-mobile-navigation__wrapper {
22
+ padding: 32px 48px;
23
+ }
24
+ .pc-mobile-navigation__button {
25
+ margin-top: 24px;
26
+ }
27
+ .pc-mobile-navigation__links {
28
+ position: relative;
29
+ display: flex;
30
+ flex-direction: column;
31
+ padding-bottom: 24px;
32
+ margin: 0;
33
+ padding: 0;
34
+ list-style: none;
35
+ }
36
+ .pc-mobile-navigation__links-item:not(:last-child) {
37
+ margin-bottom: 24px;
38
+ }
39
+ .pc-mobile-navigation__dropdown-item:not(:last-child) {
40
+ margin-bottom: 16px;
41
+ }
42
+ .pc-mobile-navigation__popup {
43
+ z-index: 101;
44
+ display: flex;
45
+ flex-direction: column;
46
+ min-width: 220px;
47
+ padding: 16px;
48
+ border: 1px solid var(--yc-color-line-generic);
49
+ border-top-width: 0;
50
+ border-radius: calc(var(--pc-border-radius) / 2);
51
+ background: var(--yc-color-base-float);
52
+ box-shadow: 0 3px 10px var(--yc-color-sfx-shadow);
53
+ }
54
+ @media (min-width: 769px) {
55
+ .pc-mobile-navigation__popup {
56
+ display: none;
57
+ }
58
+ }
59
+ @media (max-width: 576px) {
60
+ .pc-mobile-navigation__wrapper {
61
+ padding-left: 24px;
62
+ padding-right: 24px;
63
+ }
64
+ }
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import { NavigationItem as NavigationItemModel } from '../../../../models/navigation';
3
+ import './MobileNavigation.css';
4
+ export interface MobileNavigationProps {
5
+ className?: string;
6
+ isOpened?: boolean;
7
+ topItems?: NavigationItemModel[];
8
+ bottomItems?: NavigationItemModel[];
9
+ activeItemIndex: number;
10
+ onClose: () => void;
11
+ onActiveItemChange: (index: number) => void;
12
+ }
13
+ declare const MobileNavigation: React.FC<MobileNavigationProps>;
14
+ export default MobileNavigation;
@@ -0,0 +1,43 @@
1
+ import React, { useRef, useCallback } from 'react';
2
+ import { Popup, Portal } from '@gravity-ui/uikit';
3
+ import { block } from '../../../../utils';
4
+ import Foldable from '../../../Foldable/Foldable';
5
+ import { NavigationItemType, } from '../../../../models/navigation';
6
+ import NavigationItem from '../NavigationItem/NavigationItem';
7
+ import './MobileNavigation.css';
8
+ const b = block('mobile-navigation');
9
+ const MobileNavigationDropdown = ({ data, onItemClick, onToggle, isOpened = false, }) => {
10
+ const ref = useRef(null);
11
+ return (React.createElement("div", { ref: ref, className: b('dropdown') },
12
+ React.createElement(NavigationItem, { data: data, onClick: onToggle, isOpened: isOpened }),
13
+ 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 })))))));
14
+ };
15
+ const MobileNavigationItem = ({ link, index, isActive, onActiveItemChange, onClose, }) => {
16
+ const toggleActive = useCallback((e) => {
17
+ e.stopPropagation();
18
+ if (onActiveItemChange) {
19
+ onActiveItemChange(isActive ? -1 : index);
20
+ }
21
+ }, [isActive, index, onActiveItemChange]);
22
+ const onItemClick = useCallback((e) => {
23
+ toggleActive(e);
24
+ onClose();
25
+ }, [toggleActive, onClose]);
26
+ return (React.createElement("li", { key: index, className: b('links-item') }, link.type === NavigationItemType.Dropdown ? (React.createElement(MobileNavigationDropdown, { data: link, onToggle: toggleActive, isOpened: isActive, onItemClick: onItemClick })) : (React.createElement(NavigationItem, { data: link, onClick: onItemClick }))));
27
+ };
28
+ const MobileNavigation = (props) => {
29
+ if (typeof window === 'undefined') {
30
+ return null;
31
+ }
32
+ const { isOpened, topItems, bottomItems, activeItemIndex, onActiveItemChange, onClose } = props;
33
+ return (React.createElement(Portal, null,
34
+ React.createElement(Foldable, { key: topItems === null || topItems === void 0 ? void 0 : topItems.length, className: b(), isOpened: Boolean(isOpened) },
35
+ React.createElement("div", { className: b('wrapper') },
36
+ React.createElement("nav", null,
37
+ React.createElement("ul", { className: b('links') }, topItems === null || topItems === void 0 ? void 0 : topItems.map((link, index) => {
38
+ const isActive = index === activeItemIndex;
39
+ return (React.createElement(MobileNavigationItem, { key: index, link: link, index: index, isActive: isOpened && isActive, onClose: onClose, onActiveItemChange: onActiveItemChange }));
40
+ }))), bottomItems === null || bottomItems === void 0 ? void 0 :
41
+ bottomItems.map((item) => (React.createElement(NavigationItem, { key: item.text, data: item, className: b('button') })))))));
42
+ };
43
+ export default MobileNavigation;
@@ -0,0 +1,43 @@
1
+ /* use this for style redefinitions to awoid problems with
2
+ unpredictable css rules order in build */
3
+ .pc-navigation {
4
+ font-size: var(--yc-text-body-2-font-size);
5
+ line-height: var(--yc-text-body-2-line-height);
6
+ }
7
+ .pc-navigation__links {
8
+ position: relative;
9
+ display: flex;
10
+ align-items: center;
11
+ margin: 0;
12
+ padding: 0;
13
+ list-style: none;
14
+ }
15
+ .pc-navigation__links-item {
16
+ position: relative;
17
+ height: var(--header-height);
18
+ line-height: var(--header-height);
19
+ cursor: pointer;
20
+ outline: none;
21
+ color: inherit;
22
+ text-decoration: none;
23
+ }
24
+ .utilityfocus .pc-navigation__links-item:focus {
25
+ outline: 2px solid #ffdb4d;
26
+ }
27
+ .pc-navigation__links-item:hover, .pc-navigation__links-item:active {
28
+ color: var(--yc-color-text-link);
29
+ }
30
+ .pc-navigation__links-item:not(:last-child) {
31
+ margin-right: 20px;
32
+ }
33
+ .pc-navigation__slider-container {
34
+ position: absolute;
35
+ right: 0;
36
+ bottom: 0;
37
+ left: 0;
38
+ }
39
+ .pc-navigation__slider {
40
+ width: 100%;
41
+ height: 2px;
42
+ background-color: var(--yc-color-text-link);
43
+ }
@@ -0,0 +1,19 @@
1
+ import React, { MouseEventHandler } from 'react';
2
+ import { NavigationDropdownItem, NavigationItem as NavigationItemModel } from '../../../../models/navigation';
3
+ import './Navigation.css';
4
+ export interface NavigationProps {
5
+ links: NavigationItemModel[];
6
+ activeItemIndex: number;
7
+ onActiveItemChange: (index: number) => void;
8
+ className?: string;
9
+ highlightActiveItem?: boolean;
10
+ }
11
+ export interface NavigationDropdownProps {
12
+ data: NavigationDropdownItem;
13
+ onClick: MouseEventHandler;
14
+ isActive: boolean;
15
+ position: number;
16
+ hidePopup: () => void;
17
+ }
18
+ declare const Navigation: React.FC<NavigationProps>;
19
+ export default Navigation;
@@ -0,0 +1,68 @@
1
+ import { __rest } from "tslib";
2
+ import _ from 'lodash';
3
+ import React, { Fragment, useState, useEffect, useCallback, useContext, useRef, } from 'react';
4
+ import { block } from '../../../../utils';
5
+ import OverflowScroller from '../../../OverflowScroller/OverflowScroller';
6
+ import { NavigationItemType, } from '../../../../models/navigation';
7
+ import NavigationPopup from '../NavigationPopup/NavigationPopup';
8
+ import NavigationItem from '../NavigationItem/NavigationItem';
9
+ import { LocationContext } from '../../../../context/locationContext';
10
+ import './Navigation.css';
11
+ const b = block('navigation');
12
+ const NavigationDropdown = ({ data, isActive, position, hidePopup, onClick, }) => {
13
+ const { text, items } = data, popupProps = __rest(data, ["text", "items"]);
14
+ return (React.createElement(Fragment, null,
15
+ React.createElement(NavigationItem, { className: b('link'), onClick: onClick, isOpened: isActive, data: { text, type: NavigationItemType.Dropdown } }),
16
+ isActive && (React.createElement(NavigationPopup, Object.assign({ left: position, onClose: hidePopup, items: items }, popupProps)))));
17
+ };
18
+ const Navigation = ({ className, onActiveItemChange, links, activeItemIndex, highlightActiveItem, }) => {
19
+ const { asPath, pathname } = useContext(LocationContext);
20
+ const itemRefs = useRef([]);
21
+ const [itemPositions, setItemPosition] = useState([]);
22
+ const [lastLeftScroll, setLastLeftScroll] = useState(0);
23
+ const hidePopup = useCallback(() => {
24
+ onActiveItemChange(-1);
25
+ }, [onActiveItemChange]);
26
+ const getItemClickHandler = useCallback((index) => (e) => {
27
+ e.stopPropagation();
28
+ onActiveItemChange(index === activeItemIndex ? -1 : index);
29
+ }, [activeItemIndex, onActiveItemChange]);
30
+ const calculateItemPositions = useCallback(() => {
31
+ if (itemRefs.current.length) {
32
+ const currentItemPositions = itemRefs.current.map((itemRef) => (itemRef && itemRef.getBoundingClientRect().left) || 0);
33
+ setItemPosition(currentItemPositions);
34
+ }
35
+ }, []);
36
+ useEffect(() => {
37
+ const debouncedCalculateItemPositions = _.debounce(calculateItemPositions, 100);
38
+ const calculateOnScroll = _.debounce(() => {
39
+ const curLeftScroll = window.pageXOffset;
40
+ if (curLeftScroll !== lastLeftScroll) {
41
+ setLastLeftScroll(window.pageXOffset);
42
+ calculateItemPositions();
43
+ }
44
+ }, 100);
45
+ calculateItemPositions();
46
+ setLastLeftScroll(window.pageXOffset);
47
+ window.addEventListener('resize', debouncedCalculateItemPositions);
48
+ window.addEventListener('scroll', calculateOnScroll);
49
+ return () => {
50
+ window.removeEventListener(`resize`, calculateItemPositions);
51
+ window.removeEventListener('scroll', calculateOnScroll);
52
+ };
53
+ }, [calculateItemPositions, itemRefs, lastLeftScroll]);
54
+ useEffect(() => {
55
+ hidePopup();
56
+ }, [hidePopup, asPath, pathname]);
57
+ return (React.createElement(OverflowScroller, { className: b(null, className), onScrollStart: hidePopup, onScrollEnd: calculateItemPositions },
58
+ React.createElement("nav", null,
59
+ React.createElement("ul", { className: b('links') }, links.map((link, index) => {
60
+ const isActive = index === activeItemIndex;
61
+ const onClick = getItemClickHandler(index);
62
+ return (React.createElement("li", { ref: (el) => itemRefs.current.push(el), key: index, className: b('links-item') },
63
+ link.type === NavigationItemType.Dropdown ? (React.createElement(NavigationDropdown, { data: link, onClick: onClick, isActive: isActive, position: itemPositions[index], hidePopup: hidePopup })) : (React.createElement(NavigationItem, { data: link, onClick: onClick })),
64
+ highlightActiveItem && isActive && (React.createElement("div", { className: b('slider-container') },
65
+ React.createElement("div", { className: b('slider') })))));
66
+ })))));
67
+ };
68
+ export default Navigation;
@@ -0,0 +1,40 @@
1
+ /* use this for style redefinitions to awoid problems with
2
+ unpredictable css rules order in build */
3
+ .pc-navigation-item {
4
+ position: relative;
5
+ display: flex;
6
+ align-items: center;
7
+ }
8
+ .pc-navigation-item_type_link {
9
+ color: var(--yc-color-text-primary);
10
+ color: inherit;
11
+ text-decoration: none;
12
+ outline: none;
13
+ }
14
+ .utilityfocus .pc-navigation-item_type_link:focus {
15
+ outline: 2px solid #ffdb4d;
16
+ }
17
+ .pc-navigation-item_type_link:hover, .pc-navigation-item_type_link_active {
18
+ color: var(--yc-color-text-link);
19
+ }
20
+ .pc-navigation-item_type_button {
21
+ display: inline-block;
22
+ }
23
+ .pc-navigation-item__arrow {
24
+ position: relative;
25
+ top: -2px;
26
+ width: 9px;
27
+ height: 9px;
28
+ margin-left: 5px;
29
+ }
30
+ .pc-navigation-item__icon {
31
+ display: flex;
32
+ width: 20px;
33
+ height: 20px;
34
+ margin-right: 8px;
35
+ object-fit: cover;
36
+ }
37
+ .pc-navigation-item__dropdown {
38
+ margin-left: 7px;
39
+ color: var(--yc-color-text-secondary);
40
+ }
@@ -0,0 +1,11 @@
1
+ import React, { MouseEventHandler } from 'react';
2
+ import { NavigationItemData } from '../../../../models';
3
+ import './NavigationItem.css';
4
+ export interface NavigationItemProps {
5
+ data: NavigationItemData;
6
+ className?: string;
7
+ onClick?: MouseEventHandler;
8
+ isOpened?: boolean;
9
+ }
10
+ declare const NavigationItem: React.FC<NavigationItemProps>;
11
+ export default NavigationItem;
@@ -0,0 +1,58 @@
1
+ import { __rest } from "tslib";
2
+ import React, { Fragment, useContext, useMemo } from 'react';
3
+ import { block, getLinkProps } from '../../../../utils';
4
+ import { RouterLink, ToggleArrow, Button, Image } from '../../../index';
5
+ import { LocationContext } from '../../../../context/locationContext';
6
+ import { NavigationItemType, } from '../../../../models';
7
+ import { NavigationArrow } from '../../../../icons';
8
+ import SocialIcon from '../SocialIcon/SocialIcon';
9
+ import { getMediaImage } from '../../../Media/Image/utils';
10
+ import './NavigationItem.css';
11
+ const b = block('navigation-item');
12
+ const Content = ({ text, icon }) => (React.createElement(Fragment, null,
13
+ icon && React.createElement(Image, Object.assign({ className: b('icon') }, icon)),
14
+ React.createElement("span", { className: b('text') }, text)));
15
+ const NavigationDropdown = (_a) => {
16
+ var { text, icon, isOpened } = _a, props = __rest(_a, ["text", "icon", "isOpened"]);
17
+ const iconData = icon && getMediaImage(icon);
18
+ return (React.createElement("span", Object.assign({}, props),
19
+ React.createElement(Content, { text: text, icon: iconData }),
20
+ React.createElement(ToggleArrow, { className: b('dropdown'), size: 12, type: 'vertical', iconType: "navigation", open: isOpened })));
21
+ };
22
+ const NavigationLink = (props) => {
23
+ const { hostname, Link } = useContext(LocationContext);
24
+ const { url, text, icon, arrow, target } = props, rest = __rest(props, ["url", "text", "icon", "arrow", "target"]);
25
+ const linkExtraProps = getLinkProps(url, hostname, target);
26
+ const iconData = icon && getMediaImage(icon);
27
+ const content = (React.createElement(Fragment, null,
28
+ React.createElement(Content, { text: text, icon: iconData }),
29
+ arrow && React.createElement(NavigationArrow, { className: b('arrow') })));
30
+ if ((linkExtraProps === null || linkExtraProps === void 0 ? void 0 : linkExtraProps.target) || !Link) {
31
+ return (React.createElement("a", Object.assign({ href: url, title: text }, rest, linkExtraProps), content));
32
+ }
33
+ else {
34
+ return (React.createElement(RouterLink, { href: url, passHref: true },
35
+ React.createElement("a", Object.assign({}, rest), content)));
36
+ }
37
+ };
38
+ const NavigationButton = (props) => {
39
+ const { url, target } = props;
40
+ return target ? (React.createElement(Button, Object.assign({}, props, { url: url }))) : (React.createElement(RouterLink, { href: url },
41
+ React.createElement(Button, Object.assign({}, props, { url: url }))));
42
+ };
43
+ //todo: add types support form component in map
44
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
45
+ const NavigationItemsMap = {
46
+ [NavigationItemType.Button]: NavigationButton,
47
+ [NavigationItemType.Social]: SocialIcon,
48
+ [NavigationItemType.Dropdown]: NavigationDropdown,
49
+ [NavigationItemType.Link]: NavigationLink,
50
+ };
51
+ const NavigationItem = (_a) => {
52
+ var { data, className } = _a, props = __rest(_a, ["data", "className"]);
53
+ const { type = NavigationItemType.Link } = data;
54
+ const Component = NavigationItemsMap[type];
55
+ const componentProps = useMemo(() => (Object.assign(Object.assign({ className: b({ type }, className) }, data), props)), [className, data, props, type]);
56
+ return React.createElement(Component, Object.assign({}, componentProps));
57
+ };
58
+ export default NavigationItem;
@@ -0,0 +1,33 @@
1
+ /* use this for style redefinitions to awoid problems with
2
+ unpredictable css rules order in build */
3
+ .pc-navigation-popup {
4
+ position: fixed;
5
+ top: calc(var(--header-height) - 16px);
6
+ padding-right: 4px;
7
+ padding-left: 4px;
8
+ transform: translateX(calc(calc(8px * 2) * -1));
9
+ z-index: 101;
10
+ display: flex;
11
+ flex-direction: column;
12
+ min-width: 220px;
13
+ padding: 16px;
14
+ border: 1px solid var(--yc-color-line-generic);
15
+ border-top-width: 0;
16
+ border-radius: calc(var(--pc-border-radius) / 2);
17
+ background: var(--yc-color-base-float);
18
+ box-shadow: 0 3px 10px var(--yc-color-sfx-shadow);
19
+ }
20
+ @media (max-width: 768px) {
21
+ .pc-navigation-popup {
22
+ display: none;
23
+ }
24
+ }
25
+ .pc-navigation-popup__link {
26
+ height: 36px;
27
+ padding: 8px 12px;
28
+ border-radius: 8px;
29
+ }
30
+ .pc-navigation-popup__link:hover {
31
+ color: var(--yc-color-text-primary);
32
+ background-color: var(--yc-color-base-simple-hover);
33
+ }
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { NavigationLinkItem } from '../../../../models';
3
+ import './NavigationPopup.css';
4
+ export interface NavigationPopupProps {
5
+ items: NavigationLinkItem[];
6
+ onClose: () => void;
7
+ left?: number;
8
+ className?: string;
9
+ }
10
+ export declare const NavigationPopup: React.FC<NavigationPopupProps>;
11
+ export default NavigationPopup;
@@ -0,0 +1,41 @@
1
+ import _ from 'lodash';
2
+ import React, { useRef, useState, useEffect, useCallback } from 'react';
3
+ import { Portal } from '@gravity-ui/uikit';
4
+ import { block } from '../../../../utils';
5
+ import { OutsideClick } from '../../../index';
6
+ import NavigationItem from '../NavigationItem/NavigationItem';
7
+ import './NavigationPopup.css';
8
+ const b = block('navigation-popup');
9
+ export const NavigationPopup = ({ items, left, onClose }) => {
10
+ const [calculatedLeft, setCalculatedLeft] = useState(left);
11
+ const popupRef = useRef(null);
12
+ const calculateLeft = useCallback(() => {
13
+ if (popupRef && popupRef.current && left) {
14
+ const right = left + popupRef.current.offsetWidth;
15
+ const docWidth = document.body.clientWidth;
16
+ const currentLeft = right > docWidth ? left - (right - docWidth) : left;
17
+ setCalculatedLeft(currentLeft);
18
+ }
19
+ else {
20
+ setCalculatedLeft(left);
21
+ }
22
+ }, [left]);
23
+ useEffect(() => {
24
+ const debounceCalculateLeft = _.debounce(calculateLeft, 100);
25
+ calculateLeft();
26
+ window.addEventListener('resize', debounceCalculateLeft);
27
+ return () => {
28
+ window.removeEventListener('resize', debounceCalculateLeft);
29
+ };
30
+ }, [calculateLeft]);
31
+ useEffect(() => {
32
+ calculateLeft();
33
+ }, [calculateLeft, left]);
34
+ if (!document || !document.body) {
35
+ return null;
36
+ }
37
+ return (React.createElement(Portal, null,
38
+ React.createElement("div", { ref: popupRef, className: b(), style: { left: calculatedLeft } },
39
+ React.createElement(OutsideClick, { onOutsideClick: onClose }, items.map((item) => (React.createElement(NavigationItem, { key: item.text, className: b('link'), data: item })))))));
40
+ };
41
+ export default NavigationPopup;