@cntrl-site/sdk-nextjs 1.9.8 → 1.9.10
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/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/modules.xml +8 -0
- package/.idea/sdk-nextjs.iml +12 -0
- package/.idea/vcs.xml +6 -0
- package/lib/components/items/EmbedVideoItem/VimeoEmbed.js +12 -4
- package/lib/components/items/EmbedVideoItem/YoutubeEmbed.js +9 -4
- package/lib/components/items/FileItem/ImageItem.js +23 -43
- package/lib/components/items/FileItem/VideoItem.js +21 -41
- package/lib/components/items/RectangleItem/RectangleItem.js +22 -45
- package/package.json +1 -1
- package/src/components/items/EmbedVideoItem/VimeoEmbed.tsx +11 -3
- package/src/components/items/EmbedVideoItem/YoutubeEmbed.tsx +8 -3
- package/src/components/items/FileItem/ImageItem.tsx +14 -60
- package/src/components/items/FileItem/VideoItem.tsx +14 -60
- package/src/components/items/Item.tsx +1 -1
- package/src/components/items/RectangleItem/RectangleItem.tsx +24 -57
- package/cntrl-site-sdk-nextjs-1.9.8.tgz +0 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectModuleManager">
|
|
4
|
+
<modules>
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/sdk-nextjs.iml" filepath="$PROJECT_DIR$/.idea/sdk-nextjs.iml" />
|
|
6
|
+
</modules>
|
|
7
|
+
</component>
|
|
8
|
+
</project>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="WEB_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager">
|
|
4
|
+
<content url="file://$MODULE_DIR$">
|
|
5
|
+
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
|
6
|
+
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
|
7
|
+
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
|
8
|
+
</content>
|
|
9
|
+
<orderEntry type="inheritedJdk" />
|
|
10
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
11
|
+
</component>
|
|
12
|
+
</module>
|
package/.idea/vcs.xml
ADDED
|
@@ -38,7 +38,7 @@ const VimeoEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibili
|
|
|
38
38
|
const layoutParams = layoutId ? item.layoutParams[layoutId] : null;
|
|
39
39
|
const [ref, setRef] = (0, react_1.useState)(null);
|
|
40
40
|
const [imgRef, setImgRef] = (0, react_1.useState)(null);
|
|
41
|
-
const [isCoverVisible, setIsCoverVisible] = (0, react_1.useState)(
|
|
41
|
+
const [isCoverVisible, setIsCoverVisible] = (0, react_1.useState)(item.commonParams.coverUrl !== null);
|
|
42
42
|
const layoutValues = [item.area, item.layoutParams];
|
|
43
43
|
const wrapperStateParams = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['angle', 'blur', 'opacity']);
|
|
44
44
|
const frameStateParams = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['radius']);
|
|
@@ -68,6 +68,9 @@ const VimeoEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibili
|
|
|
68
68
|
if (layoutParams.play === 'on-click') {
|
|
69
69
|
setIsCoverVisible(true);
|
|
70
70
|
}
|
|
71
|
+
if (layoutParams.play === 'auto') {
|
|
72
|
+
setIsCoverVisible(false);
|
|
73
|
+
}
|
|
71
74
|
vimeoPlayer.on('pause', (e) => {
|
|
72
75
|
if (e.seconds === 0) {
|
|
73
76
|
setIsCoverVisible(true);
|
|
@@ -117,14 +120,19 @@ const VimeoEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibili
|
|
|
117
120
|
});
|
|
118
121
|
}, [interactionCtrl, vimeoPlayer]);
|
|
119
122
|
return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, { url: (_e = item.link) === null || _e === void 0 ? void 0 : _e.url, target: (_f = item.link) === null || _f === void 0 ? void 0 : _f.target, children: [(0, jsx_runtime_1.jsxs)("div", { className: `embed-video-wrapper-${item.id}`, ref: setRef, style: Object.assign(Object.assign(Object.assign(Object.assign({}, (opacity !== undefined ? { opacity } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), { willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset', transition: (_g = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.transition) !== null && _g !== void 0 ? _g : 'none' }), onMouseEnter: () => {
|
|
120
|
-
if (!vimeoPlayer || !layoutParams || layoutParams.play !== 'on-hover')
|
|
123
|
+
if (!vimeoPlayer || !layoutParams || layoutParams.play !== 'on-hover' || isCoverVisible)
|
|
121
124
|
return;
|
|
122
125
|
vimeoPlayer.play();
|
|
123
126
|
}, onMouseLeave: () => {
|
|
124
127
|
if (!vimeoPlayer || !layoutParams || layoutParams.play !== 'on-hover')
|
|
125
128
|
return;
|
|
126
129
|
vimeoPlayer.pause();
|
|
127
|
-
}, children: [item.commonParams.coverUrl && ((0, jsx_runtime_1.jsx)("img", { ref: setImgRef, onClick: () => onCoverClick()
|
|
130
|
+
}, children: [item.commonParams.coverUrl && ((0, jsx_runtime_1.jsx)("img", Object.assign({ ref: setImgRef }, ((layoutParams === null || layoutParams === void 0 ? void 0 : layoutParams.play) === 'on-click' ? { onClick: () => onCoverClick() } : {}), ((layoutParams === null || layoutParams === void 0 ? void 0 : layoutParams.play) === 'on-hover' ? { onMouseEnter: () => {
|
|
131
|
+
if (!vimeoPlayer || !layoutParams || layoutParams.play !== 'on-hover')
|
|
132
|
+
return;
|
|
133
|
+
setIsCoverVisible(false);
|
|
134
|
+
vimeoPlayer.play();
|
|
135
|
+
} } : {}), { src: (_h = item.commonParams.coverUrl) !== null && _h !== void 0 ? _h : '', style: {
|
|
128
136
|
display: isCoverVisible ? 'block' : 'none',
|
|
129
137
|
cursor: 'pointer',
|
|
130
138
|
position: 'absolute',
|
|
@@ -133,7 +141,7 @@ const VimeoEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibili
|
|
|
133
141
|
width: '100%',
|
|
134
142
|
top: '0',
|
|
135
143
|
left: '0'
|
|
136
|
-
}, alt: "Cover img" })), layoutParams && (!layoutParams.controls && (layoutParams.play === 'on-click' || layoutParams.play === 'auto')) && ((0, jsx_runtime_1.jsx)("div", { onClick: handleClick, style: {
|
|
144
|
+
}, alt: "Cover img" }))), layoutParams && (!layoutParams.controls && (layoutParams.play === 'on-click' || layoutParams.play === 'auto')) && ((0, jsx_runtime_1.jsx)("div", { onClick: handleClick, style: {
|
|
137
145
|
position: 'absolute',
|
|
138
146
|
height: '100%',
|
|
139
147
|
width: '100%',
|
|
@@ -29,7 +29,7 @@ const YoutubeEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibi
|
|
|
29
29
|
const YT = (0, useYouTubeIframeApi_1.useYouTubeIframeApi)();
|
|
30
30
|
const [div, setDiv] = (0, react_1.useState)(null);
|
|
31
31
|
const [player, setPlayer] = (0, react_1.useState)(undefined);
|
|
32
|
-
const [isCoverVisible, setIsCoverVisible] = (0, react_1.useState)(
|
|
32
|
+
const [isCoverVisible, setIsCoverVisible] = (0, react_1.useState)(item.commonParams.coverUrl !== null);
|
|
33
33
|
const [imgRef, setImgRef] = (0, react_1.useState)(null);
|
|
34
34
|
const layoutValues = [item.area, item.layoutParams];
|
|
35
35
|
const wrapperStateParams = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['angle', 'blur', 'opacity']);
|
|
@@ -115,14 +115,19 @@ const YoutubeEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibi
|
|
|
115
115
|
});
|
|
116
116
|
}, [interactionCtrl, player]);
|
|
117
117
|
return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, { url: (_e = item.link) === null || _e === void 0 ? void 0 : _e.url, target: (_f = item.link) === null || _f === void 0 ? void 0 : _f.target, children: [(0, jsx_runtime_1.jsxs)("div", { className: `embed-youtube-video-wrapper-${item.id}`, onMouseEnter: () => {
|
|
118
|
-
if (!player || !layoutParams || layoutParams.play !== 'on-hover')
|
|
118
|
+
if (!player || !layoutParams || layoutParams.play !== 'on-hover' || isCoverVisible)
|
|
119
119
|
return;
|
|
120
120
|
player.playVideo();
|
|
121
121
|
}, onMouseLeave: () => {
|
|
122
122
|
if (!player || !layoutParams || layoutParams.play !== 'on-hover')
|
|
123
123
|
return;
|
|
124
124
|
player.pauseVideo();
|
|
125
|
-
}, style: Object.assign(Object.assign(Object.assign(Object.assign({}, (opacity !== undefined ? { opacity } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), { willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset', transition: (_g = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.transition) !== null && _g !== void 0 ? _g : 'none' }), children: [item.commonParams.coverUrl && ((0, jsx_runtime_1.jsx)("img", { ref: setImgRef, onClick: () => onCoverClick()
|
|
125
|
+
}, style: Object.assign(Object.assign(Object.assign(Object.assign({}, (opacity !== undefined ? { opacity } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), { willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset', transition: (_g = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.transition) !== null && _g !== void 0 ? _g : 'none' }), children: [item.commonParams.coverUrl && ((0, jsx_runtime_1.jsx)("img", Object.assign({ ref: setImgRef }, ((layoutParams === null || layoutParams === void 0 ? void 0 : layoutParams.play) === 'on-click' ? { onClick: () => onCoverClick() } : {}), ((layoutParams === null || layoutParams === void 0 ? void 0 : layoutParams.play) === 'on-hover' ? { onMouseEnter: () => {
|
|
126
|
+
if (!player || !layoutParams || layoutParams.play !== 'on-hover')
|
|
127
|
+
return;
|
|
128
|
+
setIsCoverVisible(false);
|
|
129
|
+
player.playVideo();
|
|
130
|
+
} } : {}), { src: (_h = item.commonParams.coverUrl) !== null && _h !== void 0 ? _h : '', style: {
|
|
126
131
|
display: isCoverVisible ? 'block' : 'none',
|
|
127
132
|
cursor: 'pointer',
|
|
128
133
|
position: 'absolute',
|
|
@@ -132,7 +137,7 @@ const YoutubeEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibi
|
|
|
132
137
|
top: '0',
|
|
133
138
|
left: '0',
|
|
134
139
|
zIndex: 1
|
|
135
|
-
}, alt: "Cover img" })), (0, jsx_runtime_1.jsx)("div", { className: `embed-${item.id}`, ref: setDiv, style: Object.assign(Object.assign({}, (radius !== undefined ? { borderRadius: `${radius * 100}vw` } : {})), { transition: (_j = frameStateParams === null || frameStateParams === void 0 ? void 0 : frameStateParams.transition) !== null && _j !== void 0 ? _j : 'none' }) })] }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
140
|
+
}, alt: "Cover img" }))), (0, jsx_runtime_1.jsx)("div", { className: `embed-${item.id}`, ref: setDiv, style: Object.assign(Object.assign({}, (radius !== undefined ? { borderRadius: `${radius * 100}vw` } : {})), { transition: (_j = frameStateParams === null || frameStateParams === void 0 ? void 0 : frameStateParams.transition) !== null && _j !== void 0 ? _j : 'none' }) })] }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
136
141
|
.embed-youtube-video-wrapper-${item.id},
|
|
137
142
|
.embed-${item.id} {
|
|
138
143
|
position: absolute;
|
|
@@ -20,7 +20,7 @@ const getStyleFromItemStateAndParams_1 = require("../../../utils/getStyleFromIte
|
|
|
20
20
|
const useItemFXData_1 = require("../../../common/useItemFXData");
|
|
21
21
|
const getFill_1 = require("../../../utils/getFill");
|
|
22
22
|
const ImageItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityChange }) => {
|
|
23
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
23
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
24
24
|
const id = (0, react_1.useId)();
|
|
25
25
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
26
26
|
const layoutId = (0, useLayoutContext_1.useLayoutContext)();
|
|
@@ -38,10 +38,7 @@ const ImageItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityCha
|
|
|
38
38
|
const width = area && exemplary ? area.width * exemplary : 0;
|
|
39
39
|
const height = area && exemplary ? area.height * exemplary : 0;
|
|
40
40
|
const wrapperStateParams = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['angle', 'opacity', 'blur']);
|
|
41
|
-
const imgStateParams = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['strokeWidth', 'radius']);
|
|
42
|
-
const stateStrokeFillParams = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['strokeFill']);
|
|
43
|
-
const stateStrokeFillLayers = (_b = stateStrokeFillParams === null || stateStrokeFillParams === void 0 ? void 0 : stateStrokeFillParams.styles) === null || _b === void 0 ? void 0 : _b.strokeFill;
|
|
44
|
-
const strokeSolidTransition = (_c = stateStrokeFillParams === null || stateStrokeFillParams === void 0 ? void 0 : stateStrokeFillParams.transition) !== null && _c !== void 0 ? _c : 'none';
|
|
41
|
+
const imgStateParams = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['strokeWidth', 'radius', 'strokeFill']);
|
|
45
42
|
(0, react_1.useEffect)(() => {
|
|
46
43
|
isInitialRef.current = false;
|
|
47
44
|
}, []);
|
|
@@ -51,35 +48,30 @@ const ImageItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityCha
|
|
|
51
48
|
controlsValues
|
|
52
49
|
}, width, height);
|
|
53
50
|
const rect = (0, useElementRect_1.useElementRect)(wrapperRef);
|
|
54
|
-
const rectWidth = Math.floor((
|
|
55
|
-
const rectHeight = Math.floor((
|
|
56
|
-
const radius = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((
|
|
57
|
-
const strokeWidth = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((
|
|
58
|
-
const
|
|
59
|
-
const
|
|
60
|
-
const
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const stroke = strokeValue
|
|
65
|
-
? (_l = (0, getFill_1.getFill)(strokeValue)) !== null && _l !== void 0 ? _l : 'transparent'
|
|
51
|
+
const rectWidth = Math.floor((_b = rect === null || rect === void 0 ? void 0 : rect.width) !== null && _b !== void 0 ? _b : 0);
|
|
52
|
+
const rectHeight = Math.floor((_c = rect === null || rect === void 0 ? void 0 : rect.height) !== null && _c !== void 0 ? _c : 0);
|
|
53
|
+
const radius = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_d = imgStateParams === null || imgStateParams === void 0 ? void 0 : imgStateParams.styles) === null || _d === void 0 ? void 0 : _d.radius, itemRadius);
|
|
54
|
+
const strokeWidth = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_e = imgStateParams === null || imgStateParams === void 0 ? void 0 : imgStateParams.styles) === null || _e === void 0 ? void 0 : _e.strokeWidth, itemStrokeWidth);
|
|
55
|
+
const strokeFill = (_h = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_g = (_f = imgStateParams === null || imgStateParams === void 0 ? void 0 : imgStateParams.styles) === null || _f === void 0 ? void 0 : _f.strokeFill) === null || _g === void 0 ? void 0 : _g[0], itemStrokeFill === null || itemStrokeFill === void 0 ? void 0 : itemStrokeFill[0])) !== null && _h !== void 0 ? _h : itemStrokeFill === null || itemStrokeFill === void 0 ? void 0 : itemStrokeFill[0];
|
|
56
|
+
const angle = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_j = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.styles) === null || _j === void 0 ? void 0 : _j.angle, itemAngle);
|
|
57
|
+
const opacity = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_k = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.styles) === null || _k === void 0 ? void 0 : _k.opacity, itemOpacity);
|
|
58
|
+
const blur = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_l = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.styles) === null || _l === void 0 ? void 0 : _l.blur, itemBlur);
|
|
59
|
+
const stroke = strokeFill
|
|
60
|
+
? (_m = (0, getFill_1.getFill)(strokeFill)) !== null && _m !== void 0 ? _m : 'transparent'
|
|
66
61
|
: 'transparent';
|
|
67
|
-
const inlineStyles = Object.assign(Object.assign(Object.assign({}, (radius !== undefined ? { borderRadius: `${radius * 100}vw` } : {})), (strokeWidth !== undefined ? {
|
|
62
|
+
const inlineStyles = Object.assign(Object.assign(Object.assign({}, (radius !== undefined ? { borderRadius: `${radius * 100}vw` } : {})), (strokeWidth !== undefined ? {
|
|
63
|
+
borderColor: stroke,
|
|
64
|
+
borderWidth: `${strokeWidth * 100}vw`,
|
|
65
|
+
borderRadius: radius !== undefined ? `${radius * 100}vw` : 'inherit',
|
|
66
|
+
borderStyle: 'solid',
|
|
67
|
+
} : {})), { transition: (_o = imgStateParams === null || imgStateParams === void 0 ? void 0 : imgStateParams.transition) !== null && _o !== void 0 ? _o : 'none' });
|
|
68
68
|
const isInteractive = opacity !== 0;
|
|
69
69
|
(0, react_1.useEffect)(() => {
|
|
70
70
|
onVisibilityChange === null || onVisibilityChange === void 0 ? void 0 : onVisibilityChange(isInteractive);
|
|
71
71
|
}, [isInteractive, onVisibilityChange]);
|
|
72
|
-
return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { url: (
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
'--stroke-background-repeat': strokeValue.behavior === 'repeat' ? 'repeat' : 'no-repeat'
|
|
76
|
-
} : {})) : {})), { willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset', transition: (_q = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.transition) !== null && _q !== void 0 ? _q : 'none' }), children: [hasGLEffect && isFXAllowed
|
|
77
|
-
? ((0, jsx_runtime_1.jsx)("canvas", { style: inlineStyles, ref: fxCanvas, className: `img-canvas image-${item.id}`, width: rectWidth, height: rectHeight }))
|
|
78
|
-
: ((0, jsx_runtime_1.jsx)("img", { alt: "", className: `image image-${item.id}`, style: inlineStyles, src: item.commonParams.url })), strokeWidth !== 0 && strokeValue && ((0, jsx_runtime_1.jsx)("div", { className: `image-border-${item.id}`, style: Object.assign({ position: 'absolute', inset: 0, borderRadius: 'inherit', pointerEvents: 'none', zIndex: 2, WebkitMask: 'linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)', WebkitMaskComposite: 'xor', maskComposite: 'exclude' }, (strokeWidth !== 0 && strokeValue ? Object.assign(Object.assign(Object.assign({}, (strokeWidth ? { padding: `${strokeWidth * 100}vw` } : {})), (strokeValue.type === 'solid' ? { transition: strokeSolidTransition, background: stroke } : {})), (strokeValue.type === 'image' ? {
|
|
79
|
-
backgroundPosition: 'center',
|
|
80
|
-
backgroundSize: strokeValue.behavior === 'repeat' ? `${strokeValue.backgroundSize}%` : strokeValue.behavior,
|
|
81
|
-
backgroundRepeat: strokeValue.behavior === 'repeat' ? 'repeat' : 'no-repeat'
|
|
82
|
-
} : { background: stroke })) : {})) }))] }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
72
|
+
return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { url: (_p = item.link) === null || _p === void 0 ? void 0 : _p.url, target: (_q = item.link) === null || _q === void 0 ? void 0 : _q.target, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `image-wrapper-${item.id}`, ref: setWrapperRef, style: Object.assign(Object.assign(Object.assign(Object.assign({}, (opacity !== undefined ? { opacity } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), { willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset', transition: (_r = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.transition) !== null && _r !== void 0 ? _r : 'none' }), children: hasGLEffect && isFXAllowed
|
|
73
|
+
? ((0, jsx_runtime_1.jsx)("canvas", { style: inlineStyles, ref: fxCanvas, className: `img-canvas image-${item.id}`, width: rectWidth, height: rectHeight }))
|
|
74
|
+
: ((0, jsx_runtime_1.jsx)("img", { alt: "", className: `image image-${item.id}`, style: inlineStyles, src: item.commonParams.url })) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
83
75
|
.image-wrapper-${item.id} {
|
|
84
76
|
position: absolute;
|
|
85
77
|
width: 100%;
|
|
@@ -115,21 +107,9 @@ const ImageItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityCha
|
|
|
115
107
|
}
|
|
116
108
|
.image-${item.id} {
|
|
117
109
|
border: solid;
|
|
118
|
-
border-color:
|
|
119
|
-
border-width: ${layoutParams.strokeWidth * 100}vw;
|
|
110
|
+
border-color: ${stroke};
|
|
120
111
|
border-radius: ${layoutParams.radius * 100}vw;
|
|
121
|
-
|
|
122
|
-
.image-border-${item.id} {
|
|
123
|
-
position: absolute;
|
|
124
|
-
inset: 0;
|
|
125
|
-
border-radius: inherit;
|
|
126
|
-
pointer-events: none;
|
|
127
|
-
z-index: 2;
|
|
128
|
-
-webkit-mask:
|
|
129
|
-
linear-gradient(#fff 0 0) content-box,
|
|
130
|
-
linear-gradient(#fff 0 0);
|
|
131
|
-
-webkit-mask-composite: xor;
|
|
132
|
-
mask-composite: exclude;
|
|
112
|
+
border-width: ${layoutParams.strokeWidth * 100}vw;
|
|
133
113
|
}
|
|
134
114
|
`);
|
|
135
115
|
})}
|
|
@@ -21,7 +21,7 @@ const useElementRect_1 = require("../../../utils/useElementRect");
|
|
|
21
21
|
const useItemFXData_1 = require("../../../common/useItemFXData");
|
|
22
22
|
const getFill_1 = require("../../../utils/getFill");
|
|
23
23
|
const VideoItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityChange }) => {
|
|
24
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
24
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
25
25
|
const id = (0, react_1.useId)();
|
|
26
26
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
27
27
|
const layoutId = (0, useLayoutContext_1.useLayoutContext)();
|
|
@@ -49,20 +49,15 @@ const VideoItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityCha
|
|
|
49
49
|
const layoutValues = [item.area, item.layoutParams];
|
|
50
50
|
const hasScrollPlayback = scrollPlayback !== null;
|
|
51
51
|
const wrapperStateParams = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['angle', 'opacity', 'blur']);
|
|
52
|
-
const videoStateParams = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['strokeWidth', 'radius']);
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
const strokeValue = stateStrokeFillLayers
|
|
62
|
-
? (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)(stateStrokeFillLayers[0], itemStrokeFill === null || itemStrokeFill === void 0 ? void 0 : itemStrokeFill[0])
|
|
63
|
-
: itemStrokeFill === null || itemStrokeFill === void 0 ? void 0 : itemStrokeFill[0];
|
|
64
|
-
const stroke = strokeValue
|
|
65
|
-
? (_l = (0, getFill_1.getFill)(strokeValue)) !== null && _l !== void 0 ? _l : 'transparent'
|
|
52
|
+
const videoStateParams = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['strokeWidth', 'radius', 'strokeFill']);
|
|
53
|
+
const angle = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_d = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.styles) === null || _d === void 0 ? void 0 : _d.angle, itemAngle);
|
|
54
|
+
const opacity = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_e = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.styles) === null || _e === void 0 ? void 0 : _e.opacity, itemOpacity);
|
|
55
|
+
const blur = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_f = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.styles) === null || _f === void 0 ? void 0 : _f.blur, itemBlur);
|
|
56
|
+
const strokeWidth = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_g = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.styles) === null || _g === void 0 ? void 0 : _g.strokeWidth, itemStrokeWidth);
|
|
57
|
+
const radius = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_h = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.styles) === null || _h === void 0 ? void 0 : _h.radius, itemRadius);
|
|
58
|
+
const strokeFill = (_l = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_k = (_j = videoStateParams === null || videoStateParams === void 0 ? void 0 : videoStateParams.styles) === null || _j === void 0 ? void 0 : _j.strokeFill) === null || _k === void 0 ? void 0 : _k[0], itemStrokeFill === null || itemStrokeFill === void 0 ? void 0 : itemStrokeFill[0])) !== null && _l !== void 0 ? _l : itemStrokeFill === null || itemStrokeFill === void 0 ? void 0 : itemStrokeFill[0];
|
|
59
|
+
const stroke = strokeFill
|
|
60
|
+
? (_m = (0, getFill_1.getFill)(strokeFill)) !== null && _m !== void 0 ? _m : 'transparent'
|
|
66
61
|
: 'transparent';
|
|
67
62
|
(0, react_1.useEffect)(() => {
|
|
68
63
|
isInitialRef.current = false;
|
|
@@ -73,7 +68,12 @@ const VideoItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityCha
|
|
|
73
68
|
controls: controlsValues
|
|
74
69
|
}, width, height);
|
|
75
70
|
(0, useRegisterResize_1.useRegisterResize)(ref, onResize);
|
|
76
|
-
const inlineStyles = Object.assign(Object.assign(Object.assign({}, (radius !== undefined ? { borderRadius: `${radius * 100}vw` } : {})), (strokeWidth !== undefined ? {
|
|
71
|
+
const inlineStyles = Object.assign(Object.assign(Object.assign({}, (radius !== undefined ? { borderRadius: `${radius * 100}vw` } : {})), (strokeWidth !== undefined ? {
|
|
72
|
+
borderWidth: `${strokeWidth * 100}vw`,
|
|
73
|
+
borderColor: stroke,
|
|
74
|
+
borderRadius: radius !== undefined ? `${radius * 100}vw` : 'inherit',
|
|
75
|
+
borderStyle: 'solid'
|
|
76
|
+
} : {})), { transition: (_o = videoStateParams === null || videoStateParams === void 0 ? void 0 : videoStateParams.transition) !== null && _o !== void 0 ? _o : 'none' });
|
|
77
77
|
const isInteractive = opacity !== 0;
|
|
78
78
|
(0, react_1.useEffect)(() => {
|
|
79
79
|
onVisibilityChange === null || onVisibilityChange === void 0 ? void 0 : onVisibilityChange(isInteractive);
|
|
@@ -96,11 +96,7 @@ const VideoItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityCha
|
|
|
96
96
|
observer.observe(ref);
|
|
97
97
|
return () => observer.disconnect();
|
|
98
98
|
}, [layoutParams, videoRef, ref, userPaused, isVideoInteracted]);
|
|
99
|
-
return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, { url: (
|
|
100
|
-
'--stroke-background-position': 'center',
|
|
101
|
-
'--stroke-background-size': strokeValue.behavior === 'repeat' ? `${strokeValue.backgroundSize}%` : strokeValue.behavior,
|
|
102
|
-
'--stroke-background-repeat': strokeValue.behavior === 'repeat' ? 'repeat' : 'no-repeat'
|
|
103
|
-
} : {})) : {})), { willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset', transition: (_q = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.transition) !== null && _q !== void 0 ? _q : 'none' }), 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}` })), hasGLEffect && isFXAllowed && ((0, jsx_runtime_1.jsx)("canvas", { style: inlineStyles, ref: fxCanvas, className: `video-canvas video-${item.id}`, width: rectWidth, height: rectHeight })), !hasScrollPlayback && !hasGLEffect && layoutParams && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("video", { poster: (_r = item.commonParams.coverUrl) !== null && _r !== void 0 ? _r : '', ref: setVideoRef, autoPlay: layoutParams.play === 'auto', preload: "auto", onClick: () => {
|
|
99
|
+
return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, { url: (_p = item.link) === null || _p === void 0 ? void 0 : _p.url, target: (_q = item.link) === null || _q === void 0 ? void 0 : _q.target, children: [(0, jsx_runtime_1.jsxs)("div", { className: `video-wrapper-${item.id}`, ref: setRef, style: Object.assign(Object.assign(Object.assign(Object.assign({}, (opacity !== undefined ? { opacity } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), { willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset', transition: (_r = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.transition) !== null && _r !== void 0 ? _r : 'none' }), 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}` })), hasGLEffect && isFXAllowed && ((0, jsx_runtime_1.jsx)("canvas", { style: inlineStyles, ref: fxCanvas, className: `video-canvas video-${item.id}`, width: rectWidth, height: rectHeight })), !hasScrollPlayback && !hasGLEffect && layoutParams && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("video", { poster: (_s = item.commonParams.coverUrl) !== null && _s !== void 0 ? _s : '', ref: setVideoRef, autoPlay: layoutParams.play === 'auto', preload: "auto", onClick: () => {
|
|
104
100
|
setIsVideoInteracted(true);
|
|
105
101
|
}, muted: layoutParams.muted, onPlay: () => {
|
|
106
102
|
setIsVideoPlaying(true);
|
|
@@ -123,7 +119,7 @@ const VideoItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityCha
|
|
|
123
119
|
return;
|
|
124
120
|
setIsVideoInteracted(true);
|
|
125
121
|
videoRef.play();
|
|
126
|
-
}, src: (
|
|
122
|
+
}, src: (_t = item.commonParams.coverUrl) !== null && _t !== void 0 ? _t : '', className: `video-cover-${item.id}`, onClick: () => {
|
|
127
123
|
if (!videoRef)
|
|
128
124
|
return;
|
|
129
125
|
setIsVideoInteracted(true);
|
|
@@ -138,11 +134,7 @@ const VideoItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityCha
|
|
|
138
134
|
else {
|
|
139
135
|
videoRef.play();
|
|
140
136
|
}
|
|
141
|
-
} })))] })),
|
|
142
|
-
backgroundPosition: 'center',
|
|
143
|
-
backgroundSize: strokeValue.behavior === 'repeat' ? `${strokeValue.backgroundSize}%` : strokeValue.behavior,
|
|
144
|
-
backgroundRepeat: strokeValue.behavior === 'repeat' ? 'repeat' : 'no-repeat'
|
|
145
|
-
} : { background: stroke })) : {})) }))] }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
137
|
+
} })))] }))] }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
146
138
|
.video-wrapper-${item.id} {
|
|
147
139
|
position: absolute;
|
|
148
140
|
overflow: hidden;
|
|
@@ -202,21 +194,9 @@ const VideoItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityCha
|
|
|
202
194
|
}
|
|
203
195
|
.video-${item.id} {
|
|
204
196
|
border: solid;
|
|
205
|
-
border-color:
|
|
206
|
-
border-width: ${layoutParams.strokeWidth * 100}vw;
|
|
197
|
+
border-color: ${stroke};
|
|
207
198
|
border-radius: ${layoutParams.radius * 100}vw;
|
|
208
|
-
|
|
209
|
-
.video-border-${item.id} {
|
|
210
|
-
position: absolute;
|
|
211
|
-
inset: 0;
|
|
212
|
-
border-radius: inherit;
|
|
213
|
-
pointer-events: none;
|
|
214
|
-
z-index: 2;
|
|
215
|
-
-webkit-mask:
|
|
216
|
-
linear-gradient(#fff 0 0) content-box,
|
|
217
|
-
linear-gradient(#fff 0 0);
|
|
218
|
-
-webkit-mask-composite: xor;
|
|
219
|
-
mask-composite: exclude;
|
|
199
|
+
border-width: ${layoutParams.strokeWidth * 100}vw;
|
|
220
200
|
}
|
|
221
201
|
`);
|
|
222
202
|
})}
|
|
@@ -22,56 +22,45 @@ const RectangleItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilit
|
|
|
22
22
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
23
23
|
const { fill: itemFill, radius: itemRadius, strokeWidth: itemStrokeWidth, strokeFill: itemStrokeFill, blur: itemBlur, backdropBlur: itemBackdropBlur } = (0, useRectangleItem_1.useRectangleItem)(item, sectionId);
|
|
24
24
|
const itemAngle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
|
|
25
|
-
const stateParams = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['angle', 'strokeWidth', 'radius', 'blur', 'backdropBlur']);
|
|
25
|
+
const stateParams = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['angle', 'strokeWidth', 'radius', 'blur', 'backdropBlur', 'strokeFill']);
|
|
26
26
|
const stateFillParams = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['fill']);
|
|
27
27
|
const stateFillLayers = (_a = stateFillParams === null || stateFillParams === void 0 ? void 0 : stateFillParams.styles) === null || _a === void 0 ? void 0 : _a.fill;
|
|
28
28
|
const solidTransition = (_b = stateFillParams === null || stateFillParams === void 0 ? void 0 : stateFillParams.transition) !== null && _b !== void 0 ? _b : 'none';
|
|
29
|
-
const
|
|
30
|
-
const stateStrokeFillLayers = (_c = stateStrokeFillParams === null || stateStrokeFillParams === void 0 ? void 0 : stateStrokeFillParams.styles) === null || _c === void 0 ? void 0 : _c.strokeFill;
|
|
31
|
-
const strokeSolidTransition = (_d = stateStrokeFillParams === null || stateStrokeFillParams === void 0 ? void 0 : stateStrokeFillParams.transition) !== null && _d !== void 0 ? _d : 'none';
|
|
32
|
-
const styles = (_e = stateParams === null || stateParams === void 0 ? void 0 : stateParams.styles) !== null && _e !== void 0 ? _e : {};
|
|
29
|
+
const styles = (_c = stateParams === null || stateParams === void 0 ? void 0 : stateParams.styles) !== null && _c !== void 0 ? _c : {};
|
|
33
30
|
const layoutValues = [item.area, item.layoutParams];
|
|
34
31
|
const [ref, setRef] = (0, react_1.useState)(null);
|
|
35
32
|
(0, useRegisterResize_1.useRegisterResize)(ref, onResize);
|
|
36
33
|
const backdropBlur = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)(styles === null || styles === void 0 ? void 0 : styles.backdropBlur, itemBackdropBlur);
|
|
37
34
|
const radius = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)(styles === null || styles === void 0 ? void 0 : styles.radius, itemRadius);
|
|
38
35
|
const strokeWidth = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)(styles === null || styles === void 0 ? void 0 : styles.strokeWidth, itemStrokeWidth);
|
|
36
|
+
const strokeFill = (_e = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_d = styles === null || styles === void 0 ? void 0 : styles.strokeFill) === null || _d === void 0 ? void 0 : _d[0], itemStrokeFill === null || itemStrokeFill === void 0 ? void 0 : itemStrokeFill[0])) !== null && _e !== void 0 ? _e : itemStrokeFill === null || itemStrokeFill === void 0 ? void 0 : itemStrokeFill[0];
|
|
39
37
|
const angle = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)(styles === null || styles === void 0 ? void 0 : styles.angle, itemAngle);
|
|
40
38
|
const blur = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)(styles === null || styles === void 0 ? void 0 : styles.blur, itemBlur);
|
|
41
39
|
const backdropFilterValue = backdropBlur ? `blur(${backdropBlur * 100}vw)` : undefined;
|
|
42
|
-
const isInteractive = (0, areFillsVisible_1.areFillsVisible)((_f = stateFillLayers !== null && stateFillLayers !== void 0 ? stateFillLayers : itemFill) !== null && _f !== void 0 ? _f : []) || (strokeWidth !== 0 && (0, areFillsVisible_1.areFillsVisible)((_g =
|
|
40
|
+
const isInteractive = (0, areFillsVisible_1.areFillsVisible)((_f = stateFillLayers !== null && stateFillLayers !== void 0 ? stateFillLayers : itemFill) !== null && _f !== void 0 ? _f : []) || (strokeWidth !== 0 && (0, areFillsVisible_1.areFillsVisible)((_g = strokeFill !== null && strokeFill !== void 0 ? strokeFill : itemStrokeFill) !== null && _g !== void 0 ? _g : []));
|
|
43
41
|
(0, react_1.useEffect)(() => {
|
|
44
42
|
onVisibilityChange === null || onVisibilityChange === void 0 ? void 0 : onVisibilityChange(isInteractive);
|
|
45
43
|
}, [isInteractive, onVisibilityChange]);
|
|
46
|
-
const
|
|
47
|
-
? (0,
|
|
48
|
-
: itemStrokeFill === null || itemStrokeFill === void 0 ? void 0 : itemStrokeFill[0];
|
|
49
|
-
const stroke = strokeValue
|
|
50
|
-
? (_h = (0, getFill_1.getFill)(strokeValue)) !== null && _h !== void 0 ? _h : 'transparent'
|
|
44
|
+
const stroke = strokeFill
|
|
45
|
+
? (_h = (0, getFill_1.getFill)(strokeFill)) !== null && _h !== void 0 ? _h : 'transparent'
|
|
51
46
|
: 'transparent';
|
|
52
|
-
return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { url: (_j = item.link) === null || _j === void 0 ? void 0 : _j.url, target: (_k = item.link) === null || _k === void 0 ? void 0 : _k.target, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.
|
|
47
|
+
return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { url: (_j = item.link) === null || _j === void 0 ? void 0 : _j.url, target: (_k = item.link) === null || _k === void 0 ? void 0 : _k.target, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `rectangle-${item.id}`, ref: setRef, style: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (strokeFill ? Object.assign({ borderColor: stroke, borderWidth: strokeWidth !== undefined ? `${strokeWidth * 100}vw` : 0, borderRadius: radius !== undefined ? `${radius * 100}vw` : 'inherit', borderStyle: 'solid' }, (strokeFill.type === 'image' ? {
|
|
53
48
|
backgroundPosition: 'center',
|
|
54
|
-
backgroundSize:
|
|
55
|
-
backgroundRepeat:
|
|
49
|
+
backgroundSize: strokeFill.behavior === 'repeat' ? `${strokeFill.backgroundSize}%` : strokeFill.behavior,
|
|
50
|
+
backgroundRepeat: strokeFill.behavior === 'repeat' ? 'repeat' : 'no-repeat'
|
|
56
51
|
} : {})) : {})), (radius !== undefined ? { borderRadius: `${radius * 100}vw` } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), { willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset' }), (backdropFilterValue !== undefined
|
|
57
52
|
? { backdropFilter: backdropFilterValue, WebkitBackdropFilter: backdropFilterValue }
|
|
58
|
-
: {})), { transition: (_l = stateParams === null || stateParams === void 0 ? void 0 : stateParams.transition) !== null && _l !== void 0 ? _l : 'none' }), children:
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
: fill;
|
|
70
|
-
const background = value
|
|
71
|
-
? (_b = (0, getFill_1.getFill)(value)) !== null && _b !== void 0 ? _b : 'transparent'
|
|
72
|
-
: 'transparent';
|
|
73
|
-
return ((0, jsx_runtime_1.jsx)(Fill, { fill: value, itemId: item.id, background: background, solidTransition: solidTransition }));
|
|
74
|
-
})] }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
53
|
+
: {})), { transition: (_l = stateParams === null || stateParams === void 0 ? void 0 : stateParams.transition) !== null && _l !== void 0 ? _l : 'none' }), children: itemFill && itemFill.map((fill) => {
|
|
54
|
+
var _a, _b;
|
|
55
|
+
const stateFillLayer = stateFillLayers === null || stateFillLayers === void 0 ? void 0 : stateFillLayers.find((layer) => layer.id === fill.id);
|
|
56
|
+
const value = stateFillLayer
|
|
57
|
+
? ((_a = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)(stateFillLayer, fill)) !== null && _a !== void 0 ? _a : fill)
|
|
58
|
+
: fill;
|
|
59
|
+
const background = value
|
|
60
|
+
? (_b = (0, getFill_1.getFill)(value)) !== null && _b !== void 0 ? _b : 'transparent'
|
|
61
|
+
: 'transparent';
|
|
62
|
+
return ((0, jsx_runtime_1.jsx)(Fill, { fill: value, itemId: item.id, background: background, solidTransition: solidTransition, radius: radius, strokeWidth: strokeWidth }));
|
|
63
|
+
}) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
75
64
|
.rectangle-${item.id} {
|
|
76
65
|
position: absolute;
|
|
77
66
|
width: 100%;
|
|
@@ -97,25 +86,13 @@ const RectangleItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilit
|
|
|
97
86
|
${layoutParams.blur !== 0 ? 'will-change: transform;' : ''}
|
|
98
87
|
backdrop-filter: ${layoutParams.backdropBlur !== 0 ? `blur(${layoutParams.backdropBlur * 100}vw)` : 'unset'};
|
|
99
88
|
-webkit-backdrop-filter: ${layoutParams.backdropBlur !== 0 ? `blur(${layoutParams.backdropBlur * 100}vw)` : 'unset'};
|
|
100
|
-
},
|
|
101
|
-
.rectangle-border-${item.id} {
|
|
102
|
-
position: absolute;
|
|
103
|
-
inset: 0;
|
|
104
|
-
border-radius: inherit;
|
|
105
|
-
pointer-events: none;
|
|
106
|
-
z-index: 2;
|
|
107
|
-
-webkit-mask:
|
|
108
|
-
linear-gradient(#fff 0 0) content-box,
|
|
109
|
-
linear-gradient(#fff 0 0);
|
|
110
|
-
-webkit-mask-composite: xor;
|
|
111
|
-
mask-composite: exclude;
|
|
112
89
|
}
|
|
113
90
|
`);
|
|
114
91
|
})}
|
|
115
92
|
` })] }) }));
|
|
116
93
|
};
|
|
117
94
|
exports.RectangleItem = RectangleItem;
|
|
118
|
-
function Fill({ fill, itemId, background, solidTransition }) {
|
|
95
|
+
function Fill({ fill, itemId, background, solidTransition, radius, strokeWidth }) {
|
|
119
96
|
const isRotatedImage = fill.type === 'image' && fill.rotation && fill.rotation !== 0;
|
|
120
97
|
return ((0, jsx_runtime_1.jsx)("div", { className: fill.type === 'image' ? `image-fill-${itemId}` : `fill-${itemId}`, style: Object.assign(Object.assign(Object.assign(Object.assign({}, (fill.type === 'solid' ? { background, transition: solidTransition } : {})), (fill.type === 'image'
|
|
121
98
|
? {
|
|
@@ -125,6 +102,6 @@ function Fill({ fill, itemId, background, solidTransition }) {
|
|
|
125
102
|
backgroundRepeat: fill.behavior === 'repeat' ? 'repeat' : 'no-repeat',
|
|
126
103
|
opacity: fill.opacity
|
|
127
104
|
}
|
|
128
|
-
: { background })), { position: 'absolute',
|
|
105
|
+
: { background })), { position: 'absolute', mixBlendMode: fill.blendMode, borderRadius: `calc(${radius * 100}vw - ${strokeWidth * 100}vw)`, top: 0, left: 0, width: '100%', height: '100%', pointerEvents: 'none' }), (isRotatedImage ? { overflow: 'hidden' } : {})) }, fill.id));
|
|
129
106
|
}
|
|
130
107
|
;
|
package/package.json
CHANGED
|
@@ -29,7 +29,7 @@ export const VimeoEmbedItem: FC<ItemProps<TVimeoEmbedItem>> = ({ item, sectionId
|
|
|
29
29
|
const layoutParams = layoutId ? item.layoutParams[layoutId] : null;
|
|
30
30
|
const [ref, setRef] = useState<HTMLDivElement | null>(null);
|
|
31
31
|
const [imgRef, setImgRef] = useState<HTMLImageElement | null>(null);
|
|
32
|
-
const [isCoverVisible, setIsCoverVisible] = useState(
|
|
32
|
+
const [isCoverVisible, setIsCoverVisible] = useState(item.commonParams.coverUrl !== null);
|
|
33
33
|
const layoutValues: Record<string, any>[] = [item.area, item.layoutParams];
|
|
34
34
|
const wrapperStateParams = interactionCtrl?.getState<number>(['angle', 'blur', 'opacity']);
|
|
35
35
|
const frameStateParams = interactionCtrl?.getState<number>(['radius']);
|
|
@@ -58,6 +58,9 @@ export const VimeoEmbedItem: FC<ItemProps<TVimeoEmbedItem>> = ({ item, sectionId
|
|
|
58
58
|
if (layoutParams.play === 'on-click') {
|
|
59
59
|
setIsCoverVisible(true);
|
|
60
60
|
}
|
|
61
|
+
if (layoutParams.play === 'auto') {
|
|
62
|
+
setIsCoverVisible(false);
|
|
63
|
+
}
|
|
61
64
|
vimeoPlayer.on('pause', (e) => {
|
|
62
65
|
if (e.seconds === 0) {
|
|
63
66
|
setIsCoverVisible(true);
|
|
@@ -121,7 +124,7 @@ export const VimeoEmbedItem: FC<ItemProps<TVimeoEmbedItem>> = ({ item, sectionId
|
|
|
121
124
|
transition: wrapperStateParams?.transition ?? 'none'
|
|
122
125
|
}}
|
|
123
126
|
onMouseEnter={() => {
|
|
124
|
-
if (!vimeoPlayer || !layoutParams || layoutParams.play !== 'on-hover') return;
|
|
127
|
+
if (!vimeoPlayer || !layoutParams || layoutParams.play !== 'on-hover' || isCoverVisible) return;
|
|
125
128
|
vimeoPlayer.play();
|
|
126
129
|
}}
|
|
127
130
|
onMouseLeave={() => {
|
|
@@ -132,7 +135,12 @@ export const VimeoEmbedItem: FC<ItemProps<TVimeoEmbedItem>> = ({ item, sectionId
|
|
|
132
135
|
{item.commonParams.coverUrl && (
|
|
133
136
|
<img
|
|
134
137
|
ref={setImgRef}
|
|
135
|
-
|
|
138
|
+
{...(layoutParams?.play === 'on-click' ? { onClick: () => onCoverClick() } : {})}
|
|
139
|
+
{...(layoutParams?.play === 'on-hover' ? { onMouseEnter: () => {
|
|
140
|
+
if (!vimeoPlayer || !layoutParams || layoutParams.play !== 'on-hover') return;
|
|
141
|
+
setIsCoverVisible(false);
|
|
142
|
+
vimeoPlayer.play();
|
|
143
|
+
} } : {})}
|
|
136
144
|
src={item.commonParams.coverUrl ?? ''}
|
|
137
145
|
style={{
|
|
138
146
|
display: isCoverVisible ? 'block' : 'none',
|
|
@@ -24,7 +24,7 @@ export const YoutubeEmbedItem: FC<ItemProps<TYoutubeEmbedItem>> = ({ item, secti
|
|
|
24
24
|
const YT = useYouTubeIframeApi();
|
|
25
25
|
const [div, setDiv] = useState<HTMLDivElement | null>(null);
|
|
26
26
|
const [player, setPlayer] = useState<YTPlayer | undefined>(undefined);
|
|
27
|
-
const [isCoverVisible, setIsCoverVisible] = useState(
|
|
27
|
+
const [isCoverVisible, setIsCoverVisible] = useState(item.commonParams.coverUrl !== null);
|
|
28
28
|
const [imgRef, setImgRef] = useState<HTMLImageElement | null>(null);
|
|
29
29
|
const layoutValues: Record<string, any>[] = [item.area, item.layoutParams];
|
|
30
30
|
const wrapperStateParams = interactionCtrl?.getState<number>(['angle', 'blur', 'opacity']);
|
|
@@ -114,7 +114,7 @@ export const YoutubeEmbedItem: FC<ItemProps<TYoutubeEmbedItem>> = ({ item, secti
|
|
|
114
114
|
<div
|
|
115
115
|
className={`embed-youtube-video-wrapper-${item.id}`}
|
|
116
116
|
onMouseEnter={() => {
|
|
117
|
-
if (!player || !layoutParams || layoutParams.play !== 'on-hover') return;
|
|
117
|
+
if (!player || !layoutParams || layoutParams.play !== 'on-hover' || isCoverVisible) return;
|
|
118
118
|
player.playVideo();
|
|
119
119
|
}}
|
|
120
120
|
onMouseLeave={() => {
|
|
@@ -132,7 +132,12 @@ export const YoutubeEmbedItem: FC<ItemProps<TYoutubeEmbedItem>> = ({ item, secti
|
|
|
132
132
|
{item.commonParams.coverUrl && (
|
|
133
133
|
<img
|
|
134
134
|
ref={setImgRef}
|
|
135
|
-
|
|
135
|
+
{...(layoutParams?.play === 'on-click' ? { onClick: () => onCoverClick() } : {})}
|
|
136
|
+
{...(layoutParams?.play === 'on-hover' ? { onMouseEnter: () => {
|
|
137
|
+
if (!player || !layoutParams || layoutParams.play !== 'on-hover') return;
|
|
138
|
+
setIsCoverVisible(false);
|
|
139
|
+
player.playVideo();
|
|
140
|
+
} } : {})}
|
|
136
141
|
src={item.commonParams.coverUrl ?? ''}
|
|
137
142
|
style={{
|
|
138
143
|
display: isCoverVisible ? 'block' : 'none',
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { FC, useEffect, useId,
|
|
1
|
+
import { FC, useEffect, useId, useRef, useState } from 'react';
|
|
2
2
|
import JSXStyle from 'styled-jsx/style';
|
|
3
|
-
import {
|
|
4
|
-
import { getLayoutStyles, ImageItem as TImageItem, FillLayer } from '@cntrl-site/sdk';
|
|
3
|
+
import { getLayoutStyles, ImageItem as TImageItem } from '@cntrl-site/sdk';
|
|
5
4
|
import { ItemProps } from '../Item';
|
|
6
5
|
import { LinkWrapper } from '../LinkWrapper';
|
|
7
6
|
import { useFileItem } from './useFileItem';
|
|
@@ -40,11 +39,7 @@ export const ImageItem: FC<ItemProps<TImageItem>> = ({ item, sectionId, onResize
|
|
|
40
39
|
const width = area && exemplary ? area.width * exemplary : 0;
|
|
41
40
|
const height = area && exemplary ? area.height * exemplary : 0;
|
|
42
41
|
const wrapperStateParams = interactionCtrl?.getState<number>(['angle', 'opacity', 'blur']);
|
|
43
|
-
const imgStateParams = interactionCtrl?.getState<
|
|
44
|
-
const stateStrokeFillParams = interactionCtrl?.getState<FillLayer[]>(['strokeFill']);
|
|
45
|
-
const stateStrokeFillLayers = stateStrokeFillParams?.styles?.strokeFill;
|
|
46
|
-
const strokeSolidTransition = stateStrokeFillParams?.transition ?? 'none';
|
|
47
|
-
|
|
42
|
+
const imgStateParams = interactionCtrl?.getState<any>(['strokeWidth', 'radius', 'strokeFill']);
|
|
48
43
|
useEffect(() => {
|
|
49
44
|
isInitialRef.current = false;
|
|
50
45
|
}, []);
|
|
@@ -64,19 +59,22 @@ export const ImageItem: FC<ItemProps<TImageItem>> = ({ item, sectionId, onResize
|
|
|
64
59
|
const rectHeight = Math.floor(rect?.height ?? 0);
|
|
65
60
|
const radius = getStyleFromItemStateAndParams(imgStateParams?.styles?.radius, itemRadius);
|
|
66
61
|
const strokeWidth = getStyleFromItemStateAndParams(imgStateParams?.styles?.strokeWidth, itemStrokeWidth);
|
|
62
|
+
const strokeFill = getStyleFromItemStateAndParams(imgStateParams?.styles?.strokeFill?.[0], itemStrokeFill?.[0]) ?? itemStrokeFill?.[0];
|
|
67
63
|
const angle = getStyleFromItemStateAndParams(wrapperStateParams?.styles?.angle, itemAngle);
|
|
68
64
|
const opacity = getStyleFromItemStateAndParams(wrapperStateParams?.styles?.opacity, itemOpacity);
|
|
69
65
|
const blur = getStyleFromItemStateAndParams(wrapperStateParams?.styles?.blur, itemBlur);
|
|
70
66
|
|
|
71
|
-
const
|
|
72
|
-
?
|
|
73
|
-
: itemStrokeFill?.[0];
|
|
74
|
-
const stroke = strokeValue
|
|
75
|
-
? getFill(strokeValue) ?? 'transparent'
|
|
67
|
+
const stroke = strokeFill
|
|
68
|
+
? getFill(strokeFill) ?? 'transparent'
|
|
76
69
|
: 'transparent';
|
|
77
70
|
const inlineStyles = {
|
|
78
71
|
...(radius !== undefined ? { borderRadius: `${radius * 100}vw` } : {}),
|
|
79
|
-
...(strokeWidth !== undefined ? {
|
|
72
|
+
...(strokeWidth !== undefined ? {
|
|
73
|
+
borderColor: stroke,
|
|
74
|
+
borderWidth: `${strokeWidth * 100}vw`,
|
|
75
|
+
borderRadius: radius !== undefined ? `${radius * 100}vw` : 'inherit',
|
|
76
|
+
borderStyle: 'solid',
|
|
77
|
+
} : {}),
|
|
80
78
|
transition: imgStateParams?.transition ?? 'none'
|
|
81
79
|
};
|
|
82
80
|
const isInteractive = opacity !== 0;
|
|
@@ -93,14 +91,6 @@ export const ImageItem: FC<ItemProps<TImageItem>> = ({ item, sectionId, onResize
|
|
|
93
91
|
...(opacity !== undefined ? { opacity } : {}),
|
|
94
92
|
...(angle !== undefined ? { transform: `rotate(${angle}deg)` } : {}),
|
|
95
93
|
...(blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {}),
|
|
96
|
-
...(strokeValue ? {
|
|
97
|
-
'--stroke-background': stroke,
|
|
98
|
-
...(strokeValue.type === 'image' ? {
|
|
99
|
-
'--stroke-background-position': 'center',
|
|
100
|
-
'--stroke-background-size': strokeValue.behavior === 'repeat' ? `${strokeValue.backgroundSize}%` : strokeValue.behavior,
|
|
101
|
-
'--stroke-background-repeat': strokeValue.behavior === 'repeat' ? 'repeat' : 'no-repeat'
|
|
102
|
-
} : {})
|
|
103
|
-
} : {}),
|
|
104
94
|
willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset',
|
|
105
95
|
transition: wrapperStateParams?.transition ?? 'none'
|
|
106
96
|
}}
|
|
@@ -123,30 +113,6 @@ export const ImageItem: FC<ItemProps<TImageItem>> = ({ item, sectionId, onResize
|
|
|
123
113
|
src={item.commonParams.url}
|
|
124
114
|
/>
|
|
125
115
|
)}
|
|
126
|
-
{strokeWidth !== 0 && strokeValue && (
|
|
127
|
-
<div
|
|
128
|
-
className={`image-border-${item.id}`}
|
|
129
|
-
style={{
|
|
130
|
-
position: 'absolute',
|
|
131
|
-
inset: 0,
|
|
132
|
-
borderRadius: 'inherit',
|
|
133
|
-
pointerEvents: 'none',
|
|
134
|
-
zIndex: 2,
|
|
135
|
-
WebkitMask: 'linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)',
|
|
136
|
-
WebkitMaskComposite: 'xor',
|
|
137
|
-
maskComposite: 'exclude',
|
|
138
|
-
...(strokeWidth !== 0 && strokeValue ? {
|
|
139
|
-
...(strokeWidth ? { padding: `${strokeWidth * 100}vw` } : {}),
|
|
140
|
-
...(strokeValue.type === 'solid' ? { transition: strokeSolidTransition, background: stroke } : {}),
|
|
141
|
-
...(strokeValue.type === 'image' ? {
|
|
142
|
-
backgroundPosition: 'center',
|
|
143
|
-
backgroundSize: strokeValue.behavior === 'repeat' ? `${strokeValue.backgroundSize}%` : strokeValue.behavior,
|
|
144
|
-
backgroundRepeat: strokeValue.behavior === 'repeat' ? 'repeat' : 'no-repeat'
|
|
145
|
-
} : { background: stroke })
|
|
146
|
-
} : {}),
|
|
147
|
-
}}
|
|
148
|
-
/>
|
|
149
|
-
)}
|
|
150
116
|
</div>
|
|
151
117
|
<JSXStyle id={id}>{`
|
|
152
118
|
.image-wrapper-${item.id} {
|
|
@@ -184,21 +150,9 @@ export const ImageItem: FC<ItemProps<TImageItem>> = ({ item, sectionId, onResize
|
|
|
184
150
|
}
|
|
185
151
|
.image-${item.id} {
|
|
186
152
|
border: solid;
|
|
187
|
-
border-color:
|
|
188
|
-
border-width: ${layoutParams.strokeWidth * 100}vw;
|
|
153
|
+
border-color: ${stroke};
|
|
189
154
|
border-radius: ${layoutParams.radius * 100}vw;
|
|
190
|
-
|
|
191
|
-
.image-border-${item.id} {
|
|
192
|
-
position: absolute;
|
|
193
|
-
inset: 0;
|
|
194
|
-
border-radius: inherit;
|
|
195
|
-
pointer-events: none;
|
|
196
|
-
z-index: 2;
|
|
197
|
-
-webkit-mask:
|
|
198
|
-
linear-gradient(#fff 0 0) content-box,
|
|
199
|
-
linear-gradient(#fff 0 0);
|
|
200
|
-
-webkit-mask-composite: xor;
|
|
201
|
-
mask-composite: exclude;
|
|
155
|
+
border-width: ${layoutParams.strokeWidth * 100}vw;
|
|
202
156
|
}
|
|
203
157
|
`);
|
|
204
158
|
})}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { FC, useEffect, useId,
|
|
1
|
+
import { FC, useEffect, useId, useRef, useState } from 'react';
|
|
2
2
|
import JSXStyle from 'styled-jsx/style';
|
|
3
|
-
import {
|
|
4
|
-
import { getLayoutStyles, VideoItem as TVideoItem, FillLayer } from '@cntrl-site/sdk';
|
|
3
|
+
import { getLayoutStyles, VideoItem as TVideoItem } from '@cntrl-site/sdk';
|
|
5
4
|
import { ItemProps } from '../Item';
|
|
6
5
|
import { LinkWrapper } from '../LinkWrapper';
|
|
7
6
|
import { useFileItem } from './useFileItem';
|
|
@@ -50,21 +49,15 @@ export const VideoItem: FC<ItemProps<TVideoItem>> = ({ item, sectionId, onResize
|
|
|
50
49
|
const layoutValues: Record<string, any>[] = [item.area, item.layoutParams];
|
|
51
50
|
const hasScrollPlayback = scrollPlayback !== null;
|
|
52
51
|
const wrapperStateParams = interactionCtrl?.getState<number>(['angle', 'opacity', 'blur']);
|
|
53
|
-
const videoStateParams = interactionCtrl?.getState<
|
|
54
|
-
const stateStrokeFillParams = interactionCtrl?.getState<FillLayer[]>(['strokeFill']);
|
|
55
|
-
const stateStrokeFillLayers = stateStrokeFillParams?.styles?.strokeFill;
|
|
56
|
-
const strokeSolidTransition = stateStrokeFillParams?.transition ?? 'none';
|
|
52
|
+
const videoStateParams = interactionCtrl?.getState<any>(['strokeWidth', 'radius', 'strokeFill']);
|
|
57
53
|
const angle = getStyleFromItemStateAndParams(wrapperStateParams?.styles?.angle, itemAngle);
|
|
58
54
|
const opacity = getStyleFromItemStateAndParams(wrapperStateParams?.styles?.opacity, itemOpacity);
|
|
59
55
|
const blur = getStyleFromItemStateAndParams(wrapperStateParams?.styles?.blur, itemBlur);
|
|
60
56
|
const strokeWidth = getStyleFromItemStateAndParams(wrapperStateParams?.styles?.strokeWidth, itemStrokeWidth);
|
|
61
57
|
const radius = getStyleFromItemStateAndParams(wrapperStateParams?.styles?.radius, itemRadius);
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
?
|
|
65
|
-
: itemStrokeFill?.[0];
|
|
66
|
-
const stroke = strokeValue
|
|
67
|
-
? getFill(strokeValue) ?? 'transparent'
|
|
58
|
+
const strokeFill = getStyleFromItemStateAndParams(videoStateParams?.styles?.strokeFill?.[0], itemStrokeFill?.[0]) ?? itemStrokeFill?.[0];
|
|
59
|
+
const stroke = strokeFill
|
|
60
|
+
? getFill(strokeFill) ?? 'transparent'
|
|
68
61
|
: 'transparent';
|
|
69
62
|
useEffect(() => {
|
|
70
63
|
isInitialRef.current = false;
|
|
@@ -83,7 +76,12 @@ export const VideoItem: FC<ItemProps<TVideoItem>> = ({ item, sectionId, onResize
|
|
|
83
76
|
useRegisterResize(ref, onResize);
|
|
84
77
|
const inlineStyles = {
|
|
85
78
|
...(radius !== undefined ? { borderRadius: `${radius * 100}vw` } : {}),
|
|
86
|
-
...(strokeWidth !== undefined ? {
|
|
79
|
+
...(strokeWidth !== undefined ? {
|
|
80
|
+
borderWidth: `${strokeWidth * 100}vw`,
|
|
81
|
+
borderColor: stroke,
|
|
82
|
+
borderRadius: radius !== undefined ? `${radius * 100}vw` : 'inherit',
|
|
83
|
+
borderStyle: 'solid'
|
|
84
|
+
} : {}),
|
|
87
85
|
transition: videoStateParams?.transition ?? 'none'
|
|
88
86
|
};
|
|
89
87
|
const isInteractive = opacity !== 0;
|
|
@@ -118,14 +116,6 @@ export const VideoItem: FC<ItemProps<TVideoItem>> = ({ item, sectionId, onResize
|
|
|
118
116
|
...(opacity !== undefined ? { opacity } : {}),
|
|
119
117
|
...(angle !== undefined ? { transform: `rotate(${angle}deg)` } : {}),
|
|
120
118
|
...(blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {}),
|
|
121
|
-
...(strokeValue ? {
|
|
122
|
-
'--stroke-background': stroke,
|
|
123
|
-
...(strokeValue.type === 'image' ? {
|
|
124
|
-
'--stroke-background-position': 'center',
|
|
125
|
-
'--stroke-background-size': strokeValue.behavior === 'repeat' ? `${strokeValue.backgroundSize}%` : strokeValue.behavior,
|
|
126
|
-
'--stroke-background-repeat': strokeValue.behavior === 'repeat' ? 'repeat' : 'no-repeat'
|
|
127
|
-
} : {})
|
|
128
|
-
} : {}),
|
|
129
119
|
willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset',
|
|
130
120
|
transition: wrapperStateParams?.transition ?? 'none'
|
|
131
121
|
}}
|
|
@@ -217,30 +207,6 @@ export const VideoItem: FC<ItemProps<TVideoItem>> = ({ item, sectionId, onResize
|
|
|
217
207
|
))}
|
|
218
208
|
</>
|
|
219
209
|
)}
|
|
220
|
-
{strokeWidth !== 0 && strokeValue && (
|
|
221
|
-
<div
|
|
222
|
-
className={`video-border-${item.id}`}
|
|
223
|
-
style={{
|
|
224
|
-
position: 'absolute',
|
|
225
|
-
inset: 0,
|
|
226
|
-
borderRadius: 'inherit',
|
|
227
|
-
pointerEvents: 'none',
|
|
228
|
-
zIndex: 2,
|
|
229
|
-
WebkitMask: 'linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)',
|
|
230
|
-
WebkitMaskComposite: 'xor',
|
|
231
|
-
maskComposite: 'exclude',
|
|
232
|
-
...(strokeWidth !== 0 && strokeValue ? {
|
|
233
|
-
...(strokeWidth ? { padding: `${strokeWidth * 100}vw` } : {}),
|
|
234
|
-
...(strokeValue.type === 'solid' ? { transition: strokeSolidTransition, background: stroke } : {}),
|
|
235
|
-
...(strokeValue.type === 'image' ? {
|
|
236
|
-
backgroundPosition: 'center',
|
|
237
|
-
backgroundSize: strokeValue.behavior === 'repeat' ? `${strokeValue.backgroundSize}%` : strokeValue.behavior,
|
|
238
|
-
backgroundRepeat: strokeValue.behavior === 'repeat' ? 'repeat' : 'no-repeat'
|
|
239
|
-
} : { background: stroke })
|
|
240
|
-
} : {}),
|
|
241
|
-
}}
|
|
242
|
-
/>
|
|
243
|
-
)}
|
|
244
210
|
</div>
|
|
245
211
|
<JSXStyle id={id}>{`
|
|
246
212
|
.video-wrapper-${item.id} {
|
|
@@ -302,21 +268,9 @@ export const VideoItem: FC<ItemProps<TVideoItem>> = ({ item, sectionId, onResize
|
|
|
302
268
|
}
|
|
303
269
|
.video-${item.id} {
|
|
304
270
|
border: solid;
|
|
305
|
-
border-color:
|
|
306
|
-
border-width: ${layoutParams.strokeWidth * 100}vw;
|
|
271
|
+
border-color: ${stroke};
|
|
307
272
|
border-radius: ${layoutParams.radius * 100}vw;
|
|
308
|
-
|
|
309
|
-
.video-border-${item.id} {
|
|
310
|
-
position: absolute;
|
|
311
|
-
inset: 0;
|
|
312
|
-
border-radius: inherit;
|
|
313
|
-
pointer-events: none;
|
|
314
|
-
z-index: 2;
|
|
315
|
-
-webkit-mask:
|
|
316
|
-
linear-gradient(#fff 0 0) content-box,
|
|
317
|
-
linear-gradient(#fff 0 0);
|
|
318
|
-
-webkit-mask-composite: xor;
|
|
319
|
-
mask-composite: exclude;
|
|
273
|
+
border-width: ${layoutParams.strokeWidth * 100}vw;
|
|
320
274
|
}
|
|
321
275
|
`);
|
|
322
276
|
})}
|
|
@@ -163,7 +163,7 @@ export const Item: FC<ItemWrapperProps> = ({ item, sectionId, articleHeight, isP
|
|
|
163
163
|
className={`item-${item.id}`}
|
|
164
164
|
style={{
|
|
165
165
|
opacity: (keyframes.length !== 0 && !layout) ? 0 : 1,
|
|
166
|
-
top: sticky ?getAnchoredItemTop(stickyTop, sectionHeight, anchorSide) : 0,
|
|
166
|
+
top: sticky ? getAnchoredItemTop(stickyTop, sectionHeight, anchorSide) : 0,
|
|
167
167
|
height: isRichText && itemHeight !== undefined ? `${itemHeight * 100}vw` : 'unset'
|
|
168
168
|
}}
|
|
169
169
|
>
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { FC, useEffect, useId,
|
|
1
|
+
import { FC, useEffect, useId, useState } from 'react';
|
|
2
2
|
import JSXStyle from 'styled-jsx/style';
|
|
3
|
-
import { CntrlColor } from '@cntrl-site/color';
|
|
4
3
|
import { RectangleItem as TRectangleItem, getLayoutStyles, FillLayer } from '@cntrl-site/sdk';
|
|
5
4
|
import { ItemProps } from '../Item';
|
|
6
5
|
import { LinkWrapper } from '../LinkWrapper';
|
|
@@ -24,13 +23,10 @@ export const RectangleItem: FC<ItemProps<TRectangleItem>> = ({ item, sectionId,
|
|
|
24
23
|
backdropBlur: itemBackdropBlur
|
|
25
24
|
} = useRectangleItem(item, sectionId);
|
|
26
25
|
const itemAngle = useItemAngle(item, sectionId);
|
|
27
|
-
const stateParams = interactionCtrl?.getState<
|
|
26
|
+
const stateParams = interactionCtrl?.getState<any>(['angle', 'strokeWidth', 'radius', 'blur', 'backdropBlur', 'strokeFill']);
|
|
28
27
|
const stateFillParams = interactionCtrl?.getState<FillLayer[]>(['fill']);
|
|
29
28
|
const stateFillLayers = stateFillParams?.styles?.fill;
|
|
30
29
|
const solidTransition = stateFillParams?.transition ?? 'none';
|
|
31
|
-
const stateStrokeFillParams = interactionCtrl?.getState<FillLayer[]>(['strokeFill']);
|
|
32
|
-
const stateStrokeFillLayers = stateStrokeFillParams?.styles?.strokeFill;
|
|
33
|
-
const strokeSolidTransition = stateStrokeFillParams?.transition ?? 'none';
|
|
34
30
|
const styles = stateParams?.styles ?? {};
|
|
35
31
|
const layoutValues: Record<string, any>[] = [item.area, item.layoutParams];
|
|
36
32
|
const [ref, setRef] = useState<HTMLDivElement | null>(null);
|
|
@@ -38,19 +34,17 @@ export const RectangleItem: FC<ItemProps<TRectangleItem>> = ({ item, sectionId,
|
|
|
38
34
|
const backdropBlur = getStyleFromItemStateAndParams(styles?.backdropBlur, itemBackdropBlur);
|
|
39
35
|
const radius = getStyleFromItemStateAndParams(styles?.radius, itemRadius);
|
|
40
36
|
const strokeWidth = getStyleFromItemStateAndParams(styles?.strokeWidth, itemStrokeWidth);
|
|
37
|
+
const strokeFill = getStyleFromItemStateAndParams(styles?.strokeFill?.[0], itemStrokeFill?.[0]) ?? itemStrokeFill?.[0];
|
|
41
38
|
const angle = getStyleFromItemStateAndParams(styles?.angle, itemAngle);
|
|
42
39
|
const blur = getStyleFromItemStateAndParams(styles?.blur, itemBlur);
|
|
43
40
|
const backdropFilterValue = backdropBlur ? `blur(${backdropBlur * 100}vw)` : undefined;
|
|
44
|
-
const isInteractive = areFillsVisible(stateFillLayers ?? itemFill ?? []) || (strokeWidth !== 0 && areFillsVisible(
|
|
41
|
+
const isInteractive = areFillsVisible(stateFillLayers ?? itemFill ?? []) || (strokeWidth !== 0 && areFillsVisible(strokeFill ?? itemStrokeFill ?? []));
|
|
45
42
|
useEffect(() => {
|
|
46
43
|
onVisibilityChange?.(isInteractive);
|
|
47
44
|
}, [isInteractive, onVisibilityChange]);
|
|
48
45
|
|
|
49
|
-
const
|
|
50
|
-
?
|
|
51
|
-
: itemStrokeFill?.[0];
|
|
52
|
-
const stroke = strokeValue
|
|
53
|
-
? getFill(strokeValue) ?? 'transparent'
|
|
46
|
+
const stroke = strokeFill
|
|
47
|
+
? getFill(strokeFill) ?? 'transparent'
|
|
54
48
|
: 'transparent';
|
|
55
49
|
|
|
56
50
|
return (
|
|
@@ -60,12 +54,15 @@ export const RectangleItem: FC<ItemProps<TRectangleItem>> = ({ item, sectionId,
|
|
|
60
54
|
className={`rectangle-${item.id}`}
|
|
61
55
|
ref={setRef}
|
|
62
56
|
style={{
|
|
63
|
-
...(
|
|
64
|
-
|
|
65
|
-
|
|
57
|
+
...(strokeFill ? {
|
|
58
|
+
borderColor: stroke,
|
|
59
|
+
borderWidth: strokeWidth !== undefined ? `${strokeWidth * 100}vw` : 0,
|
|
60
|
+
borderRadius: radius !== undefined ? `${radius * 100}vw` : 'inherit',
|
|
61
|
+
borderStyle: 'solid',
|
|
62
|
+
...(strokeFill.type === 'image' ? {
|
|
66
63
|
backgroundPosition: 'center',
|
|
67
|
-
backgroundSize:
|
|
68
|
-
backgroundRepeat:
|
|
64
|
+
backgroundSize: strokeFill.behavior === 'repeat' ? `${strokeFill.backgroundSize}%` : strokeFill.behavior,
|
|
65
|
+
backgroundRepeat: strokeFill.behavior === 'repeat' ? 'repeat' : 'no-repeat'
|
|
69
66
|
} : {})
|
|
70
67
|
} : {}),
|
|
71
68
|
...(radius !== undefined ? { borderRadius: `${radius * 100}vw` } : {}),
|
|
@@ -79,31 +76,6 @@ export const RectangleItem: FC<ItemProps<TRectangleItem>> = ({ item, sectionId,
|
|
|
79
76
|
transition: stateParams?.transition ?? 'none'
|
|
80
77
|
}}
|
|
81
78
|
>
|
|
82
|
-
<div
|
|
83
|
-
className={`rectangle-border-${item.id}`}
|
|
84
|
-
style={{
|
|
85
|
-
position: 'absolute',
|
|
86
|
-
inset: 0,
|
|
87
|
-
borderRadius: 'inherit',
|
|
88
|
-
pointerEvents: 'none',
|
|
89
|
-
zIndex: 2,
|
|
90
|
-
WebkitMask: 'linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)',
|
|
91
|
-
WebkitMaskComposite: 'xor',
|
|
92
|
-
maskComposite: 'exclude',
|
|
93
|
-
...(strokeWidth !== 0 && strokeValue ? {
|
|
94
|
-
...(strokeWidth ? { padding: `${strokeWidth * 100}vw` } : {}),
|
|
95
|
-
...(strokeValue.type === 'solid' ? { transition: strokeSolidTransition, background: stroke } : {}),
|
|
96
|
-
...(strokeValue.type === 'image' ? {
|
|
97
|
-
backgroundPosition: 'center',
|
|
98
|
-
backgroundSize: strokeValue.behavior === 'repeat' ? `${strokeValue.backgroundSize}%` : strokeValue.behavior,
|
|
99
|
-
backgroundRepeat: strokeValue.behavior === 'repeat' ? 'repeat' : 'no-repeat'
|
|
100
|
-
} : {
|
|
101
|
-
background: stroke,
|
|
102
|
-
}
|
|
103
|
-
)
|
|
104
|
-
} : { background: stroke }),
|
|
105
|
-
}}
|
|
106
|
-
/>
|
|
107
79
|
{itemFill && itemFill.map((fill) => {
|
|
108
80
|
const stateFillLayer = stateFillLayers?.find((layer) => layer.id === fill.id);
|
|
109
81
|
const value = stateFillLayer
|
|
@@ -114,7 +86,14 @@ export const RectangleItem: FC<ItemProps<TRectangleItem>> = ({ item, sectionId,
|
|
|
114
86
|
: 'transparent';
|
|
115
87
|
|
|
116
88
|
return (
|
|
117
|
-
<Fill
|
|
89
|
+
<Fill
|
|
90
|
+
fill={value}
|
|
91
|
+
itemId={item.id}
|
|
92
|
+
background={background}
|
|
93
|
+
solidTransition={solidTransition}
|
|
94
|
+
radius={radius}
|
|
95
|
+
strokeWidth={strokeWidth}
|
|
96
|
+
/>
|
|
118
97
|
);
|
|
119
98
|
})}
|
|
120
99
|
</div>
|
|
@@ -144,18 +123,6 @@ export const RectangleItem: FC<ItemProps<TRectangleItem>> = ({ item, sectionId,
|
|
|
144
123
|
${layoutParams.blur !== 0 ? 'will-change: transform;' : ''}
|
|
145
124
|
backdrop-filter: ${layoutParams.backdropBlur !== 0 ? `blur(${layoutParams.backdropBlur * 100}vw)` : 'unset'};
|
|
146
125
|
-webkit-backdrop-filter: ${layoutParams.backdropBlur !== 0 ? `blur(${layoutParams.backdropBlur * 100}vw)` : 'unset'};
|
|
147
|
-
},
|
|
148
|
-
.rectangle-border-${item.id} {
|
|
149
|
-
position: absolute;
|
|
150
|
-
inset: 0;
|
|
151
|
-
border-radius: inherit;
|
|
152
|
-
pointer-events: none;
|
|
153
|
-
z-index: 2;
|
|
154
|
-
-webkit-mask:
|
|
155
|
-
linear-gradient(#fff 0 0) content-box,
|
|
156
|
-
linear-gradient(#fff 0 0);
|
|
157
|
-
-webkit-mask-composite: xor;
|
|
158
|
-
mask-composite: exclude;
|
|
159
126
|
}
|
|
160
127
|
`);
|
|
161
128
|
})}
|
|
@@ -165,7 +132,7 @@ export const RectangleItem: FC<ItemProps<TRectangleItem>> = ({ item, sectionId,
|
|
|
165
132
|
);
|
|
166
133
|
};
|
|
167
134
|
|
|
168
|
-
function Fill({ fill, itemId, background, solidTransition }: { fill: FillLayer; itemId: string; background: string; solidTransition: string; }) {
|
|
135
|
+
function Fill({ fill, itemId, background, solidTransition, radius, strokeWidth }: { fill: FillLayer; itemId: string; background: string; solidTransition: string; radius: number; strokeWidth: number; }) {
|
|
169
136
|
const isRotatedImage = fill.type === 'image' && fill.rotation && fill.rotation !== 0;
|
|
170
137
|
|
|
171
138
|
return (
|
|
@@ -184,8 +151,8 @@ function Fill({ fill, itemId, background, solidTransition }: { fill: FillLayer;
|
|
|
184
151
|
}
|
|
185
152
|
: { background }),
|
|
186
153
|
position: 'absolute',
|
|
187
|
-
borderRadius: 'inherit',
|
|
188
154
|
mixBlendMode: fill.blendMode as any,
|
|
155
|
+
borderRadius: `calc(${radius * 100}vw - ${strokeWidth * 100}vw)`,
|
|
189
156
|
top: 0,
|
|
190
157
|
left: 0,
|
|
191
158
|
width: '100%',
|
|
Binary file
|