@gravity-ui/page-constructor 2.22.1 → 2.23.0-alpha.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/CHANGELOG.md CHANGED
@@ -1,12 +1,5 @@
1
1
  # Changelog
2
2
 
3
- ## [2.22.1](https://github.com/gravity-ui/page-constructor/compare/v2.22.0...v2.22.1) (2023-06-01)
4
-
5
-
6
- ### Bug Fixes
7
-
8
- * filter block nesting ([#364](https://github.com/gravity-ui/page-constructor/issues/364)) ([5b62522](https://github.com/gravity-ui/page-constructor/commit/5b62522e5e34eeacbb2fb9ec6de957bba69cd758))
9
-
10
3
  ## [2.22.0](https://github.com/gravity-ui/page-constructor/compare/v2.21.0...v2.22.0) (2023-05-31)
11
4
 
12
5
 
@@ -6,7 +6,6 @@
6
6
  unpredictable css rules order in build */
7
7
  .pc-header-block {
8
8
  position: relative;
9
- margin: 16px 0;
10
9
  }
11
10
  .pc-header-block_full-width {
12
11
  --pc-border-radius: 0;
@@ -30,16 +29,16 @@ unpredictable css rules order in build */
30
29
  margin: 16px 0;
31
30
  }
32
31
  .pc-header-block__content_vertical-offset_s {
33
- padding: 48px 0;
32
+ padding: 64px 0;
34
33
  }
35
34
  .pc-header-block__content_vertical-offset_m {
36
- padding: calc(96px - 16px) 0;
35
+ padding: 96px 0;
37
36
  }
38
37
  .pc-header-block__content_vertical-offset_l {
39
- padding: calc(128px - 16px) 0;
38
+ padding: 128px 0;
40
39
  }
41
40
  .pc-header-block__content_vertical-offset_xl {
42
- padding: calc(160px - 16px) 0;
41
+ padding: 160px 0;
43
42
  }
44
43
  .pc-header-block__content_offset_large {
45
44
  padding: calc(128px - 16px) 0 16px;
@@ -95,10 +94,10 @@ unpredictable css rules order in build */
95
94
  .pc-header-block__media {
96
95
  position: absolute;
97
96
  display: none;
98
- top: 0;
97
+ top: 16px;
99
98
  right: 0;
100
99
  width: 50%;
101
- height: 100%;
100
+ height: calc(100% - 2 * 16px);
102
101
  overflow: hidden;
103
102
  object-fit: cover;
104
103
  border-radius: var(--pc-border-radius);
@@ -63,6 +63,7 @@ export interface HeaderData {
63
63
  leftItems: NavigationItemModel[];
64
64
  rightItems?: NavigationItemModel[];
65
65
  iconSize?: number;
66
+ withBorder?: boolean;
66
67
  }
67
68
  export interface FooterColumn {
68
69
  title: string;
@@ -9,6 +9,8 @@ unpredictable css rules order in build */
9
9
  align-items: center;
10
10
  height: var(--header-height);
11
11
  background-color: var(--yc-color-base-background);
12
+ }
13
+ .pc-header_with-border {
12
14
  box-shadow: inset 0 -1px 0 var(--yc-color-line-generic);
13
15
  }
14
16
  .pc-header__wrapper {
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Header = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const react_1 = tslib_1.__importStar(require("react"));
6
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
6
7
  const Control_1 = tslib_1.__importDefault(require("../../../components/Control/Control"));
7
8
  const OutsideClick_1 = tslib_1.__importDefault(require("../../../components/OutsideClick/OutsideClick"));
8
9
  const grid_1 = require("../../../grid");
@@ -27,9 +28,10 @@ const MobileMenuButton = ({ isSidebarOpened, onSidebarOpenedChange, }) => {
27
28
  };
28
29
  const iconSizeKey = 'iconSize';
29
30
  const Header = ({ data, logo }) => {
30
- const { leftItems, rightItems, iconSize = 20 } = data;
31
+ const { leftItems, rightItems, iconSize = 20, withBorder = false } = data;
31
32
  const [isSidebarOpened, setIsSidebarOpened] = (0, react_1.useState)(false);
32
33
  const [activeItemId, setactiveItemId] = (0, react_1.useState)(undefined);
34
+ const [withHeaderBorder, setWithHeaderBorder] = (0, react_1.useState)(withBorder);
33
35
  const getNavigationItemWithIconSize = (0, react_1.useCallback)((item) => {
34
36
  if (!(iconSizeKey in item)) {
35
37
  return Object.assign(Object.assign({}, item), { iconSize });
@@ -50,7 +52,19 @@ const Header = ({ data, logo }) => {
50
52
  const hideSidebar = (0, react_1.useCallback)(() => {
51
53
  setIsSidebarOpened(false);
52
54
  }, []);
53
- return (react_1.default.createElement(grid_1.Grid, { className: b() },
55
+ (0, react_1.useEffect)(() => {
56
+ const handleScroll = () => {
57
+ if (window.scrollY > 0 && !withBorder) {
58
+ setWithHeaderBorder(true);
59
+ }
60
+ else if (window.scrollY === 0 && !withBorder) {
61
+ setWithHeaderBorder(false);
62
+ }
63
+ };
64
+ window.addEventListener('scroll', lodash_1.default.debounce(handleScroll, 5), { passive: true });
65
+ return () => window.removeEventListener('scroll', lodash_1.default.debounce(handleScroll, 5));
66
+ });
67
+ return (react_1.default.createElement(grid_1.Grid, { className: b({ 'with-border': withHeaderBorder }) },
54
68
  react_1.default.createElement(grid_1.Row, null,
55
69
  react_1.default.createElement(grid_1.Col, null,
56
70
  react_1.default.createElement("header", { className: b('wrapper') },
@@ -6,7 +6,6 @@
6
6
  unpredictable css rules order in build */
7
7
  .pc-header-block {
8
8
  position: relative;
9
- margin: 16px 0;
10
9
  }
11
10
  .pc-header-block_full-width {
12
11
  --pc-border-radius: 0;
@@ -30,16 +29,16 @@ unpredictable css rules order in build */
30
29
  margin: 16px 0;
31
30
  }
32
31
  .pc-header-block__content_vertical-offset_s {
33
- padding: 48px 0;
32
+ padding: 64px 0;
34
33
  }
35
34
  .pc-header-block__content_vertical-offset_m {
36
- padding: calc(96px - 16px) 0;
35
+ padding: 96px 0;
37
36
  }
38
37
  .pc-header-block__content_vertical-offset_l {
39
- padding: calc(128px - 16px) 0;
38
+ padding: 128px 0;
40
39
  }
41
40
  .pc-header-block__content_vertical-offset_xl {
42
- padding: calc(160px - 16px) 0;
41
+ padding: 160px 0;
43
42
  }
44
43
  .pc-header-block__content_offset_large {
45
44
  padding: calc(128px - 16px) 0 16px;
@@ -95,10 +94,10 @@ unpredictable css rules order in build */
95
94
  .pc-header-block__media {
96
95
  position: absolute;
97
96
  display: none;
98
- top: 0;
97
+ top: 16px;
99
98
  right: 0;
100
99
  width: 50%;
101
- height: 100%;
100
+ height: calc(100% - 2 * 16px);
102
101
  overflow: hidden;
103
102
  object-fit: cover;
104
103
  border-radius: var(--pc-border-radius);
@@ -63,6 +63,7 @@ export interface HeaderData {
63
63
  leftItems: NavigationItemModel[];
64
64
  rightItems?: NavigationItemModel[];
65
65
  iconSize?: number;
66
+ withBorder?: boolean;
66
67
  }
67
68
  export interface FooterColumn {
68
69
  title: string;
@@ -9,6 +9,8 @@ unpredictable css rules order in build */
9
9
  align-items: center;
10
10
  height: var(--header-height);
11
11
  background-color: var(--yc-color-base-background);
12
+ }
13
+ .pc-header_with-border {
12
14
  box-shadow: inset 0 -1px 0 var(--yc-color-line-generic);
13
15
  }
14
16
  .pc-header__wrapper {
@@ -1,4 +1,5 @@
1
- import React, { useCallback, useMemo, useState } from 'react';
1
+ import React, { useCallback, useEffect, useMemo, useState } from 'react';
2
+ import _ from 'lodash';
2
3
  import Control from '../../../components/Control/Control';
3
4
  import OutsideClick from '../../../components/OutsideClick/OutsideClick';
4
5
  import { Col, Grid, Row } from '../../../grid';
@@ -24,9 +25,10 @@ const MobileMenuButton = ({ isSidebarOpened, onSidebarOpenedChange, }) => {
24
25
  };
25
26
  const iconSizeKey = 'iconSize';
26
27
  export const Header = ({ data, logo }) => {
27
- const { leftItems, rightItems, iconSize = 20 } = data;
28
+ const { leftItems, rightItems, iconSize = 20, withBorder = false } = data;
28
29
  const [isSidebarOpened, setIsSidebarOpened] = useState(false);
29
30
  const [activeItemId, setactiveItemId] = useState(undefined);
31
+ const [withHeaderBorder, setWithHeaderBorder] = useState(withBorder);
30
32
  const getNavigationItemWithIconSize = useCallback((item) => {
31
33
  if (!(iconSizeKey in item)) {
32
34
  return Object.assign(Object.assign({}, item), { iconSize });
@@ -47,7 +49,19 @@ export const Header = ({ data, logo }) => {
47
49
  const hideSidebar = useCallback(() => {
48
50
  setIsSidebarOpened(false);
49
51
  }, []);
50
- return (React.createElement(Grid, { className: b() },
52
+ useEffect(() => {
53
+ const handleScroll = () => {
54
+ if (window.scrollY > 0 && !withBorder) {
55
+ setWithHeaderBorder(true);
56
+ }
57
+ else if (window.scrollY === 0 && !withBorder) {
58
+ setWithHeaderBorder(false);
59
+ }
60
+ };
61
+ window.addEventListener('scroll', _.debounce(handleScroll, 5), { passive: true });
62
+ return () => window.removeEventListener('scroll', _.debounce(handleScroll, 5));
63
+ });
64
+ return (React.createElement(Grid, { className: b({ 'with-border': withHeaderBorder }) },
51
65
  React.createElement(Row, null,
52
66
  React.createElement(Col, null,
53
67
  React.createElement("header", { className: b('wrapper') },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/page-constructor",
3
- "version": "2.22.1",
3
+ "version": "2.23.0-alpha.0",
4
4
  "description": "Gravity UI Page Constructor",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -139,5 +139,8 @@
139
139
  "*.{json,yaml,yml,md}": [
140
140
  "prettier --write"
141
141
  ]
142
+ },
143
+ "publishConfig": {
144
+ "tag": "alpha"
142
145
  }
143
146
  }
@@ -63,6 +63,7 @@ export interface HeaderData {
63
63
  leftItems: NavigationItemModel[];
64
64
  rightItems?: NavigationItemModel[];
65
65
  iconSize?: number;
66
+ withBorder?: boolean;
66
67
  }
67
68
  export interface FooterColumn {
68
69
  title: string;