@gravity-ui/page-constructor 1.2.3-alpha.3 → 1.2.3-alpha.5

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.
@@ -124,6 +124,16 @@ unpredictable css rules order in build */
124
124
  top: 16px;
125
125
  z-index: 11;
126
126
  }
127
+ .pc-header-block__background-media {
128
+ height: 100%;
129
+ }
130
+ .pc-header-block__background-media > div {
131
+ height: 100%;
132
+ width: 100%;
133
+ }
134
+ .pc-header-block__background-media > div:not(.pc-header-block__video) {
135
+ position: absolute;
136
+ }
127
137
  .pc-header-block__background, .pc-header-block__background.pc-header-block__background_media {
128
138
  position: absolute;
129
139
  top: 0;
@@ -142,9 +152,6 @@ unpredictable css rules order in build */
142
152
  .pc-header-block__background.pc-header-block__background_full-width-media > div, .pc-header-block__background.pc-header-block__background_media.pc-header-block__background_full-width-media > div {
143
153
  max-width: none;
144
154
  }
145
- .pc-header-block__background.pc-header-block__background_full-width-media .pc-header-block__background-media, .pc-header-block__background.pc-header-block__background_media.pc-header-block__background_full-width-media .pc-header-block__background-media {
146
- height: 100%;
147
- }
148
155
  .pc-header-block__background.pc-header-block__background_full-width-media video, .pc-header-block__background.pc-header-block__background_media.pc-header-block__background_full-width-media video {
149
156
  height: 100%;
150
157
  width: 100%;
@@ -7,34 +7,37 @@ const utils_1 = require("../../utils");
7
7
  const components_1 = require("../../components");
8
8
  const grid_1 = require("../../grid");
9
9
  const utils_2 = require("./utils");
10
+ const mobileContext_1 = require("../../context/mobileContext");
10
11
  const YFMWrapper_1 = (0, tslib_1.__importDefault)(require("../../components/YFMWrapper/YFMWrapper"));
11
12
  const HeaderBreadcrumbs_1 = (0, tslib_1.__importDefault)(require("../../components/HeaderBreadcrumbs/HeaderBreadcrumbs"));
12
13
  const ThemeValueContext_1 = require("../../context/theme/ThemeValueContext");
13
14
  const utils_3 = require("../../components/Media/Image/utils");
14
15
  const b = (0, utils_1.block)('header-block');
15
- const Background = ({ background }) => {
16
- const { url, image, fullWidthMedia } = background;
16
+ const Background = ({ background, isMobile }) => {
17
+ const { url, image, fullWidthMedia, video, color } = background;
17
18
  const imageObject = url ? (0, utils_3.getMediaImage)(url) : image;
18
- return (react_1.default.createElement(components_1.BackgroundMedia, Object.assign({}, background, { image: imageObject, animated: false, parallax: false, mediaClassName: b('background-media'), className: b('background', { media: true, 'full-width-media': fullWidthMedia }) })));
19
+ const renderMedia = !isMobile || (typeof image === 'object' && 'mobile' in image);
20
+ return (react_1.default.createElement("div", { className: b('background', { media: true, 'full-width-media': fullWidthMedia }), style: { backgroundColor: color } }, renderMedia && (react_1.default.createElement(components_1.Media, Object.assign({}, background, { className: b('background-media'), imageClassName: b('image'), videoClassName: b('video'), isBackground: true, parallax: false, video: isMobile ? undefined : video, image: imageObject })))));
19
21
  };
20
22
  const FullWidthBackground = ({ background }) => (react_1.default.createElement("div", { className: b('background', { ['full-width']: true }), style: { backgroundColor: background === null || background === void 0 ? void 0 : background.color } }));
21
23
  const HeaderBlock = (props) => {
22
24
  const { title, overtitle, description, buttons, image, video, width = 'm', imageSize, offset = 'default', background, theme: textTheme = 'light', verticalOffset = 'm', className, breadcrumbs, status, children, } = props;
25
+ const isMobile = (0, react_1.useContext)(mobileContext_1.MobileContext);
23
26
  const { themeValue: theme } = (0, react_1.useContext)(ThemeValueContext_1.ThemeValueContext);
24
- const hasMedia = Boolean(image || video);
27
+ const hasRightSideImage = Boolean(image || video);
25
28
  const curImageSize = imageSize || (0, utils_2.getImageSize)(width);
26
- const titleSizes = hasMedia ? (0, utils_2.titleWithImageSizes)(curImageSize) : (0, utils_2.getTitleSizes)(width);
29
+ const titleSizes = hasRightSideImage ? (0, utils_2.titleWithImageSizes)(curImageSize) : (0, utils_2.getTitleSizes)(width);
27
30
  let curVerticalOffset = verticalOffset;
28
- if (hasMedia && !verticalOffset) {
31
+ if (hasRightSideImage && !verticalOffset) {
29
32
  curVerticalOffset = 'm';
30
33
  }
31
34
  const backgroundThemed = background && (0, utils_1.getThemedValue)(background, theme);
32
35
  const imageThemed = image && (0, utils_1.getThemedValue)(image, theme);
33
36
  const videoThemed = video && (0, utils_1.getThemedValue)(video, theme);
34
- const fullWidth = backgroundThemed === null || backgroundThemed === void 0 ? void 0 : backgroundThemed.fullWidth;
35
- return (react_1.default.createElement("header", { className: b({ ['has-media']: hasMedia, ['full-width']: fullWidth }, className) },
37
+ const fullWidth = (backgroundThemed === null || backgroundThemed === void 0 ? void 0 : backgroundThemed.fullWidth) || (backgroundThemed === null || backgroundThemed === void 0 ? void 0 : backgroundThemed.fullWidthMedia);
38
+ return (react_1.default.createElement("header", { className: b({ ['has-media']: hasRightSideImage, ['full-width']: fullWidth }, className) },
36
39
  backgroundThemed && fullWidth && react_1.default.createElement(FullWidthBackground, { background: backgroundThemed }),
37
- backgroundThemed && react_1.default.createElement(Background, { background: backgroundThemed }),
40
+ backgroundThemed && react_1.default.createElement(Background, { background: backgroundThemed, isMobile: isMobile }),
38
41
  react_1.default.createElement(grid_1.Grid, { containerClass: b('container-fluid') },
39
42
  breadcrumbs && (react_1.default.createElement(grid_1.Row, { className: b('breadcrumbs') },
40
43
  react_1.default.createElement(grid_1.Col, null,
@@ -59,7 +62,7 @@ const HeaderBlock = (props) => {
59
62
  buttons.map((button, index) => (react_1.default.createElement(components_1.RouterLink, { href: button.url, key: index },
60
63
  react_1.default.createElement(components_1.Button, Object.assign({ key: index, className: b('button'), size: "xl" }, button))))))),
61
64
  children))),
62
- hasMedia && (react_1.default.createElement(components_1.Media, { className: b('media', { [curImageSize]: true }), videoClassName: b('video'), imageClassName: b('image'), video: videoThemed, image: imageThemed })))))));
65
+ hasRightSideImage && (react_1.default.createElement(components_1.Media, { className: b('media', { [curImageSize]: true }), videoClassName: b('video'), imageClassName: b('image'), video: videoThemed, image: imageThemed })))))));
63
66
  };
64
67
  exports.HeaderBlock = HeaderBlock;
65
68
  exports.default = exports.HeaderBlock;