@doyourjob/gravity-ui-page-constructor 5.31.234 → 5.31.236
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/build/cjs/blocks/UnicornCards/Item/Item.css +9 -1
- package/build/cjs/blocks/UnicornCards/Item/Item.d.ts +1 -1
- package/build/cjs/blocks/UnicornCards/Item/Item.js +13 -5
- package/build/cjs/blocks/UnicornCards/schema.d.ts +3 -0
- package/build/cjs/blocks/UnicornCards/schema.js +1 -0
- package/build/cjs/components/BackgroundUnicorn/BackgroundUnicorn.js +1 -1
- package/build/cjs/components/UnicornScene/UnicornScene.d.ts +3 -1
- package/build/cjs/components/UnicornScene/UnicornScene.js +37 -3
- package/build/cjs/models/constructor-items/blocks.d.ts +1 -0
- package/build/esm/blocks/UnicornCards/Item/Item.css +9 -1
- package/build/esm/blocks/UnicornCards/Item/Item.d.ts +1 -1
- package/build/esm/blocks/UnicornCards/Item/Item.js +13 -5
- package/build/esm/blocks/UnicornCards/schema.d.ts +3 -0
- package/build/esm/blocks/UnicornCards/schema.js +1 -0
- package/build/esm/components/BackgroundUnicorn/BackgroundUnicorn.js +1 -1
- package/build/esm/components/UnicornScene/UnicornScene.d.ts +3 -1
- package/build/esm/components/UnicornScene/UnicornScene.js +37 -3
- package/build/esm/models/constructor-items/blocks.d.ts +1 -0
- package/package.json +1 -1
- package/schema/index.js +1 -1
- package/server/models/constructor-items/blocks.d.ts +1 -0
- package/widget/index.js +1 -1
|
@@ -4,7 +4,7 @@ unpredictable css rules order in build */
|
|
|
4
4
|
position: relative;
|
|
5
5
|
padding: 20px 24px;
|
|
6
6
|
border-radius: 20px;
|
|
7
|
-
min-height:
|
|
7
|
+
min-height: 360px;
|
|
8
8
|
}
|
|
9
9
|
.pc-unicorn-cards-item__title {
|
|
10
10
|
font-size: var(--g-text-display-2-font-size, var(--pc-text-display-2-font-size));
|
|
@@ -31,4 +31,12 @@ unpredictable css rules order in build */
|
|
|
31
31
|
}
|
|
32
32
|
.pc-unicorn-cards-item__background-item {
|
|
33
33
|
height: 100%;
|
|
34
|
+
}
|
|
35
|
+
.pc-unicorn-cards-item__background .pc-unicorn-cards-item__preview-image {
|
|
36
|
+
position: absolute;
|
|
37
|
+
top: 0;
|
|
38
|
+
left: 0;
|
|
39
|
+
width: 100%;
|
|
40
|
+
height: 100%;
|
|
41
|
+
object-fit: cover;
|
|
34
42
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { UnicornCardsItemProps } from '../../../models';
|
|
2
|
-
export declare const Item: ({ title, text, unicorn, unicornSdkUrl }: UnicornCardsItemProps) => JSX.Element;
|
|
2
|
+
export declare const Item: ({ title, text, unicorn, unicornSdkUrl, previewImage, }: UnicornCardsItemProps) => JSX.Element;
|
|
3
3
|
export default Item;
|
|
@@ -2,16 +2,24 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Item = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const react_1 = tslib_1.
|
|
5
|
+
const react_1 = tslib_1.__importStar(require("react"));
|
|
6
6
|
const components_1 = require("../../../components");
|
|
7
|
+
const constants_1 = require("../../../constants");
|
|
8
|
+
const useWindowBreakpoint_1 = tslib_1.__importDefault(require("../../../hooks/useWindowBreakpoint"));
|
|
7
9
|
const utils_1 = require("../../../utils");
|
|
8
10
|
const b = (0, utils_1.block)('unicorn-cards-item');
|
|
9
|
-
const Item = ({ title, text, unicorn, unicornSdkUrl }) => {
|
|
10
|
-
|
|
11
|
+
const Item = ({ title, text, unicorn, unicornSdkUrl, previewImage, }) => {
|
|
12
|
+
const [isHovered, setIsHovered] = (0, react_1.useState)(false);
|
|
13
|
+
const breakpoint = (0, useWindowBreakpoint_1.default)();
|
|
14
|
+
const isMobile = breakpoint < constants_1.BREAKPOINTS.md;
|
|
15
|
+
const showPreview = isMobile && previewImage;
|
|
16
|
+
const showUnicorn = !isMobile && unicorn;
|
|
17
|
+
return (react_1.default.createElement("div", { className: b(), onMouseEnter: () => setIsHovered(true), onMouseLeave: () => setIsHovered(false) },
|
|
11
18
|
title && react_1.default.createElement("div", { className: b('title') }, title),
|
|
12
19
|
text && react_1.default.createElement("div", { className: b('text') }, text),
|
|
13
|
-
|
|
14
|
-
react_1.default.createElement(
|
|
20
|
+
react_1.default.createElement("div", { className: b('background') },
|
|
21
|
+
showPreview && (react_1.default.createElement("img", { src: previewImage, className: b('preview-image'), alt: title })),
|
|
22
|
+
showUnicorn && (react_1.default.createElement(components_1.UnicornScene, { className: b('background-item'), jsonFilePath: unicorn, sdkUrl: unicornSdkUrl, width: "100%", play: isHovered })))));
|
|
15
23
|
};
|
|
16
24
|
exports.Item = Item;
|
|
17
25
|
exports.default = exports.Item;
|
|
@@ -11,6 +11,6 @@ const BackgroundUnicorn = (props) => {
|
|
|
11
11
|
return null;
|
|
12
12
|
}
|
|
13
13
|
return (react_1.default.createElement("div", { className: b() },
|
|
14
|
-
react_1.default.createElement(__1.UnicornScene, { className: b('item'), jsonFilePath: blockUnicorn, sdkUrl: blockUnicornSdkUrl, width: "100%" })));
|
|
14
|
+
react_1.default.createElement(__1.UnicornScene, { className: b('item'), jsonFilePath: blockUnicorn, sdkUrl: blockUnicornSdkUrl, width: "100%", play: true })));
|
|
15
15
|
};
|
|
16
16
|
exports.default = BackgroundUnicorn;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { UnicornSceneProps } from 'unicornstudio-react';
|
|
2
2
|
export declare const UNICORN_STUDIO_SDK_URL = "https://cdn.jsdelivr.net/gh/hiunicornstudio/unicornstudio.js@v2.2.0/dist/unicornStudio.umd.js";
|
|
3
|
-
declare const UnicornScene: (props: UnicornSceneProps
|
|
3
|
+
declare const UnicornScene: (props: UnicornSceneProps & {
|
|
4
|
+
play?: boolean;
|
|
5
|
+
}) => JSX.Element;
|
|
4
6
|
export type { UnicornSceneProps };
|
|
5
7
|
export default UnicornScene;
|
|
@@ -2,11 +2,45 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UNICORN_STUDIO_SDK_URL = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const react_1 = tslib_1.
|
|
5
|
+
const react_1 = tslib_1.__importStar(require("react"));
|
|
6
6
|
const unicornstudio_react_1 = tslib_1.__importDefault(require("unicornstudio-react"));
|
|
7
7
|
exports.UNICORN_STUDIO_SDK_URL = 'https://cdn.jsdelivr.net/gh/hiunicornstudio/unicornstudio.js@v2.2.0/dist/unicornStudio.umd.js';
|
|
8
8
|
const UnicornScene = (props) => {
|
|
9
|
-
const { sdkUrl = exports.UNICORN_STUDIO_SDK_URL } = props, rest = tslib_1.__rest(props, ["sdkUrl"]);
|
|
10
|
-
|
|
9
|
+
const { sdkUrl = exports.UNICORN_STUDIO_SDK_URL, play = true } = props, rest = tslib_1.__rest(props, ["sdkUrl", "play"]);
|
|
10
|
+
const [inView, setInView] = (0, react_1.useState)(false);
|
|
11
|
+
const containerRef = (0, react_1.useRef)(null);
|
|
12
|
+
const sceneRef = (0, react_1.useRef)(null);
|
|
13
|
+
const syncPausedState = (0, react_1.useCallback)(() => {
|
|
14
|
+
if (sceneRef.current) {
|
|
15
|
+
sceneRef.current.paused = !play || !inView;
|
|
16
|
+
}
|
|
17
|
+
}, [play, inView]);
|
|
18
|
+
(0, react_1.useEffect)(() => {
|
|
19
|
+
const observer = new IntersectionObserver(([entry]) => {
|
|
20
|
+
setInView(entry.isIntersecting);
|
|
21
|
+
}, { threshold: 0 });
|
|
22
|
+
const currentContainer = containerRef.current;
|
|
23
|
+
if (currentContainer) {
|
|
24
|
+
observer.observe(currentContainer);
|
|
25
|
+
}
|
|
26
|
+
return () => {
|
|
27
|
+
if (currentContainer) {
|
|
28
|
+
observer.unobserve(currentContainer);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}, []);
|
|
32
|
+
(0, react_1.useEffect)(() => {
|
|
33
|
+
syncPausedState();
|
|
34
|
+
const timer = setTimeout(syncPausedState, 100);
|
|
35
|
+
return () => clearTimeout(timer);
|
|
36
|
+
}, [syncPausedState]);
|
|
37
|
+
const handleLoad = () => {
|
|
38
|
+
syncPausedState();
|
|
39
|
+
if (rest.onLoad) {
|
|
40
|
+
rest.onLoad();
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
return (react_1.default.createElement("div", { ref: containerRef, style: { width: '100%', height: '100%' } },
|
|
44
|
+
react_1.default.createElement(unicornstudio_react_1.default, Object.assign({}, rest, { sdkUrl: sdkUrl, paused: !play || !inView, lazyLoad: false, sceneRef: sceneRef, onLoad: handleLoad }))));
|
|
11
45
|
};
|
|
12
46
|
exports.default = UnicornScene;
|
|
@@ -4,7 +4,7 @@ unpredictable css rules order in build */
|
|
|
4
4
|
position: relative;
|
|
5
5
|
padding: 20px 24px;
|
|
6
6
|
border-radius: 20px;
|
|
7
|
-
min-height:
|
|
7
|
+
min-height: 360px;
|
|
8
8
|
}
|
|
9
9
|
.pc-unicorn-cards-item__title {
|
|
10
10
|
font-size: var(--g-text-display-2-font-size, var(--pc-text-display-2-font-size));
|
|
@@ -31,4 +31,12 @@ unpredictable css rules order in build */
|
|
|
31
31
|
}
|
|
32
32
|
.pc-unicorn-cards-item__background-item {
|
|
33
33
|
height: 100%;
|
|
34
|
+
}
|
|
35
|
+
.pc-unicorn-cards-item__background .pc-unicorn-cards-item__preview-image {
|
|
36
|
+
position: absolute;
|
|
37
|
+
top: 0;
|
|
38
|
+
left: 0;
|
|
39
|
+
width: 100%;
|
|
40
|
+
height: 100%;
|
|
41
|
+
object-fit: cover;
|
|
34
42
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { UnicornCardsItemProps } from '../../../models';
|
|
2
2
|
import './Item.css';
|
|
3
|
-
export declare const Item: ({ title, text, unicorn, unicornSdkUrl }: UnicornCardsItemProps) => JSX.Element;
|
|
3
|
+
export declare const Item: ({ title, text, unicorn, unicornSdkUrl, previewImage, }: UnicornCardsItemProps) => JSX.Element;
|
|
4
4
|
export default Item;
|
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
import { UnicornScene } from '../../../components';
|
|
3
|
+
import { BREAKPOINTS } from '../../../constants';
|
|
4
|
+
import useWindowBreakpoint from '../../../hooks/useWindowBreakpoint';
|
|
3
5
|
import { block } from '../../../utils';
|
|
4
6
|
import './Item.css';
|
|
5
7
|
const b = block('unicorn-cards-item');
|
|
6
|
-
export const Item = ({ title, text, unicorn, unicornSdkUrl }) => {
|
|
7
|
-
|
|
8
|
+
export const Item = ({ title, text, unicorn, unicornSdkUrl, previewImage, }) => {
|
|
9
|
+
const [isHovered, setIsHovered] = useState(false);
|
|
10
|
+
const breakpoint = useWindowBreakpoint();
|
|
11
|
+
const isMobile = breakpoint < BREAKPOINTS.md;
|
|
12
|
+
const showPreview = isMobile && previewImage;
|
|
13
|
+
const showUnicorn = !isMobile && unicorn;
|
|
14
|
+
return (React.createElement("div", { className: b(), onMouseEnter: () => setIsHovered(true), onMouseLeave: () => setIsHovered(false) },
|
|
8
15
|
title && React.createElement("div", { className: b('title') }, title),
|
|
9
16
|
text && React.createElement("div", { className: b('text') }, text),
|
|
10
|
-
|
|
11
|
-
React.createElement(
|
|
17
|
+
React.createElement("div", { className: b('background') },
|
|
18
|
+
showPreview && (React.createElement("img", { src: previewImage, className: b('preview-image'), alt: title })),
|
|
19
|
+
showUnicorn && (React.createElement(UnicornScene, { className: b('background-item'), jsonFilePath: unicorn, sdkUrl: unicornSdkUrl, width: "100%", play: isHovered })))));
|
|
12
20
|
};
|
|
13
21
|
export default Item;
|
|
@@ -9,6 +9,6 @@ const BackgroundUnicorn = (props) => {
|
|
|
9
9
|
return null;
|
|
10
10
|
}
|
|
11
11
|
return (React.createElement("div", { className: b() },
|
|
12
|
-
React.createElement(UnicornScene, { className: b('item'), jsonFilePath: blockUnicorn, sdkUrl: blockUnicornSdkUrl, width: "100%" })));
|
|
12
|
+
React.createElement(UnicornScene, { className: b('item'), jsonFilePath: blockUnicorn, sdkUrl: blockUnicornSdkUrl, width: "100%", play: true })));
|
|
13
13
|
};
|
|
14
14
|
export default BackgroundUnicorn;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { UnicornSceneProps } from 'unicornstudio-react';
|
|
2
2
|
export declare const UNICORN_STUDIO_SDK_URL = "https://cdn.jsdelivr.net/gh/hiunicornstudio/unicornstudio.js@v2.2.0/dist/unicornStudio.umd.js";
|
|
3
|
-
declare const UnicornScene: (props: UnicornSceneProps
|
|
3
|
+
declare const UnicornScene: (props: UnicornSceneProps & {
|
|
4
|
+
play?: boolean;
|
|
5
|
+
}) => JSX.Element;
|
|
4
6
|
export type { UnicornSceneProps };
|
|
5
7
|
export default UnicornScene;
|
|
@@ -1,9 +1,43 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
|
-
import React from 'react';
|
|
2
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
3
|
import UnicornSceneLib from 'unicornstudio-react';
|
|
4
4
|
export const UNICORN_STUDIO_SDK_URL = 'https://cdn.jsdelivr.net/gh/hiunicornstudio/unicornstudio.js@v2.2.0/dist/unicornStudio.umd.js';
|
|
5
5
|
const UnicornScene = (props) => {
|
|
6
|
-
const { sdkUrl = UNICORN_STUDIO_SDK_URL } = props, rest = __rest(props, ["sdkUrl"]);
|
|
7
|
-
|
|
6
|
+
const { sdkUrl = UNICORN_STUDIO_SDK_URL, play = true } = props, rest = __rest(props, ["sdkUrl", "play"]);
|
|
7
|
+
const [inView, setInView] = useState(false);
|
|
8
|
+
const containerRef = useRef(null);
|
|
9
|
+
const sceneRef = useRef(null);
|
|
10
|
+
const syncPausedState = useCallback(() => {
|
|
11
|
+
if (sceneRef.current) {
|
|
12
|
+
sceneRef.current.paused = !play || !inView;
|
|
13
|
+
}
|
|
14
|
+
}, [play, inView]);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
const observer = new IntersectionObserver(([entry]) => {
|
|
17
|
+
setInView(entry.isIntersecting);
|
|
18
|
+
}, { threshold: 0 });
|
|
19
|
+
const currentContainer = containerRef.current;
|
|
20
|
+
if (currentContainer) {
|
|
21
|
+
observer.observe(currentContainer);
|
|
22
|
+
}
|
|
23
|
+
return () => {
|
|
24
|
+
if (currentContainer) {
|
|
25
|
+
observer.unobserve(currentContainer);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}, []);
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
syncPausedState();
|
|
31
|
+
const timer = setTimeout(syncPausedState, 100);
|
|
32
|
+
return () => clearTimeout(timer);
|
|
33
|
+
}, [syncPausedState]);
|
|
34
|
+
const handleLoad = () => {
|
|
35
|
+
syncPausedState();
|
|
36
|
+
if (rest.onLoad) {
|
|
37
|
+
rest.onLoad();
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
return (React.createElement("div", { ref: containerRef, style: { width: '100%', height: '100%' } },
|
|
41
|
+
React.createElement(UnicornSceneLib, Object.assign({}, rest, { sdkUrl: sdkUrl, paused: !play || !inView, lazyLoad: false, sceneRef: sceneRef, onLoad: handleLoad }))));
|
|
8
42
|
};
|
|
9
43
|
export default UnicornScene;
|