@gravity-ui/page-constructor 3.0.0-alpha.6 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +59 -0
- package/README.md +16 -1
- package/build/cjs/blocks/CardLayout/CardLayout.js +1 -1
- package/build/cjs/blocks/CardLayout/schema.d.ts +2 -2
- package/build/cjs/blocks/CardLayout/schema.js +1 -1
- package/build/cjs/blocks/FilterBlock/FilterBlock.js +9 -13
- package/build/cjs/blocks/Header/schema.d.ts +243 -0
- package/build/cjs/blocks/HeaderSlider/schema.d.ts +81 -0
- package/build/cjs/blocks/Media/schema.d.ts +162 -0
- package/build/cjs/blocks/PromoFeaturesBlock/schema.d.ts +81 -0
- package/build/cjs/blocks/Slider/Slider.js +1 -1
- package/build/cjs/blocks/Tabs/schema.d.ts +81 -0
- package/build/cjs/components/FullscreenImage/{FullScreenImage.css → FullscreenImage.css} +13 -13
- package/build/cjs/components/FullscreenImage/FullscreenImage.d.ts +3 -3
- package/build/cjs/components/FullscreenImage/FullscreenImage.js +7 -7
- package/build/cjs/components/FullscreenImage/i18n/index.js +1 -1
- package/build/cjs/components/FullscreenMedia/FullscreenMedia.d.ts +9 -0
- package/build/cjs/components/FullscreenMedia/{FullScreenMedia.js → FullscreenMedia.js} +5 -5
- package/build/cjs/components/Media/FullscreenVideo/FullscreenVideo.d.ts +4 -0
- package/build/cjs/components/Media/FullscreenVideo/FullscreenVideo.js +10 -0
- package/build/cjs/components/Media/Image/Image.d.ts +1 -0
- package/build/cjs/components/Media/Image/Image.js +10 -3
- package/build/cjs/components/Media/Media.js +25 -5
- package/build/cjs/components/Media/Video/Video.d.ts +1 -1
- package/build/cjs/components/VideoBlock/VideoBlock.d.ts +3 -2
- package/build/cjs/components/VideoBlock/VideoBlock.js +8 -4
- package/build/cjs/components/index.d.ts +1 -1
- package/build/cjs/components/index.js +3 -3
- package/build/cjs/constructor-items.d.ts +1 -1
- package/build/cjs/grid/Col/Col.d.ts +1 -1
- package/build/cjs/icons/Fullscreen.d.ts +2 -0
- package/build/cjs/icons/{FullScreen.js → Fullscreen.js} +3 -3
- package/build/cjs/icons/index.d.ts +1 -1
- package/build/cjs/icons/index.js +1 -1
- package/build/cjs/models/common.d.ts +2 -1
- package/build/cjs/models/common.js +1 -0
- package/build/cjs/models/constructor-items/blocks.d.ts +1 -1
- package/build/cjs/models/constructor-items/common.d.ts +1 -1
- package/build/cjs/models/constructor-items/sub-blocks.d.ts +1 -1
- package/build/cjs/schema/validators/common.d.ts +81 -0
- package/build/cjs/schema/validators/common.js +6 -0
- package/build/cjs/sub-blocks/LayoutItem/LayoutItem.d.ts +1 -1
- package/build/cjs/sub-blocks/LayoutItem/LayoutItem.js +4 -4
- package/build/cjs/sub-blocks/LayoutItem/schema.d.ts +82 -1
- package/build/cjs/sub-blocks/LayoutItem/schema.js +1 -1
- package/build/cjs/sub-blocks/LayoutItem/utils.d.ts +2 -2
- package/build/cjs/sub-blocks/LayoutItem/utils.js +6 -6
- package/build/cjs/sub-blocks/MediaCard/schema.d.ts +85 -0
- package/build/cjs/sub-blocks/MediaCard/schema.js +1 -1
- package/build/esm/blocks/CardLayout/CardLayout.js +1 -1
- package/build/esm/blocks/CardLayout/schema.d.ts +2 -2
- package/build/esm/blocks/CardLayout/schema.js +1 -1
- package/build/esm/blocks/FilterBlock/FilterBlock.js +10 -14
- package/build/esm/blocks/Header/schema.d.ts +243 -0
- package/build/esm/blocks/HeaderSlider/schema.d.ts +81 -0
- package/build/esm/blocks/Media/schema.d.ts +162 -0
- package/build/esm/blocks/PromoFeaturesBlock/schema.d.ts +81 -0
- package/build/esm/blocks/Slider/Slider.js +2 -2
- package/build/esm/blocks/Tabs/Tabs.js +2 -2
- package/build/esm/blocks/Tabs/schema.d.ts +81 -0
- package/build/esm/components/FullscreenImage/{FullScreenImage.css → FullscreenImage.css} +13 -13
- package/build/esm/components/FullscreenImage/FullscreenImage.d.ts +4 -4
- package/build/esm/components/FullscreenImage/FullscreenImage.js +9 -9
- package/build/esm/components/FullscreenImage/i18n/index.js +1 -1
- package/build/esm/components/FullscreenMedia/FullscreenMedia.d.ts +10 -0
- package/build/esm/components/FullscreenMedia/{FullScreenMedia.js → FullscreenMedia.js} +7 -7
- package/build/esm/components/Media/FullscreenVideo/FullscreenVideo.d.ts +4 -0
- package/build/esm/components/Media/FullscreenVideo/FullscreenVideo.js +7 -0
- package/build/esm/components/Media/Image/Image.d.ts +1 -0
- package/build/esm/components/Media/Image/Image.js +12 -5
- package/build/esm/components/Media/Media.js +25 -5
- package/build/esm/components/Media/Video/Video.d.ts +1 -1
- package/build/esm/components/VideoBlock/VideoBlock.d.ts +3 -2
- package/build/esm/components/VideoBlock/VideoBlock.js +8 -4
- package/build/esm/components/index.d.ts +1 -1
- package/build/esm/components/index.js +1 -1
- package/build/esm/constructor-items.d.ts +1 -1
- package/build/esm/grid/Col/Col.d.ts +1 -1
- package/build/esm/icons/Fullscreen.d.ts +2 -0
- package/build/esm/icons/{FullScreen.js → Fullscreen.js} +1 -1
- package/build/esm/icons/index.d.ts +1 -1
- package/build/esm/icons/index.js +1 -1
- package/build/esm/models/common.d.ts +2 -1
- package/build/esm/models/common.js +1 -0
- package/build/esm/models/constructor-items/blocks.d.ts +1 -1
- package/build/esm/models/constructor-items/common.d.ts +1 -1
- package/build/esm/models/constructor-items/sub-blocks.d.ts +1 -1
- package/build/esm/schema/validators/common.d.ts +81 -0
- package/build/esm/schema/validators/common.js +6 -0
- package/build/esm/sub-blocks/LayoutItem/LayoutItem.d.ts +1 -1
- package/build/esm/sub-blocks/LayoutItem/LayoutItem.js +6 -6
- package/build/esm/sub-blocks/LayoutItem/schema.d.ts +82 -1
- package/build/esm/sub-blocks/LayoutItem/schema.js +1 -1
- package/build/esm/sub-blocks/LayoutItem/utils.d.ts +2 -2
- package/build/esm/sub-blocks/LayoutItem/utils.js +3 -3
- package/build/esm/sub-blocks/MediaCard/schema.d.ts +85 -0
- package/build/esm/sub-blocks/MediaCard/schema.js +2 -2
- package/package.json +1 -4
- package/server/models/common.d.ts +2 -1
- package/server/models/common.js +1 -0
- package/server/models/constructor-items/blocks.d.ts +1 -1
- package/server/models/constructor-items/common.d.ts +1 -1
- package/server/models/constructor-items/sub-blocks.d.ts +1 -1
- package/build/cjs/components/FullscreenMedia/FullScreenMedia.d.ts +0 -9
- package/build/cjs/icons/FullScreen.d.ts +0 -2
- package/build/esm/components/FullscreenMedia/FullScreenMedia.d.ts +0 -10
- package/build/esm/icons/FullScreen.d.ts +0 -2
- /package/build/cjs/components/FullscreenMedia/{FullScreenMedia.css → FullscreenMedia.css} +0 -0
- /package/build/esm/components/FullscreenMedia/{FullScreenMedia.css → FullscreenMedia.css} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { Fragment, useContext, useRef, useState } from 'react';
|
|
2
2
|
import AnimateBlock from '../../components/AnimateBlock/AnimateBlock';
|
|
3
3
|
import ButtonTabs from '../../components/ButtonTabs/ButtonTabs';
|
|
4
|
-
import
|
|
4
|
+
import FullscreenImage from '../../components/FullscreenImage/FullscreenImage';
|
|
5
5
|
import { getMediaImage } from '../../components/Media/Image/utils';
|
|
6
6
|
import Media from '../../components/Media/Media';
|
|
7
7
|
import Title from '../../components/Title/Title';
|
|
@@ -44,7 +44,7 @@ export const TabsBlock = ({ items, title, description, animated, tabsColSizes, c
|
|
|
44
44
|
}, className: b('col', { centered: centered }) },
|
|
45
45
|
React.createElement("div", { ref: ref }, (activeTabData === null || activeTabData === void 0 ? void 0 : activeTabData.media) && (React.createElement(Media, Object.assign({}, getThemedValue(activeTabData.media, theme), { key: activeTab, className: b('media'), playVideo: play, height: mediaHeight })))),
|
|
46
46
|
imageProps && (React.createElement(Fragment, null,
|
|
47
|
-
React.createElement(
|
|
47
|
+
React.createElement(FullscreenImage, Object.assign({}, imageProps, { imageClassName: b('image') })))),
|
|
48
48
|
(activeTabData === null || activeTabData === void 0 ? void 0 : activeTabData.caption) && React.createElement("p", { className: b('caption') }, activeTabData.caption)));
|
|
49
49
|
const onSelectTab = (id, e) => {
|
|
50
50
|
setActiveTab(id);
|
|
@@ -142,6 +142,87 @@ export declare const tabsItem: {
|
|
|
142
142
|
type: string;
|
|
143
143
|
})[];
|
|
144
144
|
};
|
|
145
|
+
fullscreen: {
|
|
146
|
+
type: string;
|
|
147
|
+
};
|
|
148
|
+
analyticsEvents: {
|
|
149
|
+
anyOf: ({
|
|
150
|
+
type: string;
|
|
151
|
+
additionalProperties: {
|
|
152
|
+
type: string;
|
|
153
|
+
};
|
|
154
|
+
required: string[];
|
|
155
|
+
properties: {
|
|
156
|
+
name: {
|
|
157
|
+
type: string;
|
|
158
|
+
};
|
|
159
|
+
type: {
|
|
160
|
+
type: string;
|
|
161
|
+
};
|
|
162
|
+
counters: {
|
|
163
|
+
type: string;
|
|
164
|
+
additionalProperties: boolean;
|
|
165
|
+
required: never[];
|
|
166
|
+
properties: {
|
|
167
|
+
include: {
|
|
168
|
+
type: string;
|
|
169
|
+
items: {
|
|
170
|
+
type: string;
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
exclude: {
|
|
174
|
+
type: string;
|
|
175
|
+
items: {
|
|
176
|
+
type: string;
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
context: {
|
|
182
|
+
type: string;
|
|
183
|
+
};
|
|
184
|
+
};
|
|
185
|
+
} | {
|
|
186
|
+
type: string;
|
|
187
|
+
items: {
|
|
188
|
+
type: string;
|
|
189
|
+
additionalProperties: {
|
|
190
|
+
type: string;
|
|
191
|
+
};
|
|
192
|
+
required: string[];
|
|
193
|
+
properties: {
|
|
194
|
+
name: {
|
|
195
|
+
type: string;
|
|
196
|
+
};
|
|
197
|
+
type: {
|
|
198
|
+
type: string;
|
|
199
|
+
};
|
|
200
|
+
counters: {
|
|
201
|
+
type: string;
|
|
202
|
+
additionalProperties: boolean;
|
|
203
|
+
required: never[];
|
|
204
|
+
properties: {
|
|
205
|
+
include: {
|
|
206
|
+
type: string;
|
|
207
|
+
items: {
|
|
208
|
+
type: string;
|
|
209
|
+
};
|
|
210
|
+
};
|
|
211
|
+
exclude: {
|
|
212
|
+
type: string;
|
|
213
|
+
items: {
|
|
214
|
+
type: string;
|
|
215
|
+
};
|
|
216
|
+
};
|
|
217
|
+
};
|
|
218
|
+
};
|
|
219
|
+
context: {
|
|
220
|
+
type: string;
|
|
221
|
+
};
|
|
222
|
+
};
|
|
223
|
+
};
|
|
224
|
+
})[];
|
|
225
|
+
};
|
|
145
226
|
};
|
|
146
227
|
} | {
|
|
147
228
|
type: string;
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
/* use this for style redefinitions to awoid problems with
|
|
2
2
|
unpredictable css rules order in build */
|
|
3
|
-
.pc-
|
|
3
|
+
.pc-fullscreen-image__image {
|
|
4
4
|
cursor: pointer;
|
|
5
5
|
}
|
|
6
|
-
.pc-
|
|
6
|
+
.pc-fullscreen-image__image-wrapper {
|
|
7
7
|
position: relative;
|
|
8
8
|
}
|
|
9
|
-
.pc-
|
|
9
|
+
.pc-fullscreen-image__modal-content {
|
|
10
10
|
position: relative;
|
|
11
11
|
}
|
|
12
|
-
.pc-
|
|
12
|
+
.pc-fullscreen-image__modal-image {
|
|
13
13
|
display: block;
|
|
14
14
|
max-width: 1232px;
|
|
15
15
|
max-height: 70vh;
|
|
16
16
|
overflow: hidden;
|
|
17
17
|
}
|
|
18
|
-
.pc-
|
|
18
|
+
.pc-fullscreen-image__modal .yc-modal__content, .pc-fullscreen-image__modal-image {
|
|
19
19
|
border-radius: var(--pc-border-radius);
|
|
20
20
|
}
|
|
21
|
-
.pc-
|
|
21
|
+
.pc-fullscreen-image__icon-wrapper {
|
|
22
22
|
display: flex;
|
|
23
23
|
align-items: center;
|
|
24
24
|
justify-content: center;
|
|
@@ -33,28 +33,28 @@ unpredictable css rules order in build */
|
|
|
33
33
|
opacity: 0;
|
|
34
34
|
transition: 0.3s;
|
|
35
35
|
}
|
|
36
|
-
.pc-
|
|
36
|
+
.pc-fullscreen-image__icon-wrapper_visible {
|
|
37
37
|
opacity: 1;
|
|
38
38
|
}
|
|
39
|
-
.pc-
|
|
39
|
+
.pc-fullscreen-image__icon {
|
|
40
40
|
color: var(--yc-color-text-hint);
|
|
41
41
|
}
|
|
42
|
-
.pc-
|
|
42
|
+
.pc-fullscreen-image__icon_hover:hover {
|
|
43
43
|
color: var(--yc-color-text-secondary);
|
|
44
44
|
}
|
|
45
45
|
@media (max-width: 1185px) {
|
|
46
|
-
.pc-
|
|
46
|
+
.pc-fullscreen-image__modal-image {
|
|
47
47
|
width: 100%;
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
@media (max-width: 1081px) {
|
|
51
|
-
.pc-
|
|
51
|
+
.pc-fullscreen-image__image {
|
|
52
52
|
pointer-events: none;
|
|
53
53
|
}
|
|
54
|
-
.pc-
|
|
54
|
+
.pc-fullscreen-image__icon-wrapper {
|
|
55
55
|
display: none;
|
|
56
56
|
}
|
|
57
|
-
.pc-
|
|
57
|
+
.pc-fullscreen-image__modal {
|
|
58
58
|
display: none !important; /* stylelint-disable-line declaration-no-important */
|
|
59
59
|
}
|
|
60
60
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { CSSProperties } from 'react';
|
|
2
2
|
import { ImageProps } from '../Image/Image';
|
|
3
|
-
import './
|
|
4
|
-
export interface
|
|
3
|
+
import './FullscreenImage.css';
|
|
4
|
+
export interface FullscreenImageProps extends ImageProps {
|
|
5
5
|
imageClassName?: string;
|
|
6
6
|
modalImageClass?: string;
|
|
7
7
|
imageStyle?: CSSProperties;
|
|
8
8
|
}
|
|
9
|
-
declare const
|
|
10
|
-
export default
|
|
9
|
+
declare const FullscreenImage: (props: FullscreenImageProps) => JSX.Element;
|
|
10
|
+
export default FullscreenImage;
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import { Icon, Modal } from '@gravity-ui/uikit';
|
|
3
|
-
import {
|
|
3
|
+
import { Fullscreen, PreviewClose } from '../../icons';
|
|
4
4
|
import { block } from '../../utils';
|
|
5
5
|
import Image from '../Image/Image';
|
|
6
6
|
import i18n from './i18n';
|
|
7
|
-
import './
|
|
8
|
-
const b = block('
|
|
7
|
+
import './FullscreenImage.css';
|
|
8
|
+
const b = block('fullscreen-image');
|
|
9
9
|
const FULL_SCREEN_ICON_SIZE = 18;
|
|
10
10
|
const CLOSE_ICON_SIZE = 30;
|
|
11
|
-
const
|
|
11
|
+
const FullscreenImage = (props) => {
|
|
12
12
|
const { imageClassName, modalImageClass, imageStyle, alt = i18n('img-alt') } = props;
|
|
13
13
|
const [isOpened, setIsOpened] = useState(false);
|
|
14
14
|
const [isMouseEnter, setIsMouseEnter] = useState(false);
|
|
15
15
|
const openModal = () => setIsOpened(true);
|
|
16
16
|
const closeModal = () => setIsOpened(false);
|
|
17
|
-
const
|
|
18
|
-
const
|
|
17
|
+
const showFullscreenIcon = () => setIsMouseEnter(true);
|
|
18
|
+
const hideFullscreenIcon = () => setIsMouseEnter(false);
|
|
19
19
|
return (React.createElement("div", { className: b() },
|
|
20
|
-
React.createElement("div", { className: b('image-wrapper'), onMouseEnter:
|
|
20
|
+
React.createElement("div", { className: b('image-wrapper'), onMouseEnter: showFullscreenIcon, onMouseLeave: hideFullscreenIcon },
|
|
21
21
|
React.createElement(Image, Object.assign({}, props, { alt: alt, className: b('image', imageClassName), onClick: openModal, style: imageStyle })),
|
|
22
22
|
React.createElement("div", { className: b('icon-wrapper', { visible: isMouseEnter }), onClick: openModal },
|
|
23
|
-
React.createElement(Icon, { data:
|
|
23
|
+
React.createElement(Icon, { data: Fullscreen, width: FULL_SCREEN_ICON_SIZE, height: FULL_SCREEN_ICON_SIZE, className: b('icon') }))),
|
|
24
24
|
isOpened && (React.createElement(Modal, { open: isOpened, onClose: closeModal, className: b('modal') },
|
|
25
25
|
React.createElement("div", { className: b('modal-content') },
|
|
26
26
|
React.createElement("div", { className: b('icon-wrapper', { visible: true }), onClick: closeModal },
|
|
27
27
|
React.createElement(Icon, { data: PreviewClose, width: CLOSE_ICON_SIZE, height: CLOSE_ICON_SIZE, className: b('icon', { hover: true }) })),
|
|
28
28
|
React.createElement(Image, Object.assign({}, props, { className: b('modal-image', modalImageClass) })))))));
|
|
29
29
|
};
|
|
30
|
-
export default
|
|
30
|
+
export default FullscreenImage;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { MediaAllProps } from '../Media/Media';
|
|
3
|
+
import './FullscreenMedia.css';
|
|
4
|
+
export type ChildMediaRenderProps = Pick<MediaAllProps, 'fullscreen' | 'imageClassName' | 'videoClassName' | 'youtubeClassName' | 'className'>;
|
|
5
|
+
export interface FullscreenMediaProps {
|
|
6
|
+
showFullscreenIcon?: boolean;
|
|
7
|
+
children: (props?: ChildMediaRenderProps) => JSX.Element;
|
|
8
|
+
}
|
|
9
|
+
declare const FullscreenMedia: ({ children, showFullscreenIcon }: FullscreenMediaProps) => JSX.Element;
|
|
10
|
+
export default FullscreenMedia;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import React, { useContext, useState } from 'react';
|
|
2
2
|
import { Icon, Modal } from '@gravity-ui/uikit';
|
|
3
3
|
import { MobileContext } from '../../context/mobileContext';
|
|
4
|
-
import {
|
|
4
|
+
import { Fullscreen, PreviewClose } from '../../icons';
|
|
5
5
|
import { block } from '../../utils';
|
|
6
|
-
import './
|
|
6
|
+
import './FullscreenMedia.css';
|
|
7
7
|
const b = block('full-screen-media');
|
|
8
8
|
const FULL_SCREEN_ICON_SIZE = 18;
|
|
9
9
|
const CLOSE_ICON_SIZE = 30;
|
|
10
10
|
const getMediaClass = (type) => b('modal-media', { type });
|
|
11
|
-
const
|
|
11
|
+
const FullscreenMedia = ({ children, showFullscreenIcon = true }) => {
|
|
12
12
|
const [isOpened, setIsOpened] = useState(false);
|
|
13
13
|
const isMobile = useContext(MobileContext);
|
|
14
14
|
const openModal = (e) => {
|
|
@@ -22,8 +22,8 @@ const FullScreenMedia = ({ children, showFullScreenIcon = true }) => {
|
|
|
22
22
|
return (React.createElement("div", { className: b() },
|
|
23
23
|
React.createElement("div", { className: b('media-wrapper'), onClickCapture: openModal },
|
|
24
24
|
children({ className: b('inline-media') }),
|
|
25
|
-
|
|
26
|
-
React.createElement(Icon, { data:
|
|
25
|
+
showFullscreenIcon && (React.createElement("div", { className: b('icon-wrapper'), onClickCapture: openModal },
|
|
26
|
+
React.createElement(Icon, { data: Fullscreen, width: FULL_SCREEN_ICON_SIZE, height: FULL_SCREEN_ICON_SIZE, className: b('icon') })))),
|
|
27
27
|
isOpened && (React.createElement(Modal, { open: isOpened, onClose: closeModal, className: b('modal') },
|
|
28
28
|
React.createElement("div", { className: b('modal-content') },
|
|
29
29
|
React.createElement("div", { className: b('icon-wrapper', { visible: true }), onClick: closeModal },
|
|
@@ -32,7 +32,7 @@ const FullScreenMedia = ({ children, showFullScreenIcon = true }) => {
|
|
|
32
32
|
imageClassName: getMediaClass('image'),
|
|
33
33
|
videoClassName: getMediaClass('video'),
|
|
34
34
|
youtubeClassName: getMediaClass('youtube'),
|
|
35
|
-
|
|
35
|
+
fullscreen: true,
|
|
36
36
|
}))))));
|
|
37
37
|
};
|
|
38
|
-
export default
|
|
38
|
+
export default FullscreenMedia;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import FullscreenMedia from '../../FullscreenMedia/FullscreenMedia';
|
|
3
|
+
import Video from '../Video/Video';
|
|
4
|
+
const FullscreenVideo = (props) => {
|
|
5
|
+
return (React.createElement(FullscreenMedia, null, (classNames) => React.createElement(Video, Object.assign({}, props, classNames))));
|
|
6
|
+
};
|
|
7
|
+
export default FullscreenVideo;
|
|
@@ -5,13 +5,13 @@ import SliderBlock from '../../../blocks/Slider/Slider';
|
|
|
5
5
|
import { SliderType } from '../../../models';
|
|
6
6
|
import { block } from '../../../utils';
|
|
7
7
|
import BackgroundImage from '../../BackgroundImage/BackgroundImage';
|
|
8
|
-
import
|
|
8
|
+
import FullscreenImage from '../../FullscreenImage/FullscreenImage';
|
|
9
9
|
import ImageView from '../../Image/Image';
|
|
10
10
|
import { getMediaImage } from './utils';
|
|
11
11
|
import './Image.css';
|
|
12
12
|
const b = block('media-component-image');
|
|
13
13
|
const Image = (props) => {
|
|
14
|
-
const { parallax, image, height, imageClassName, isBackground, hasVideoFallback, video } = props;
|
|
14
|
+
const { parallax, image, height, imageClassName, isBackground, hasVideoFallback, video, fullscreen, } = props;
|
|
15
15
|
const [scrollY, setScrollY] = useState(0);
|
|
16
16
|
const [{ springScrollY }, springSetScrollY] = useSpring(() => ({
|
|
17
17
|
springScrollY: 0,
|
|
@@ -32,10 +32,10 @@ const Image = (props) => {
|
|
|
32
32
|
parallaxInterpolate = springScrollY.interpolate((value) => `translateY(-${Number(value) / parallaxLevel}px)`);
|
|
33
33
|
}
|
|
34
34
|
const imageClass = b('item', { withVideo: Boolean(video) && !hasVideoFallback }, imageClassName);
|
|
35
|
-
const
|
|
35
|
+
const renderFullscreenImage = (item) => {
|
|
36
36
|
const itemData = getMediaImage(item);
|
|
37
|
-
return (React.createElement(
|
|
38
|
-
}
|
|
37
|
+
return (React.createElement(FullscreenImage, Object.assign({ key: itemData.alt }, itemData, { imageClassName: imageClass, imageStyle: { height } })));
|
|
38
|
+
};
|
|
39
39
|
const imageBackground = (oneImage) => {
|
|
40
40
|
const imageData = getMediaImage(oneImage);
|
|
41
41
|
return (React.createElement(animated.div, { style: { transform: parallaxInterpolate } },
|
|
@@ -45,9 +45,16 @@ const Image = (props) => {
|
|
|
45
45
|
const imageData = getMediaImage(oneImage);
|
|
46
46
|
return React.createElement(ImageView, Object.assign({}, imageData, { className: imageClass, style: { height } }));
|
|
47
47
|
};
|
|
48
|
+
const imageSlider = (imageArray) => {
|
|
49
|
+
const fullscreenItem = fullscreen === undefined || fullscreen;
|
|
50
|
+
return (React.createElement(SliderBlock, { slidesToShow: 1, type: SliderType.MediaCard }, imageArray.map((item) => fullscreenItem ? renderFullscreenImage(item) : imageOnly(item))));
|
|
51
|
+
};
|
|
48
52
|
if (Array.isArray(image)) {
|
|
49
53
|
return imageSlider(image);
|
|
50
54
|
}
|
|
55
|
+
if (fullscreen) {
|
|
56
|
+
return renderFullscreenImage(image);
|
|
57
|
+
}
|
|
51
58
|
return isBackground ? imageBackground(image) : imageOnly(image);
|
|
52
59
|
};
|
|
53
60
|
export default Image;
|
|
@@ -2,24 +2,44 @@ import React, { useMemo, useState } from 'react';
|
|
|
2
2
|
import { block } from '../../utils';
|
|
3
3
|
import YoutubeBlock from '../VideoBlock/VideoBlock';
|
|
4
4
|
import DataLens from './DataLens/DataLens';
|
|
5
|
+
import FullscreenVideo from './FullscreenVideo/FullscreenVideo';
|
|
5
6
|
import Image from './Image/Image';
|
|
6
7
|
import Video from './Video/Video';
|
|
7
8
|
import './Media.css';
|
|
8
9
|
const b = block('Media');
|
|
9
10
|
export const Media = (props) => {
|
|
10
|
-
const { image, video, youtube, dataLens, color, height, previewImg, parallax = false, metrika,
|
|
11
|
+
const { image, video, youtube, dataLens, color, height, previewImg, parallax = false, metrika, fullscreen, analyticsEvents, } = props;
|
|
11
12
|
const { className, imageClassName, videoClassName, youtubeClassName, playVideo = true, isBackground, playButton, customBarControlsClassName, } = props;
|
|
12
13
|
const [hasVideoFallback, setHasVideoFallback] = useState(false);
|
|
13
14
|
const content = useMemo(() => {
|
|
14
15
|
let result = [];
|
|
15
16
|
if (image) {
|
|
16
|
-
result.push(React.createElement(Image, { key: "image", parallax: parallax, image: image, height: height, imageClassName: imageClassName, isBackground: isBackground, video: video, hasVideoFallback: hasVideoFallback }));
|
|
17
|
+
result.push(React.createElement(Image, { key: "image", parallax: parallax, image: image, height: height, imageClassName: imageClassName, isBackground: isBackground, video: video, hasVideoFallback: hasVideoFallback, fullscreen: fullscreen }));
|
|
17
18
|
}
|
|
18
19
|
if (video) {
|
|
19
|
-
|
|
20
|
+
const videoProps = {
|
|
21
|
+
key: 'video',
|
|
22
|
+
video,
|
|
23
|
+
videoClassName,
|
|
24
|
+
height,
|
|
25
|
+
metrika,
|
|
26
|
+
analyticsEvents,
|
|
27
|
+
playVideo,
|
|
28
|
+
previewImg,
|
|
29
|
+
playButton,
|
|
30
|
+
customBarControlsClassName,
|
|
31
|
+
hasVideoFallback,
|
|
32
|
+
setHasVideoFallback,
|
|
33
|
+
};
|
|
34
|
+
if (fullscreen) {
|
|
35
|
+
result.push(React.createElement(FullscreenVideo, Object.assign({}, videoProps)));
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
result.push(React.createElement(Video, Object.assign({}, videoProps)));
|
|
39
|
+
}
|
|
20
40
|
}
|
|
21
41
|
if (youtube) {
|
|
22
|
-
result = (React.createElement(YoutubeBlock, { className: b('youtube', youtubeClassName), record: youtube, attributes: { color: 'white', rel: '0' }, previewImg: previewImg, height: height,
|
|
42
|
+
result = (React.createElement(YoutubeBlock, { className: b('youtube', youtubeClassName), record: youtube, attributes: { color: 'white', rel: '0' }, previewImg: previewImg, height: height, fullscreen: fullscreen, analyticsEvents: analyticsEvents }));
|
|
23
43
|
}
|
|
24
44
|
if (dataLens) {
|
|
25
45
|
result = React.createElement(DataLens, { dataLens: dataLens });
|
|
@@ -43,7 +63,7 @@ export const Media = (props) => {
|
|
|
43
63
|
playButton,
|
|
44
64
|
customBarControlsClassName,
|
|
45
65
|
youtubeClassName,
|
|
46
|
-
|
|
66
|
+
fullscreen,
|
|
47
67
|
]);
|
|
48
68
|
return (React.createElement("div", { className: b(null, className), style: { backgroundColor: color } }, content));
|
|
49
69
|
};
|
|
@@ -11,6 +11,6 @@ interface InnerVideoProps {
|
|
|
11
11
|
setHasVideoFallback: React.Dispatch<boolean>;
|
|
12
12
|
hasVideoFallback: boolean;
|
|
13
13
|
}
|
|
14
|
-
type VideoAllProps = VideoAdditionProps & MediaComponentVideoProps & InnerVideoProps;
|
|
14
|
+
export type VideoAllProps = VideoAdditionProps & MediaComponentVideoProps & InnerVideoProps;
|
|
15
15
|
declare const Video: (props: VideoAllProps) => JSX.Element | null;
|
|
16
16
|
export default Video;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { AnalyticsEventsBase } from '../../models/common';
|
|
2
3
|
import './VideoBlock.css';
|
|
3
4
|
export declare const AUTOPLAY_ATTRIBUTES: {
|
|
4
5
|
autoplay: number;
|
|
5
6
|
mute: number;
|
|
6
7
|
};
|
|
7
8
|
export declare function getHeight(width: number): number;
|
|
8
|
-
export interface VideoBlockProps {
|
|
9
|
+
export interface VideoBlockProps extends AnalyticsEventsBase {
|
|
9
10
|
id?: string;
|
|
10
11
|
stream?: string;
|
|
11
12
|
record?: string;
|
|
@@ -14,7 +15,7 @@ export interface VideoBlockProps {
|
|
|
14
15
|
previewImg?: string;
|
|
15
16
|
playButton?: React.ReactNode;
|
|
16
17
|
height?: number;
|
|
17
|
-
|
|
18
|
+
fullscreen?: boolean;
|
|
18
19
|
}
|
|
19
20
|
declare const VideoBlock: (props: VideoBlockProps) => JSX.Element | null;
|
|
20
21
|
export default VideoBlock;
|
|
@@ -2,7 +2,9 @@ import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
|
2
2
|
import { Icon } from '@gravity-ui/uikit';
|
|
3
3
|
import _ from 'lodash';
|
|
4
4
|
import { v4 as uuidv4 } from 'uuid';
|
|
5
|
+
import { useAnalytics } from '../../hooks/useAnalytics';
|
|
5
6
|
import { PlayVideo } from '../../icons';
|
|
7
|
+
import { DefaultEventNames } from '../../models/common';
|
|
6
8
|
import { block, getPageSearchParams } from '../../utils';
|
|
7
9
|
import Image from '../Image/Image';
|
|
8
10
|
import i18n from './i18n';
|
|
@@ -35,7 +37,8 @@ export function getHeight(width) {
|
|
|
35
37
|
return (width / 16) * 9;
|
|
36
38
|
}
|
|
37
39
|
const VideoBlock = (props) => {
|
|
38
|
-
const { stream, record, attributes, className, id, previewImg, playButton, height,
|
|
40
|
+
const { stream, record, attributes, className, id, previewImg, playButton, height, fullscreen, analyticsEvents, } = props;
|
|
41
|
+
const handleAnalytics = useAnalytics(DefaultEventNames.VideoPreview);
|
|
39
42
|
const src = getVideoSrc(stream, record);
|
|
40
43
|
const ref = useRef(null);
|
|
41
44
|
const iframeRef = useRef();
|
|
@@ -44,11 +47,12 @@ const VideoBlock = (props) => {
|
|
|
44
47
|
const [currentHeight, setCurrentHeight] = useState(height || undefined);
|
|
45
48
|
const fullId = id || uuidv4();
|
|
46
49
|
const onPreviewClick = useCallback(() => {
|
|
50
|
+
handleAnalytics(analyticsEvents);
|
|
47
51
|
if (iframeRef.current) {
|
|
48
52
|
iframeRef.current.src = `${src}?${getPageSearchParams(Object.assign(Object.assign({}, AUTOPLAY_ATTRIBUTES), (attributes || {})))}`;
|
|
49
53
|
}
|
|
50
54
|
setTimeout(() => setHidePreview(true), AUTOPLAY_DELAY);
|
|
51
|
-
}, [src, attributes]);
|
|
55
|
+
}, [handleAnalytics, analyticsEvents, src, attributes]);
|
|
52
56
|
useEffect(() => {
|
|
53
57
|
const updateSize = _.debounce(() => {
|
|
54
58
|
setCurrentHeight(ref.current ? Math.round(getHeight(ref.current.offsetWidth)) : undefined);
|
|
@@ -78,14 +82,14 @@ const VideoBlock = (props) => {
|
|
|
78
82
|
ref.current.appendChild(iframe);
|
|
79
83
|
iframeRef.current = iframe;
|
|
80
84
|
}
|
|
81
|
-
}, [stream, record, norender, src, fullId, attributes, iframeRef,
|
|
85
|
+
}, [stream, record, norender, src, fullId, attributes, iframeRef, fullscreen]);
|
|
82
86
|
useEffect(() => {
|
|
83
87
|
setHidePreview(false);
|
|
84
88
|
}, [src, setHidePreview]);
|
|
85
89
|
if (norender) {
|
|
86
90
|
return null;
|
|
87
91
|
}
|
|
88
|
-
return (React.createElement("div", { className: b(null, className), ref: ref, style: { height: currentHeight } }, previewImg && !hidePreview && !
|
|
92
|
+
return (React.createElement("div", { className: b(null, className), ref: ref, style: { height: currentHeight } }, previewImg && !hidePreview && !fullscreen && (React.createElement("div", { className: b('preview'), onClick: onPreviewClick },
|
|
89
93
|
React.createElement(Image, { src: previewImg, className: b('image'), containerClassName: b('image-wrapper') }),
|
|
90
94
|
playButton || (React.createElement("button", { className: b('button') },
|
|
91
95
|
React.createElement(Icon, { className: b('icon'), data: PlayVideo, size: 24 })))))));
|
|
@@ -33,6 +33,6 @@ export { default as Author } from './Author/Author';
|
|
|
33
33
|
export { default as RouterLink } from './RouterLink/RouterLink';
|
|
34
34
|
export { default as HTML } from './HTML/HTML';
|
|
35
35
|
export { default as MetaInfo } from './MetaInfo/MetaInfo';
|
|
36
|
-
export { default as
|
|
36
|
+
export { default as FullscreenMedia } from './FullscreenMedia/FullscreenMedia';
|
|
37
37
|
export type { RouterLinkProps } from './RouterLink/RouterLink';
|
|
38
38
|
export type { ImageBaseProps } from './ImageBase/ImageBase';
|
|
@@ -33,4 +33,4 @@ export { default as Author } from './Author/Author';
|
|
|
33
33
|
export { default as RouterLink } from './RouterLink/RouterLink';
|
|
34
34
|
export { default as HTML } from './HTML/HTML';
|
|
35
35
|
export { default as MetaInfo } from './MetaInfo/MetaInfo';
|
|
36
|
-
export { default as
|
|
36
|
+
export { default as FullscreenMedia } from './FullscreenMedia/FullscreenMedia';
|
|
@@ -23,7 +23,7 @@ export declare const subBlockMap: {
|
|
|
23
23
|
"price-detailed": (props: import("./models").PriceDetailedProps) => JSX.Element;
|
|
24
24
|
"media-card": ({ border, ...mediaProps }: import("./models").MediaCardProps) => JSX.Element;
|
|
25
25
|
"banner-card": (props: import("./models").BannerCardProps) => JSX.Element;
|
|
26
|
-
"layout-item": ({ content: { links, ...content }, metaInfo, media, border,
|
|
26
|
+
"layout-item": ({ content: { links, ...content }, metaInfo, media, border, fullscreen, className, }: import("./models").LayoutItemProps) => JSX.Element;
|
|
27
27
|
"background-card": (props: import("./models").BackgroundCardProps) => JSX.Element;
|
|
28
28
|
"basic-card": (props: import("./models").BasicCardProps) => JSX.Element;
|
|
29
29
|
content: (props: import("./models").ContentBlockProps & import("./models").ClassNameProps) => JSX.Element;
|
|
@@ -7,4 +7,4 @@ export interface GridColumnProps extends GridColumnClassParams, Refable<HTMLDivE
|
|
|
7
7
|
dataQa?: string;
|
|
8
8
|
children?: React.ReactNode;
|
|
9
9
|
}
|
|
10
|
-
export declare const Col: React.ForwardRefExoticComponent<Pick<WithChildren<GridColumnProps>, "style" | "children" | "className" | "reset" | "
|
|
10
|
+
export declare const Col: React.ForwardRefExoticComponent<Pick<WithChildren<GridColumnProps>, "style" | "children" | "className" | "reset" | "visible" | "sizes" | "offsets" | "orders" | "hidden" | "alignSelf" | "justifyContent" | "dataQa"> & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { a11yHiddenSvgProps } from '../utils/svg';
|
|
3
|
-
export const
|
|
3
|
+
export const Fullscreen = (props) => (React.createElement("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", fill: "currentColor" }, a11yHiddenSvgProps, props),
|
|
4
4
|
React.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M18 4.654v.291a10 10 0 0 0-1.763 1.404l-2.944 2.944a1 1 0 0 0 1.414 1.414l2.933-2.932A9.996 9.996 0 0 0 19.05 6h.296l-.09.39A9.993 9.993 0 0 0 19 8.64v.857a1 1 0 0 0 2 0V4.503a1.5 1.5 0 0 0-1.5-1.5L14.5 3a1 1 0 1 0 0 2h.861a10 10 0 0 0 2.249-.256l.39-.09zM4.95 18a10 10 0 0 1 1.41-1.775l2.933-2.932a1 1 0 0 1 1.414 1.414l-2.944 2.944A9.998 9.998 0 0 1 6 19.055v.291l.39-.09A9.993 9.993 0 0 1 8.64 19h.86a1 1 0 0 1 0 2l-5-.003a1.5 1.5 0 0 1-1.5-1.5V14.5a1 1 0 1 1 2 0v.861a10 10 0 0 1-.256 2.249l-.09.39h.296z" })));
|
package/build/esm/icons/index.js
CHANGED
|
@@ -79,7 +79,8 @@ export declare enum DefaultEventNames {
|
|
|
79
79
|
HubspotFormSubmit = "hubspot-form-submit",
|
|
80
80
|
QuoteButton = "quote-button-click",
|
|
81
81
|
BackLink = "back-link-click",
|
|
82
|
-
Breadcrumb = "breadcrumb-click"
|
|
82
|
+
Breadcrumb = "breadcrumb-click",
|
|
83
|
+
VideoPreview = "video-preview-click"
|
|
83
84
|
}
|
|
84
85
|
export type AnalyticsCounters = {
|
|
85
86
|
include?: string[];
|
|
@@ -45,4 +45,5 @@ export var DefaultEventNames;
|
|
|
45
45
|
DefaultEventNames["QuoteButton"] = "quote-button-click";
|
|
46
46
|
DefaultEventNames["BackLink"] = "back-link-click";
|
|
47
47
|
DefaultEventNames["Breadcrumb"] = "breadcrumb-click";
|
|
48
|
+
DefaultEventNames["VideoPreview"] = "video-preview-click";
|
|
48
49
|
})(DefaultEventNames || (DefaultEventNames = {}));
|
|
@@ -212,7 +212,7 @@ export interface TabsBlockProps extends Animatable {
|
|
|
212
212
|
items: TabsBlockItem[];
|
|
213
213
|
}
|
|
214
214
|
export interface CardLayoutBlockProps extends Childable, Animatable, LoadableChildren {
|
|
215
|
-
title
|
|
215
|
+
title?: TitleItemProps | string;
|
|
216
216
|
description?: string;
|
|
217
217
|
colSizes?: GridColumnSizesType;
|
|
218
218
|
}
|
|
@@ -169,7 +169,7 @@ export interface MediaComponentVideoProps extends AnalyticsEventsBase {
|
|
|
169
169
|
export interface MediaComponentYoutubeProps {
|
|
170
170
|
youtube: string;
|
|
171
171
|
previewImg?: string;
|
|
172
|
-
|
|
172
|
+
fullscreen?: boolean;
|
|
173
173
|
}
|
|
174
174
|
export interface MediaComponentImageProps {
|
|
175
175
|
image: ImageProps | ImageProps[] | ImageDeviceProps;
|