@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.
@@ -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: 410px;
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.__importDefault(require("react"));
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
- return (react_1.default.createElement("div", { className: b() },
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
- unicorn && (react_1.default.createElement("div", { className: b('background') },
14
- react_1.default.createElement(components_1.UnicornScene, { className: b('background-item'), jsonFilePath: unicorn, sdkUrl: unicornSdkUrl, width: "100%" })))));
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;
@@ -181,6 +181,9 @@ export declare const UnicornCardsBlock: {
181
181
  unicornSdkUrl: {
182
182
  type: string;
183
183
  };
184
+ previewImage: {
185
+ type: string;
186
+ };
184
187
  };
185
188
  };
186
189
  };
@@ -26,6 +26,7 @@ exports.UnicornCardsBlock = {
26
26
  text: { type: 'string' },
27
27
  unicorn: { type: 'string' },
28
28
  unicornSdkUrl: { type: 'string' },
29
+ previewImage: { type: 'string' },
29
30
  },
30
31
  },
31
32
  } }),
@@ -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) => JSX.Element;
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.__importDefault(require("react"));
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
- return react_1.default.createElement(unicornstudio_react_1.default, Object.assign({ sdkUrl: sdkUrl }, rest));
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;
@@ -312,6 +312,7 @@ export type UnicornCardsItemProps = {
312
312
  text: string;
313
313
  unicorn?: string;
314
314
  unicornSdkUrl?: string;
315
+ previewImage?: string;
315
316
  };
316
317
  export interface UnicornCardsBlockProps extends Animatable {
317
318
  title?: TitleItemBaseProps | string;
@@ -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: 410px;
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
- return (React.createElement("div", { className: b() },
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
- unicorn && (React.createElement("div", { className: b('background') },
11
- React.createElement(UnicornScene, { className: b('background-item'), jsonFilePath: unicorn, sdkUrl: unicornSdkUrl, width: "100%" })))));
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;
@@ -181,6 +181,9 @@ export declare const UnicornCardsBlock: {
181
181
  unicornSdkUrl: {
182
182
  type: string;
183
183
  };
184
+ previewImage: {
185
+ type: string;
186
+ };
184
187
  };
185
188
  };
186
189
  };
@@ -23,6 +23,7 @@ export const UnicornCardsBlock = {
23
23
  text: { type: 'string' },
24
24
  unicorn: { type: 'string' },
25
25
  unicornSdkUrl: { type: 'string' },
26
+ previewImage: { type: 'string' },
26
27
  },
27
28
  },
28
29
  } }),
@@ -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) => JSX.Element;
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
- return React.createElement(UnicornSceneLib, Object.assign({ sdkUrl: sdkUrl }, rest));
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;
@@ -312,6 +312,7 @@ export type UnicornCardsItemProps = {
312
312
  text: string;
313
313
  unicorn?: string;
314
314
  unicornSdkUrl?: string;
315
+ previewImage?: string;
315
316
  };
316
317
  export interface UnicornCardsBlockProps extends Animatable {
317
318
  title?: TitleItemBaseProps | string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doyourjob/gravity-ui-page-constructor",
3
- "version": "5.31.234",
3
+ "version": "5.31.236",
4
4
  "description": "Gravity UI Page Constructor",
5
5
  "license": "MIT",
6
6
  "repository": {