@cntrl-site/sdk-nextjs 0.29.6 → 0.30.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/lib/common/useKeyframeValue.js +2 -2
- package/lib/components/ArticleWrapper.js +1 -25
- package/lib/components/Item.js +30 -23
- package/lib/components/Section.js +6 -12
- package/lib/components/items/CodeEmbedItem.js +67 -0
- package/lib/components/items/CustomItem.js +8 -2
- package/lib/components/items/GroupItem.js +6 -3
- package/lib/components/items/ImageItem.js +18 -12
- package/lib/components/items/RectangleItem.js +15 -12
- package/lib/components/items/RichTextItem.js +22 -22
- package/lib/components/items/VideoItem.js +17 -26
- package/lib/components/items/VimeoEmbed.js +7 -2
- package/lib/components/items/YoutubeEmbed.js +9 -4
- package/lib/components/items/useCodeEmbedItem.js +24 -0
- package/lib/components/items/useEmbedVideoItem.js +4 -3
- package/lib/components/items/useFileItem.js +11 -10
- package/lib/components/items/useGroupItem.js +4 -3
- package/lib/components/items/useRectangleItem.js +7 -6
- package/lib/components/items/useRichTextItemValues.js +6 -6
- package/lib/components/items/useStickyItemTop.js +5 -3
- package/lib/components/useItemAngle.js +2 -1
- package/lib/components/useItemDimensions.js +3 -10
- package/lib/components/useItemPosition.js +8 -8
- package/lib/components/useItemScale.js +2 -3
- package/lib/utils/ScaleAnchorMap.js +9 -9
- package/lib/utils/effects/useImageFx.js +2 -2
- package/package.json +2 -2
- package/src/common/useKeyframeValue.ts +3 -2
- package/src/components/ArticleWrapper.tsx +0 -21
- package/src/components/Item.tsx +43 -29
- package/src/components/Section.tsx +5 -12
- package/src/components/items/CodeEmbedItem.tsx +73 -0
- package/src/components/items/CustomItem.tsx +15 -3
- package/src/components/items/GroupItem.tsx +6 -3
- package/src/components/items/ImageItem.tsx +19 -13
- package/src/components/items/RectangleItem.tsx +17 -13
- package/src/components/items/RichTextItem.tsx +22 -23
- package/src/components/items/VideoItem.tsx +33 -45
- package/src/components/items/VimeoEmbed.tsx +7 -2
- package/src/components/items/YoutubeEmbed.tsx +11 -4
- package/src/components/items/useCodeEmbedItem.ts +36 -0
- package/src/components/items/useEmbedVideoItem.ts +4 -1
- package/src/components/items/useFileItem.ts +11 -7
- package/src/components/items/useGroupItem.ts +4 -3
- package/src/components/items/useRectangleItem.ts +7 -1
- package/src/components/items/useRichTextItemValues.ts +6 -9
- package/src/components/items/useStickyItemTop.ts +7 -5
- package/src/components/useItemAngle.ts +5 -4
- package/src/components/useItemDimensions.ts +6 -14
- package/src/components/useItemPosition.ts +10 -9
- package/src/components/useItemScale.ts +6 -6
- package/src/utils/ScaleAnchorMap.ts +1 -1
- package/src/utils/effects/useImageFx.ts +2 -2
- package/.idea/inspectionProfiles/Project_Default.xml +0 -15
- package/lib/components/useSectionColor.js +0 -19
|
@@ -23,38 +23,23 @@ const VideoItem = ({ item, sectionId, onResize }) => {
|
|
|
23
23
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
24
24
|
const { radius, strokeWidth, strokeColor, opacity, blur } = (0, useFileItem_1.useFileItem)(item, sectionId);
|
|
25
25
|
const angle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
|
|
26
|
-
const borderColor = (0, react_1.useMemo)(() => color_1.CntrlColor.parse(strokeColor), [strokeColor]);
|
|
26
|
+
const borderColor = (0, react_1.useMemo)(() => strokeColor ? color_1.CntrlColor.parse(strokeColor) : undefined, [strokeColor]);
|
|
27
27
|
const [ref, setRef] = (0, react_1.useState)(null);
|
|
28
28
|
const videoRef = (0, react_1.useRef)(null);
|
|
29
29
|
const layoutId = (0, useLayoutContext_1.useLayoutContext)();
|
|
30
|
-
const scrollPlayback = item.layoutParams[layoutId].scrollPlayback;
|
|
30
|
+
const scrollPlayback = layoutId ? item.layoutParams[layoutId].scrollPlayback : null;
|
|
31
|
+
const layoutValues = [item.area, item.layoutParams, item.state.hover];
|
|
31
32
|
const hasScrollPlayback = scrollPlayback !== null;
|
|
32
33
|
(0, useRegisterResize_1.useRegisterResize)(ref, onResize);
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
const inlineStyles = Object.assign(Object.assign(Object.assign({}, (radius !== undefined ? { borderRadius: `${radius * 100}vw` } : {})), (strokeWidth !== undefined ? { borderWidth: `${strokeWidth * 100}vw` } : {})), (borderColor ? { borderColor: `${borderColor.toCss()}` } : {}));
|
|
35
|
+
return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, { url: (_a = item.link) === null || _a === void 0 ? void 0 : _a.url, target: (_b = item.link) === null || _b === void 0 ? void 0 : _b.target, children: [(0, jsx_runtime_1.jsx)("div", { className: `video-wrapper-${item.id}`, ref: setRef, style: {
|
|
36
|
+
opacity,
|
|
35
37
|
transform: `rotate(${angle}deg)`,
|
|
36
38
|
filter: `blur(${blur * 100}vw)`,
|
|
37
|
-
|
|
38
|
-
}, children: (0, jsx_runtime_1.jsx)(ScrollPlaybackVideo_1.ScrollPlaybackVideo, { sectionId: sectionId, src: item.commonParams.url, playbackParams: scrollPlayback, style: {
|
|
39
|
-
borderRadius: `${radius * 100}vw`,
|
|
40
|
-
borderWidth: `${strokeWidth * 100}vw`,
|
|
41
|
-
borderColor: `${borderColor.toCss()}`
|
|
42
|
-
}, className: `video video-playback-wrapper video-${item.id}` }) })) : ((0, jsx_runtime_1.jsx)("div", { className: `video-wrapper-${item.id}`, ref: setRef, style: {
|
|
43
|
-
opacity: `${opacity}`,
|
|
44
|
-
transform: `rotate(${angle}deg)`,
|
|
45
|
-
filter: `blur(${blur * 100}vw)`
|
|
46
|
-
}, children: (0, jsx_runtime_1.jsx)("video", { ref: videoRef, autoPlay: true, muted: true, loop: true, playsInline: true, className: `video video-${item.id}`, style: {
|
|
47
|
-
borderRadius: `${radius * 100}vw`,
|
|
48
|
-
borderWidth: `${strokeWidth * 100}vw`,
|
|
49
|
-
borderColor: `${borderColor.toCss()}`
|
|
50
|
-
}, children: (0, jsx_runtime_1.jsx)("source", { src: item.commonParams.url }) }) })), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
51
|
-
@supports not (color: oklch(42% 0.3 90 / 1)) {
|
|
52
|
-
.video-${item.id} {
|
|
53
|
-
border-color: ${borderColor.fmt('rgba')};
|
|
54
|
-
}
|
|
55
|
-
}
|
|
39
|
+
}, children: hasScrollPlayback ? ((0, jsx_runtime_1.jsx)(ScrollPlaybackVideo_1.ScrollPlaybackVideo, { sectionId: sectionId, src: item.commonParams.url, playbackParams: scrollPlayback, style: inlineStyles, className: `video video-playback-wrapper video-${item.id}` })) : ((0, jsx_runtime_1.jsx)("video", { ref: videoRef, autoPlay: true, muted: true, loop: true, playsInline: true, className: `video video-${item.id}`, style: inlineStyles, children: (0, jsx_runtime_1.jsx)("source", { src: item.commonParams.url }) })) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
56
40
|
.video-wrapper-${item.id} {
|
|
57
41
|
position: absolute;
|
|
42
|
+
overflow: hidden;
|
|
58
43
|
width: 100%;
|
|
59
44
|
height: 100%;
|
|
60
45
|
box-sizing: border-box;
|
|
@@ -76,19 +61,25 @@ const VideoItem = ({ item, sectionId, onResize }) => {
|
|
|
76
61
|
display: flex;
|
|
77
62
|
justify-content: center;
|
|
78
63
|
}
|
|
79
|
-
${(0, sdk_1.getLayoutStyles)(layouts,
|
|
64
|
+
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams, hoverParams]) => {
|
|
80
65
|
return (`
|
|
81
66
|
.video-wrapper-${item.id} {
|
|
67
|
+
opacity: ${layoutParams.opacity};
|
|
68
|
+
transform: rotate(${area.angle}deg);
|
|
69
|
+
filter: ${layoutParams.blur !== 0 ? `blur(${layoutParams.blur * 100}vw)` : 'unset'};
|
|
82
70
|
transition: ${(0, HoverStyles_1.getTransitions)(['angle', 'opacity', 'blur'], hoverParams)};
|
|
83
71
|
}
|
|
84
72
|
.video-wrapper-${item.id}:hover {
|
|
85
|
-
${(0, HoverStyles_1.getHoverStyles)(['angle', 'opacity', 'blur'], hoverParams)}
|
|
73
|
+
${(0, HoverStyles_1.getHoverStyles)(['angle', 'opacity', 'blur'], hoverParams)};
|
|
86
74
|
}
|
|
87
75
|
.video-${item.id} {
|
|
76
|
+
border-color: ${color_1.CntrlColor.parse(layoutParams.strokeColor).fmt('rgba')};
|
|
77
|
+
border-radius: ${layoutParams.radius * 100}vw;
|
|
78
|
+
border-width: ${layoutParams.strokeWidth * 100}vw;
|
|
88
79
|
transition: ${(0, HoverStyles_1.getTransitions)(['strokeWidth', 'radius', 'strokeColor'], hoverParams)};
|
|
89
80
|
}
|
|
90
81
|
.video-wrapper-${item.id}:hover .video {
|
|
91
|
-
${(0, HoverStyles_1.getHoverStyles)(['strokeWidth', 'radius', 'strokeColor'], hoverParams)}
|
|
82
|
+
${(0, HoverStyles_1.getHoverStyles)(['strokeWidth', 'radius', 'strokeColor'], hoverParams)};
|
|
92
83
|
}
|
|
93
84
|
`);
|
|
94
85
|
})}
|
|
@@ -25,6 +25,7 @@ const VimeoEmbedItem = ({ item, sectionId, onResize }) => {
|
|
|
25
25
|
const angle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
|
|
26
26
|
const { play, controls, loop, muted, pictureInPicture, url } = item.commonParams;
|
|
27
27
|
const [ref, setRef] = (0, react_1.useState)(null);
|
|
28
|
+
const layoutValues = [item.area, item.layoutParams, item.state.hover];
|
|
28
29
|
(0, useRegisterResize_1.useRegisterResize)(ref, onResize);
|
|
29
30
|
const getValidVimeoUrl = (url) => {
|
|
30
31
|
const validURL = new URL(url);
|
|
@@ -67,19 +68,23 @@ const VimeoEmbedItem = ({ item, sectionId, onResize }) => {
|
|
|
67
68
|
border: none;
|
|
68
69
|
overflow: hidden;
|
|
69
70
|
}
|
|
70
|
-
${(0, sdk_1.getLayoutStyles)(layouts,
|
|
71
|
+
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams, hoverParams]) => {
|
|
71
72
|
return (`
|
|
72
73
|
.embed-video-wrapper-${item.id} {
|
|
74
|
+
opacity: ${layoutParams.opacity};
|
|
75
|
+
transform: rotate(${area.angle}deg);
|
|
76
|
+
filter: ${layoutParams.blur !== 0 ? `blur(${layoutParams.blur * 100}vw)` : 'unset'};
|
|
73
77
|
transition: ${(0, HoverStyles_1.getTransitions)(['angle', 'blur', 'opacity'], hoverParams)};
|
|
74
78
|
}
|
|
75
79
|
.embed-video-wrapper-${item.id}:hover {
|
|
76
80
|
${(0, HoverStyles_1.getHoverStyles)(['angle', 'blur', 'opacity'], hoverParams)}
|
|
77
81
|
}
|
|
78
82
|
.embed-video-wrapper-${item.id} .embedVideo {
|
|
83
|
+
border-radius: ${layoutParams.radius * 100}vw;
|
|
79
84
|
transition: ${(0, HoverStyles_1.getTransitions)(['radius'], hoverParams)};
|
|
80
85
|
}
|
|
81
86
|
.embed-video-wrapper-${item.id}:hover .embedVideo {
|
|
82
|
-
${(0, HoverStyles_1.getHoverStyles)(['radius'], hoverParams)}
|
|
87
|
+
${(0, HoverStyles_1.getHoverStyles)(['radius'], hoverParams)};
|
|
83
88
|
}
|
|
84
89
|
`);
|
|
85
90
|
})}
|
|
@@ -26,6 +26,7 @@ const YoutubeEmbedItem = ({ item, sectionId, onResize }) => {
|
|
|
26
26
|
const YT = (0, useYouTubeIframeApi_1.useYouTubeIframeApi)();
|
|
27
27
|
const [div, setDiv] = (0, react_1.useState)(null);
|
|
28
28
|
const [player, setPlayer] = (0, react_1.useState)(undefined);
|
|
29
|
+
const layoutValues = [item.area, item.layoutParams, item.state.hover];
|
|
29
30
|
(0, useRegisterResize_1.useRegisterResize)(div, onResize);
|
|
30
31
|
(0, react_1.useEffect)(() => {
|
|
31
32
|
const newUrl = new URL(url);
|
|
@@ -68,7 +69,7 @@ const YoutubeEmbedItem = ({ item, sectionId, onResize }) => {
|
|
|
68
69
|
opacity: `${opacity}`,
|
|
69
70
|
transform: `rotate(${angle}deg)`,
|
|
70
71
|
filter: `blur(${blur * 100}vw)`
|
|
71
|
-
}, children: (0, jsx_runtime_1.jsx)("div", { className: `embed-${item.id}`, ref: setDiv, style: { borderRadius: `${radius * 100}vw` } }) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
72
|
+
}, children: (0, jsx_runtime_1.jsx)("div", { className: `embed-${item.id}`, ref: setDiv, style: Object.assign({}, (radius !== undefined ? { borderRadius: `${radius * 100}vw` } : {})) }) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
72
73
|
.embed-youtube-video-wrapper-${item.id},
|
|
73
74
|
.embed-${item.id} {
|
|
74
75
|
position: absolute;
|
|
@@ -84,19 +85,23 @@ const YoutubeEmbedItem = ({ item, sectionId, onResize }) => {
|
|
|
84
85
|
z-index: 1;
|
|
85
86
|
border: none;
|
|
86
87
|
}
|
|
87
|
-
${(0, sdk_1.getLayoutStyles)(layouts,
|
|
88
|
+
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams, hoverParams]) => {
|
|
88
89
|
return (`
|
|
89
90
|
.embed-youtube-video-wrapper-${item.id} {
|
|
91
|
+
opacity: ${layoutParams.opacity};
|
|
92
|
+
transform: rotate(${area.angle}deg);
|
|
93
|
+
filter: ${layoutParams.blur !== 0 ? `blur(${layoutParams.blur * 100}vw)` : 'unset'};
|
|
90
94
|
transition: ${(0, HoverStyles_1.getTransitions)(['angle', 'blur', 'opacity'], hoverParams)};
|
|
91
95
|
}
|
|
92
96
|
.embed-youtube-video-wrapper-${item.id} .embed-${item.id} {
|
|
97
|
+
border-radius: ${layoutParams.radius * 100}vw;
|
|
93
98
|
transition: ${(0, HoverStyles_1.getTransitions)(['radius'], hoverParams)};
|
|
94
99
|
}
|
|
95
100
|
.embed-youtube-video-wrapper-${item.id}:hover {
|
|
96
|
-
${(0, HoverStyles_1.getHoverStyles)(['angle', 'blur', 'opacity'], hoverParams)}
|
|
101
|
+
${(0, HoverStyles_1.getHoverStyles)(['angle', 'blur', 'opacity'], hoverParams)};
|
|
97
102
|
}
|
|
98
103
|
.embed-youtube-video-wrapper-${item.id}:hover .embed-${item.id} {
|
|
99
|
-
${(0, HoverStyles_1.getHoverStyles)(['radius'], hoverParams)}
|
|
104
|
+
${(0, HoverStyles_1.getHoverStyles)(['radius'], hoverParams)};
|
|
100
105
|
}
|
|
101
106
|
`);
|
|
102
107
|
})}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useCodeEmbedItem = void 0;
|
|
4
|
+
const sdk_1 = require("@cntrl-site/sdk");
|
|
5
|
+
const useLayoutContext_1 = require("../useLayoutContext");
|
|
6
|
+
const useKeyframeValue_1 = require("../../common/useKeyframeValue");
|
|
7
|
+
const useCodeEmbedItem = (item, sectionId) => {
|
|
8
|
+
const layoutId = (0, useLayoutContext_1.useLayoutContext)();
|
|
9
|
+
const blur = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.Blur, (item, layoutId) => {
|
|
10
|
+
if (!layoutId)
|
|
11
|
+
return 0;
|
|
12
|
+
const layoutParams = item.layoutParams[layoutId];
|
|
13
|
+
return 'blur' in layoutParams ? layoutParams.blur : 0;
|
|
14
|
+
}, (animator, scroll, value) => animator.getBlur({ blur: value }, scroll).blur, sectionId, [layoutId]);
|
|
15
|
+
const opacity = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.Opacity, (item, layoutId) => {
|
|
16
|
+
if (!layoutId)
|
|
17
|
+
return 1;
|
|
18
|
+
const layoutParams = item.layoutParams[layoutId];
|
|
19
|
+
return 'opacity' in layoutParams ? layoutParams.opacity : 1;
|
|
20
|
+
}, (animator, scroll, value) => animator.getOpacity({ opacity: value }, scroll).opacity, sectionId, [layoutId]);
|
|
21
|
+
const anchor = layoutId && 'areaAnchor' in item.layoutParams[layoutId] ? item.layoutParams[layoutId].areaAnchor : sdk_1.AreaAnchor.TopLeft;
|
|
22
|
+
return { anchor, blur, opacity };
|
|
23
|
+
};
|
|
24
|
+
exports.useCodeEmbedItem = useCodeEmbedItem;
|
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useEmbedVideoItem = void 0;
|
|
4
|
+
const sdk_1 = require("@cntrl-site/sdk");
|
|
4
5
|
const useKeyframeValue_1 = require("../../common/useKeyframeValue");
|
|
5
6
|
const useLayoutContext_1 = require("../useLayoutContext");
|
|
6
7
|
const useEmbedVideoItem = (item, sectionId) => {
|
|
7
8
|
const layoutId = (0, useLayoutContext_1.useLayoutContext)();
|
|
8
|
-
const radius = (0, useKeyframeValue_1.useKeyframeValue)(item, (item, layoutId) => {
|
|
9
|
+
const radius = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.BorderRadius, (item, layoutId) => {
|
|
9
10
|
if (!layoutId)
|
|
10
11
|
return 0;
|
|
11
12
|
const layoutParams = item.layoutParams[layoutId];
|
|
12
13
|
return 'radius' in layoutParams ? layoutParams.radius : 0;
|
|
13
14
|
}, (animator, scroll, value) => animator.getRadius({ radius: value }, scroll).radius, sectionId, [layoutId]);
|
|
14
|
-
const blur = (0, useKeyframeValue_1.useKeyframeValue)(item, (item, layoutId) => {
|
|
15
|
+
const blur = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.Blur, (item, layoutId) => {
|
|
15
16
|
if (!layoutId)
|
|
16
17
|
return 0;
|
|
17
18
|
const layoutParams = item.layoutParams[layoutId];
|
|
18
19
|
return 'blur' in layoutParams ? layoutParams.blur : 0;
|
|
19
20
|
}, (animator, scroll, value) => animator.getBlur({ blur: value }, scroll).blur, sectionId, [layoutId]);
|
|
20
|
-
const opacity = (0, useKeyframeValue_1.useKeyframeValue)(item, (item, layoutId) => {
|
|
21
|
+
const opacity = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.Opacity, (item, layoutId) => {
|
|
21
22
|
if (!layoutId)
|
|
22
23
|
return 1;
|
|
23
24
|
const layoutParams = item.layoutParams[layoutId];
|
|
@@ -1,36 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useFileItem = void 0;
|
|
4
|
+
const sdk_1 = require("@cntrl-site/sdk");
|
|
4
5
|
const useKeyframeValue_1 = require("../../common/useKeyframeValue");
|
|
5
6
|
const useLayoutContext_1 = require("../useLayoutContext");
|
|
6
|
-
const
|
|
7
|
+
const DEFAULT_COLOR = 'rgba(0, 0, 0, 1)';
|
|
7
8
|
const useFileItem = (item, sectionId) => {
|
|
8
9
|
const layoutId = (0, useLayoutContext_1.useLayoutContext)();
|
|
9
|
-
const radius = (0, useKeyframeValue_1.useKeyframeValue)(item, (item, layoutId) => {
|
|
10
|
+
const radius = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.BorderRadius, (item, layoutId) => {
|
|
10
11
|
if (!layoutId)
|
|
11
12
|
return 0;
|
|
12
13
|
const layoutParams = item.layoutParams[layoutId];
|
|
13
14
|
return 'radius' in layoutParams ? layoutParams.radius : 0;
|
|
14
15
|
}, (animator, scroll, value) => animator.getRadius({ radius: value }, scroll).radius, sectionId, [layoutId]);
|
|
15
|
-
const strokeWidth = (0, useKeyframeValue_1.useKeyframeValue)(item, (item, layoutId) => {
|
|
16
|
+
const strokeWidth = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.BorderWidth, (item, layoutId) => {
|
|
16
17
|
if (!layoutId)
|
|
17
18
|
return 0;
|
|
18
19
|
const layoutParams = item.layoutParams[layoutId];
|
|
19
20
|
return 'strokeWidth' in layoutParams ? layoutParams.strokeWidth : 0;
|
|
20
21
|
}, (animator, scroll, value) => animator.getBorderWidth({ borderWidth: value }, scroll).borderWidth, sectionId, [layoutId]);
|
|
21
|
-
const opacity = (0, useKeyframeValue_1.useKeyframeValue)(item, (item, layoutId) => {
|
|
22
|
+
const opacity = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.Opacity, (item, layoutId) => {
|
|
22
23
|
if (!layoutId)
|
|
23
|
-
return
|
|
24
|
+
return 1;
|
|
24
25
|
const layoutParams = item.layoutParams[layoutId];
|
|
25
|
-
return 'opacity' in layoutParams ? layoutParams.opacity :
|
|
26
|
+
return 'opacity' in layoutParams ? layoutParams.opacity : 1;
|
|
26
27
|
}, (animator, scroll, value) => animator.getOpacity({ opacity: value }, scroll).opacity, sectionId, [layoutId]);
|
|
27
|
-
const strokeColor = (0, useKeyframeValue_1.useKeyframeValue)(item, (item, layoutId) => {
|
|
28
|
+
const strokeColor = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.BorderColor, (item, layoutId) => {
|
|
28
29
|
if (!layoutId)
|
|
29
|
-
return
|
|
30
|
+
return DEFAULT_COLOR;
|
|
30
31
|
const layoutParams = item.layoutParams[layoutId];
|
|
31
|
-
return 'strokeColor' in layoutParams ? layoutParams.strokeColor :
|
|
32
|
+
return 'strokeColor' in layoutParams ? layoutParams.strokeColor : DEFAULT_COLOR;
|
|
32
33
|
}, (animator, scroll, value) => animator.getBorderColor({ color: value }, scroll).color, sectionId);
|
|
33
|
-
const blur = (0, useKeyframeValue_1.useKeyframeValue)(item, (item, layoutId) => {
|
|
34
|
+
const blur = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.Blur, (item, layoutId) => {
|
|
34
35
|
if (!layoutId)
|
|
35
36
|
return 0;
|
|
36
37
|
const layoutParams = item.layoutParams[layoutId];
|
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useGroupItem = void 0;
|
|
4
4
|
const useKeyframeValue_1 = require("../../common/useKeyframeValue");
|
|
5
|
+
const sdk_1 = require("@cntrl-site/sdk");
|
|
5
6
|
const useLayoutContext_1 = require("../useLayoutContext");
|
|
6
7
|
function useGroupItem(item, sectionId) {
|
|
7
8
|
const layoutId = (0, useLayoutContext_1.useLayoutContext)();
|
|
8
|
-
const opacity = (0, useKeyframeValue_1.useKeyframeValue)(item, (item, layoutId) => {
|
|
9
|
+
const opacity = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.Opacity, (item, layoutId) => {
|
|
9
10
|
if (!layoutId)
|
|
10
|
-
return
|
|
11
|
+
return 1;
|
|
11
12
|
const layoutParams = item.layoutParams[layoutId];
|
|
12
|
-
return 'opacity' in layoutParams ? layoutParams.opacity :
|
|
13
|
+
return 'opacity' in layoutParams ? layoutParams.opacity : 1;
|
|
13
14
|
}, (animator, scroll, value) => animator.getOpacity({ opacity: value }, scroll).opacity, sectionId, [layoutId]);
|
|
14
15
|
return { opacity };
|
|
15
16
|
}
|
|
@@ -1,42 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useRectangleItem = void 0;
|
|
4
|
+
const sdk_1 = require("@cntrl-site/sdk");
|
|
4
5
|
const useKeyframeValue_1 = require("../../common/useKeyframeValue");
|
|
5
6
|
const useLayoutContext_1 = require("../useLayoutContext");
|
|
6
7
|
const defaultColor = 'rgba(0, 0, 0, 1)';
|
|
7
8
|
const useRectangleItem = (item, sectionId) => {
|
|
8
9
|
const layoutId = (0, useLayoutContext_1.useLayoutContext)();
|
|
9
|
-
const radius = (0, useKeyframeValue_1.useKeyframeValue)(item, (item, layoutId) => {
|
|
10
|
+
const radius = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.BorderRadius, (item, layoutId) => {
|
|
10
11
|
if (!layoutId)
|
|
11
12
|
return 0;
|
|
12
13
|
const layoutParams = item.layoutParams[layoutId];
|
|
13
14
|
return 'radius' in layoutParams ? layoutParams.radius : 0;
|
|
14
15
|
}, (animator, scroll, value) => animator.getRadius({ radius: value }, scroll).radius, sectionId, [layoutId]);
|
|
15
|
-
const strokeWidth = (0, useKeyframeValue_1.useKeyframeValue)(item, (item, layoutId) => {
|
|
16
|
+
const strokeWidth = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.BorderWidth, (item, layoutId) => {
|
|
16
17
|
if (!layoutId)
|
|
17
18
|
return 0;
|
|
18
19
|
const layoutParams = item.layoutParams[layoutId];
|
|
19
20
|
return 'strokeWidth' in layoutParams ? layoutParams.strokeWidth : 0;
|
|
20
21
|
}, (animator, scroll, value) => animator.getBorderWidth({ borderWidth: value }, scroll).borderWidth, sectionId, [layoutId]);
|
|
21
|
-
const fillColor = (0, useKeyframeValue_1.useKeyframeValue)(item, (item, layoutId) => {
|
|
22
|
+
const fillColor = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.Color, (item, layoutId) => {
|
|
22
23
|
if (!layoutId)
|
|
23
24
|
return defaultColor;
|
|
24
25
|
const layoutParams = item.layoutParams[layoutId];
|
|
25
26
|
return 'fillColor' in layoutParams ? layoutParams.fillColor : defaultColor;
|
|
26
27
|
}, (animator, scroll, value) => animator.getColor({ color: value }, scroll).color, sectionId, [layoutId]);
|
|
27
|
-
const strokeColor = (0, useKeyframeValue_1.useKeyframeValue)(item, (item, layoutId) => {
|
|
28
|
+
const strokeColor = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.BorderColor, (item, layoutId) => {
|
|
28
29
|
if (!layoutId)
|
|
29
30
|
return defaultColor;
|
|
30
31
|
const layoutParams = item.layoutParams[layoutId];
|
|
31
32
|
return 'strokeColor' in layoutParams ? layoutParams.strokeColor : defaultColor;
|
|
32
33
|
}, (animator, scroll, value) => animator.getBorderColor({ color: value }, scroll).color, sectionId, [layoutId]);
|
|
33
|
-
const blur = (0, useKeyframeValue_1.useKeyframeValue)(item, (item, layoutId) => {
|
|
34
|
+
const blur = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.Blur, (item, layoutId) => {
|
|
34
35
|
if (!layoutId)
|
|
35
36
|
return 0;
|
|
36
37
|
const layoutParams = item.layoutParams[layoutId];
|
|
37
38
|
return 'blur' in layoutParams ? layoutParams.blur : 0;
|
|
38
39
|
}, (animator, scroll, value) => animator.getBlur({ blur: value }, scroll).blur, sectionId, [layoutId]);
|
|
39
|
-
const backdropBlur = (0, useKeyframeValue_1.useKeyframeValue)(item, (item, layoutId) => {
|
|
40
|
+
const backdropBlur = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.BackdropBlur, (item, layoutId) => {
|
|
40
41
|
if (!layoutId)
|
|
41
42
|
return 0;
|
|
42
43
|
const layoutParams = item.layoutParams[layoutId];
|
|
@@ -2,35 +2,35 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useRichTextItemValues = void 0;
|
|
4
4
|
const useKeyframeValue_1 = require("../../common/useKeyframeValue");
|
|
5
|
+
const sdk_1 = require("@cntrl-site/sdk");
|
|
5
6
|
const useLayoutContext_1 = require("../useLayoutContext");
|
|
6
7
|
const DEFAULT_COLOR = 'rgba(0, 0, 0, 1)';
|
|
7
8
|
const useRichTextItemValues = (item, sectionId) => {
|
|
8
9
|
const layoutId = (0, useLayoutContext_1.useLayoutContext)();
|
|
9
|
-
const
|
|
10
|
-
const blur = (0, useKeyframeValue_1.useKeyframeValue)(item, (item, layoutId) => {
|
|
10
|
+
const blur = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.Blur, (item, layoutId) => {
|
|
11
11
|
if (!layoutId)
|
|
12
12
|
return 0;
|
|
13
13
|
const layoutParams = item.layoutParams[layoutId];
|
|
14
14
|
return 'blur' in layoutParams ? layoutParams.blur : 0;
|
|
15
15
|
}, (animator, scroll, value) => animator.getBlur({ blur: value }, scroll).blur, sectionId, [layoutId]);
|
|
16
|
-
const letterSpacing = (0, useKeyframeValue_1.useKeyframeValue)(item, (item, layoutId) => {
|
|
16
|
+
const letterSpacing = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.LetterSpacing, (item, layoutId) => {
|
|
17
17
|
if (!layoutId)
|
|
18
18
|
return 0;
|
|
19
19
|
const layoutParams = item.layoutParams[layoutId];
|
|
20
20
|
return 'letterSpacing' in layoutParams ? layoutParams.letterSpacing : 0;
|
|
21
21
|
}, (animator, scroll, value) => animator.getLetterSpacing({ letterSpacing: value }, scroll).letterSpacing, sectionId, [layoutId]);
|
|
22
|
-
const wordSpacing = (0, useKeyframeValue_1.useKeyframeValue)(item, (item, layoutId) => {
|
|
22
|
+
const wordSpacing = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.WordSpacing, (item, layoutId) => {
|
|
23
23
|
if (!layoutId)
|
|
24
24
|
return 0;
|
|
25
25
|
const layoutParams = item.layoutParams[layoutId];
|
|
26
26
|
return 'wordSpacing' in layoutParams ? layoutParams.wordSpacing : 0;
|
|
27
27
|
}, (animator, scroll, value) => animator.getWordSpacing({ wordSpacing: value }, scroll).wordSpacing, sectionId, [layoutId]);
|
|
28
|
-
const color = (0, useKeyframeValue_1.useKeyframeValue)(item, (item, layoutId) => {
|
|
28
|
+
const color = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.TextColor, (item, layoutId) => {
|
|
29
29
|
if (!layoutId)
|
|
30
30
|
return DEFAULT_COLOR;
|
|
31
31
|
const layoutParams = item.layoutParams[layoutId];
|
|
32
32
|
return 'color' in layoutParams ? layoutParams.color : DEFAULT_COLOR;
|
|
33
33
|
}, (animator, scroll, value) => animator.getTextColor({ color: value }, scroll).color, sectionId, [layoutId]);
|
|
34
|
-
return {
|
|
34
|
+
return { blur, letterSpacing, wordSpacing, color };
|
|
35
35
|
};
|
|
36
36
|
exports.useRichTextItemValues = useRichTextItemValues;
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useStickyItemTop = void 0;
|
|
4
|
+
const sdk_1 = require("@cntrl-site/sdk");
|
|
4
5
|
const useKeyframeValue_1 = require("../../common/useKeyframeValue");
|
|
5
6
|
const useLayoutContext_1 = require("../useLayoutContext");
|
|
6
7
|
function useStickyItemTop(item, sectionHeightMap, sectionId) {
|
|
7
8
|
const layoutId = (0, useLayoutContext_1.useLayoutContext)();
|
|
8
|
-
const
|
|
9
|
+
const data = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.Position, (item, layoutId) => {
|
|
9
10
|
if (!layoutId)
|
|
10
|
-
return
|
|
11
|
+
return;
|
|
11
12
|
return item.area[layoutId];
|
|
12
|
-
}, (animator, scroll, value) => animator.getPositions(value, scroll), sectionId, [layoutId]);
|
|
13
|
+
}, (animator, scroll, value) => value ? animator.getPositions(value, scroll) : undefined, sectionId, [layoutId]);
|
|
14
|
+
const top = data ? data.top : layoutId ? item.area[layoutId].top : 0;
|
|
13
15
|
const sticky = layoutId ? item.sticky[layoutId] : undefined;
|
|
14
16
|
return sticky ? top - sticky.from : 0;
|
|
15
17
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useItemAngle = void 0;
|
|
4
|
+
const sdk_1 = require("@cntrl-site/sdk");
|
|
4
5
|
const useKeyframeValue_1 = require("../common/useKeyframeValue");
|
|
5
6
|
const useItemAngle = (item, sectionId) => {
|
|
6
|
-
const
|
|
7
|
+
const angle = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.Rotation, (item, layoutId) => layoutId ? item.area[layoutId].angle : 0, (animator, scroll, value) => animator.getRotation({ angle: value }, scroll).angle, sectionId);
|
|
7
8
|
return angle;
|
|
8
9
|
};
|
|
9
10
|
exports.useItemAngle = useItemAngle;
|
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useItemDimensions = void 0;
|
|
4
|
+
const sdk_1 = require("@cntrl-site/sdk");
|
|
4
5
|
const useKeyframeValue_1 = require("../common/useKeyframeValue");
|
|
5
6
|
const useLayoutContext_1 = require("./useLayoutContext");
|
|
6
|
-
const defaultArea = {
|
|
7
|
-
left: 0,
|
|
8
|
-
top: 0,
|
|
9
|
-
width: 0,
|
|
10
|
-
height: 0,
|
|
11
|
-
angle: 0,
|
|
12
|
-
zIndex: 0
|
|
13
|
-
};
|
|
14
7
|
const useItemDimensions = (item, sectionId) => {
|
|
15
8
|
const layoutId = (0, useLayoutContext_1.useLayoutContext)();
|
|
16
|
-
const
|
|
17
|
-
return
|
|
9
|
+
const dimensions = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.Dimensions, (item, layoutId) => layoutId ? item.area[layoutId] : undefined, (animator, scroll, value) => value ? animator.getDimensions(value, scroll) : undefined, sectionId, [layoutId]);
|
|
10
|
+
return dimensions;
|
|
18
11
|
};
|
|
19
12
|
exports.useItemDimensions = useItemDimensions;
|
|
@@ -7,19 +7,19 @@ const getItemTopStyle_1 = require("../utils/getItemTopStyle");
|
|
|
7
7
|
const useLayoutContext_1 = require("./useLayoutContext");
|
|
8
8
|
const useItemPosition = (item, sectionId) => {
|
|
9
9
|
const layoutId = (0, useLayoutContext_1.useLayoutContext)();
|
|
10
|
-
const
|
|
10
|
+
const position = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.Position, (item, layoutId) => {
|
|
11
11
|
if (!layoutId)
|
|
12
|
-
return
|
|
12
|
+
return;
|
|
13
13
|
return item.area[layoutId];
|
|
14
|
-
}, (animator, scroll, value) => animator.getPositions(value, scroll), sectionId, [layoutId]);
|
|
14
|
+
}, (animator, scroll, value) => value ? animator.getPositions(value, scroll) : undefined, sectionId, [layoutId]);
|
|
15
15
|
const anchorSide = layoutId ? item.area[layoutId].anchorSide : sdk_1.AnchorSide.Top;
|
|
16
16
|
const positionType = layoutId ? item.area[layoutId].positionType : sdk_1.PositionType.ScreenBased;
|
|
17
17
|
// tp prevent fixed item (with anchor point bottom) to jump when scroll in safari on mobile
|
|
18
18
|
const isScreenBasedBottom = positionType === sdk_1.PositionType.ScreenBased && anchorSide === sdk_1.AnchorSide.Bottom;
|
|
19
|
-
return {
|
|
20
|
-
bottom: isScreenBasedBottom ? `${-top * 100}vw` : 'unset',
|
|
21
|
-
top: isScreenBasedBottom ? 'unset' : (0, getItemTopStyle_1.getItemTopStyle)(top, anchorSide),
|
|
22
|
-
left: `${left * 100}vw`
|
|
23
|
-
};
|
|
19
|
+
return position ? {
|
|
20
|
+
bottom: isScreenBasedBottom ? `${-position.top * 100}vw` : 'unset',
|
|
21
|
+
top: isScreenBasedBottom ? 'unset' : (0, getItemTopStyle_1.getItemTopStyle)(position.top, anchorSide),
|
|
22
|
+
left: `${position.left * 100}vw`
|
|
23
|
+
} : undefined;
|
|
24
24
|
};
|
|
25
25
|
exports.useItemPosition = useItemPosition;
|
|
@@ -6,8 +6,7 @@ const useKeyframeValue_1 = require("../common/useKeyframeValue");
|
|
|
6
6
|
const useLayoutContext_1 = require("./useLayoutContext");
|
|
7
7
|
const useItemScale = (item, sectionId) => {
|
|
8
8
|
const layoutId = (0, useLayoutContext_1.useLayoutContext)();
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
return { scale, scaleAnchor };
|
|
9
|
+
const scale = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.Scale, (item, layoutId) => (layoutId ? item.area[layoutId].scale : undefined), (animator, scroll, value) => value !== undefined ? animator.getScale({ scale: value }, scroll).scale : undefined, sectionId, [layoutId]);
|
|
10
|
+
return scale;
|
|
12
11
|
};
|
|
13
12
|
exports.useItemScale = useItemScale;
|
|
@@ -3,13 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ScaleAnchorMap = void 0;
|
|
4
4
|
const sdk_1 = require("@cntrl-site/sdk");
|
|
5
5
|
exports.ScaleAnchorMap = {
|
|
6
|
-
[sdk_1.
|
|
7
|
-
[sdk_1.
|
|
8
|
-
[sdk_1.
|
|
9
|
-
[sdk_1.
|
|
10
|
-
[sdk_1.
|
|
11
|
-
[sdk_1.
|
|
12
|
-
[sdk_1.
|
|
13
|
-
[sdk_1.
|
|
14
|
-
[sdk_1.
|
|
6
|
+
[sdk_1.AreaAnchor.TopLeft]: 'top left',
|
|
7
|
+
[sdk_1.AreaAnchor.TopCenter]: 'top center',
|
|
8
|
+
[sdk_1.AreaAnchor.TopRight]: 'top right',
|
|
9
|
+
[sdk_1.AreaAnchor.MiddleLeft]: 'center left',
|
|
10
|
+
[sdk_1.AreaAnchor.MiddleCenter]: 'center',
|
|
11
|
+
[sdk_1.AreaAnchor.MiddleRight]: 'center right',
|
|
12
|
+
[sdk_1.AreaAnchor.BottomLeft]: 'bottom left',
|
|
13
|
+
[sdk_1.AreaAnchor.BottomCenter]: 'bottom center',
|
|
14
|
+
[sdk_1.AreaAnchor.BottomRight]: 'bottom right'
|
|
15
15
|
};
|
|
@@ -9,11 +9,11 @@ const PATTERN_2_URL = 'https://cdn.cntrl.site/client-app-files/bayer16.png';
|
|
|
9
9
|
function useImageFx(canvas, enabled, { imageUrl, fragmentShader, cursor, controls }, width, height) {
|
|
10
10
|
const mousePos = (0, react_1.useRef)([0.0, 0.0]);
|
|
11
11
|
const imageFx = (0, react_1.useMemo)(() => {
|
|
12
|
-
if (!imageUrl || !cursor)
|
|
12
|
+
if (!imageUrl || !cursor || !enabled)
|
|
13
13
|
return undefined;
|
|
14
14
|
const { type, x, y } = cursor;
|
|
15
15
|
return new effects_1.ImageEffect(imageUrl, PATTERN_URL, PATTERN_2_URL, fragmentShader, Object.assign({ time: 0, cursor: type === 'mouse' ? mousePos.current : [x, y] }, controls), width, height);
|
|
16
|
-
}, [imageUrl, fragmentShader, width, height]);
|
|
16
|
+
}, [imageUrl, fragmentShader, width, height, enabled]);
|
|
17
17
|
(0, react_1.useEffect)(() => {
|
|
18
18
|
if (!cursor || cursor.type !== 'mouse' || !canvas || !imageFx)
|
|
19
19
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cntrl-site/sdk-nextjs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.30.0",
|
|
4
4
|
"description": "SDK for Next.js",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/index.ts",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@cntrl-site/color": "^1.0.0",
|
|
25
25
|
"@cntrl-site/effects": "^1.2.0",
|
|
26
|
-
"@cntrl-site/sdk": "^1.
|
|
26
|
+
"@cntrl-site/sdk": "^1.12.0",
|
|
27
27
|
"@types/vimeo__player": "^2.18.0",
|
|
28
28
|
"@vimeo/player": "^2.20.1",
|
|
29
29
|
"html-react-parser": "^3.0.1",
|
|
@@ -12,11 +12,12 @@ const emptyDeps: DependencyList = [];
|
|
|
12
12
|
|
|
13
13
|
export const useKeyframeValue = <T>(
|
|
14
14
|
item: ItemAny,
|
|
15
|
+
type: KeyframeType,
|
|
15
16
|
itemParamsGetter: ItemParamGetter<T>,
|
|
16
17
|
animatorGetter: AnimatorGetter<T>,
|
|
17
18
|
sectionId: string,
|
|
18
19
|
deps: DependencyList = emptyDeps
|
|
19
|
-
) => {
|
|
20
|
+
): T => {
|
|
20
21
|
const animatorGetterRef = useRef(animatorGetter);
|
|
21
22
|
const itemParamsGetterRef = useRef(itemParamsGetter);
|
|
22
23
|
|
|
@@ -26,7 +27,7 @@ export const useKeyframeValue = <T>(
|
|
|
26
27
|
const articleRectObserver = useContext(ArticleRectContext);
|
|
27
28
|
const layoutId = useLayoutContext();
|
|
28
29
|
const keyframesRepo = useContext(KeyframesContext);
|
|
29
|
-
const keyframes = useMemo(() => keyframesRepo.getItemKeyframes(item.id), [item.id, keyframesRepo]);
|
|
30
|
+
const keyframes = useMemo(() => keyframesRepo.getItemKeyframes(item.id).filter(kf => kf.type === type), [item.id, keyframesRepo, type]);
|
|
30
31
|
const paramValue = useMemo<T>(() => {
|
|
31
32
|
return itemParamsGetterRef.current(item, layoutId);
|
|
32
33
|
}, [item, layoutId, ...deps]);
|
|
@@ -4,21 +4,7 @@ import { useCurrentLayout } from '../common/useCurrentLayout';
|
|
|
4
4
|
import { LayoutContext } from '../provider/LayoutContext';
|
|
5
5
|
|
|
6
6
|
export const ArticleWrapper: FC<PropsWithChildren<{}>> = ({ children }) => {
|
|
7
|
-
const id = useId();
|
|
8
|
-
const [isPageLoaded, setIsPageLoaded] = useState(false);
|
|
9
7
|
const { layoutId, layoutDeviation } = useCurrentLayout();
|
|
10
|
-
|
|
11
|
-
useEffect(() => {
|
|
12
|
-
const onPageLoad = () => {
|
|
13
|
-
setIsPageLoaded(true);
|
|
14
|
-
};
|
|
15
|
-
if (document.readyState === 'loading') {
|
|
16
|
-
window.addEventListener('DOMContentLoaded', onPageLoad);
|
|
17
|
-
return () => window.removeEventListener('DOMContentLoaded', onPageLoad);
|
|
18
|
-
} else {
|
|
19
|
-
onPageLoad();
|
|
20
|
-
}
|
|
21
|
-
}, []);
|
|
22
8
|
const layoutDeviationStyle = {'--layout-deviation': layoutDeviation} as CSSProperties;
|
|
23
9
|
|
|
24
10
|
return (
|
|
@@ -26,18 +12,11 @@ export const ArticleWrapper: FC<PropsWithChildren<{}>> = ({ children }) => {
|
|
|
26
12
|
<div
|
|
27
13
|
className="article-wrapper"
|
|
28
14
|
style={{
|
|
29
|
-
opacity: layoutId && isPageLoaded ? 1 : 0,
|
|
30
15
|
...layoutDeviationStyle
|
|
31
16
|
}}
|
|
32
17
|
>
|
|
33
18
|
{children}
|
|
34
19
|
</div>
|
|
35
|
-
<JSXStyle id={id}>{`
|
|
36
|
-
.article-wrapper {
|
|
37
|
-
opacity: 1;
|
|
38
|
-
transition: opacity 0.2s ease;
|
|
39
|
-
}
|
|
40
|
-
`}</JSXStyle>
|
|
41
20
|
</LayoutContext.Provider>
|
|
42
21
|
);
|
|
43
22
|
};
|