@cntrl-site/sdk-nextjs 1.8.40-alpha.0 → 1.8.40
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/components/items/FileItem/ImageItem.js +22 -46
- package/lib/components/items/FileItem/VideoItem.js +21 -45
- package/lib/components/items/FileItem/useFileItem.js +5 -12
- package/lib/components/items/RectangleItem/RectangleItem.js +22 -78
- package/lib/components/items/RectangleItem/useRectangleItem.js +8 -15
- package/lib/interactions/CSSPropertyNameMap.js +18 -18
- package/lib/utils/Animator/Animator.js +19 -171
- package/package.json +2 -2
- package/src/components/items/CodeEmbedItem/CodeEmbedItem.tsx +1 -1
- package/src/components/items/ComponentItem/ComponentItem.tsx +1 -1
- package/src/components/items/CompoundItem/CompoundChild.tsx +2 -2
- package/src/components/items/CompoundItem/CompoundItem.tsx +1 -1
- package/src/components/items/CustomItem/CustomItem.tsx +1 -1
- package/src/components/items/EmbedVideoItem/VimeoEmbed.tsx +2 -2
- package/src/components/items/EmbedVideoItem/YoutubeEmbed.tsx +2 -2
- package/src/components/items/FileItem/ImageItem.tsx +11 -60
- package/src/components/items/FileItem/VideoItem.tsx +12 -61
- package/src/components/items/FileItem/useFileItem.ts +6 -14
- package/src/components/items/GroupItem/GroupItem.tsx +1 -1
- package/src/components/items/Item.tsx +2 -2
- package/src/components/items/RectangleItem/RectangleItem.tsx +24 -126
- package/src/components/items/RectangleItem/useRectangleItem.ts +10 -17
- package/src/components/items/RichTextItem/RichTextItem.tsx +5 -5
- package/src/interactions/CSSPropertyNameMap.ts +19 -18
- package/src/interactions/ItemInteractionCtrl.ts +4 -4
- package/src/interactions/types.ts +7 -7
- package/src/provider/InteractionsContext.old.tsx +66 -0
- package/src/provider/InteractionsContext.test.tsx +97 -0
- package/src/utils/Animator/Animator.ts +27 -227
- package/src/utils/getStyleFromItemStateAndParams.ts +2 -2
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/modules.xml +0 -8
- package/.idea/sdk-nextjs.iml +0 -12
- package/.idea/vcs.xml +0 -6
- package/lib/utils/areFillsVisible/areFillsVisible.js +0 -23
- package/lib/utils/getFill.js +0 -43
- package/src/utils/areFillsVisible/areFillsVisible.test.ts +0 -63
- package/src/utils/areFillsVisible/areFillsVisible.ts +0 -37
- package/src/utils/getFill.ts +0 -46
|
@@ -7,6 +7,7 @@ exports.ImageItem = void 0;
|
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const react_1 = require("react");
|
|
9
9
|
const style_1 = __importDefault(require("styled-jsx/style"));
|
|
10
|
+
const color_1 = require("@cntrl-site/color");
|
|
10
11
|
const sdk_1 = require("@cntrl-site/sdk");
|
|
11
12
|
const LinkWrapper_1 = require("../LinkWrapper");
|
|
12
13
|
const useFileItem_1 = require("./useFileItem");
|
|
@@ -18,13 +19,12 @@ const useElementRect_1 = require("../../../utils/useElementRect");
|
|
|
18
19
|
const useLayoutContext_1 = require("../../useLayoutContext");
|
|
19
20
|
const getStyleFromItemStateAndParams_1 = require("../../../utils/getStyleFromItemStateAndParams");
|
|
20
21
|
const useItemFXData_1 = require("../../../common/useItemFXData");
|
|
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
|
|
23
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
24
24
|
const id = (0, react_1.useId)();
|
|
25
25
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
26
26
|
const layoutId = (0, useLayoutContext_1.useLayoutContext)();
|
|
27
|
-
const { radius: itemRadius, strokeWidth: itemStrokeWidth, opacity: itemOpacity,
|
|
27
|
+
const { radius: itemRadius, strokeWidth: itemStrokeWidth, opacity: itemOpacity, strokeColor: itemStrokeColor, blur: itemBlur } = (0, useFileItem_1.useFileItem)(item, sectionId);
|
|
28
28
|
const itemAngle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
|
|
29
29
|
const [wrapperRef, setWrapperRef] = (0, react_1.useState)(null);
|
|
30
30
|
(0, useRegisterResize_1.useRegisterResize)(wrapperRef, onResize);
|
|
@@ -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', 'strokeColor']);
|
|
45
42
|
(0, react_1.useEffect)(() => {
|
|
46
43
|
isInitialRef.current = false;
|
|
47
44
|
}, []);
|
|
@@ -51,37 +48,26 @@ 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
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const inlineStyles = Object.assign(Object.assign({}, (radius !== undefined ? { borderRadius: `${radius * 100}vw` } : {})), { transition: (_m = imgStateParams === null || imgStateParams === void 0 ? void 0 : imgStateParams.transition) !== null && _m !== void 0 ? _m : 'none' });
|
|
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 borderColor = (0, react_1.useMemo)(() => {
|
|
54
|
+
var _a;
|
|
55
|
+
const borderColor = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_a = imgStateParams === null || imgStateParams === void 0 ? void 0 : imgStateParams.styles) === null || _a === void 0 ? void 0 : _a.strokeColor, itemStrokeColor);
|
|
56
|
+
return borderColor ? color_1.CntrlColor.parse(borderColor) : undefined;
|
|
57
|
+
}, [itemStrokeColor, (_d = imgStateParams === null || imgStateParams === void 0 ? void 0 : imgStateParams.styles) === null || _d === void 0 ? void 0 : _d.strokeColor]);
|
|
58
|
+
const radius = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_e = imgStateParams === null || imgStateParams === void 0 ? void 0 : imgStateParams.styles) === null || _e === void 0 ? void 0 : _e.radius, itemRadius);
|
|
59
|
+
const strokeWidth = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_f = imgStateParams === null || imgStateParams === void 0 ? void 0 : imgStateParams.styles) === null || _f === void 0 ? void 0 : _f.strokeWidth, itemStrokeWidth);
|
|
60
|
+
const angle = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_g = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.styles) === null || _g === void 0 ? void 0 : _g.angle, itemAngle);
|
|
61
|
+
const opacity = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_h = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.styles) === null || _h === void 0 ? void 0 : _h.opacity, itemOpacity);
|
|
62
|
+
const blur = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_j = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.styles) === null || _j === void 0 ? void 0 : _j.blur, itemBlur);
|
|
63
|
+
const inlineStyles = Object.assign(Object.assign(Object.assign(Object.assign({}, (borderColor ? { borderColor: `${borderColor.fmt('rgba')}` } : {})), (radius !== undefined ? { borderRadius: `${radius * 100}vw` } : {})), (strokeWidth !== undefined ? { borderWidth: `${strokeWidth * 100}vw` } : {})), { transition: (_k = imgStateParams === null || imgStateParams === void 0 ? void 0 : imgStateParams.transition) !== null && _k !== void 0 ? _k : 'none' });
|
|
68
64
|
const isInteractive = opacity !== 0;
|
|
69
65
|
(0, react_1.useEffect)(() => {
|
|
70
66
|
onVisibilityChange === null || onVisibilityChange === void 0 ? void 0 : onVisibilityChange(isInteractive);
|
|
71
67
|
}, [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 })), (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
|
-
} : {
|
|
83
|
-
background: stroke,
|
|
84
|
-
})) : { background: stroke })) })] }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
68
|
+
return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { url: (_l = item.link) === null || _l === void 0 ? void 0 : _l.url, target: (_m = item.link) === null || _m === void 0 ? void 0 : _m.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: (_o = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.transition) !== null && _o !== void 0 ? _o : 'none' }), children: hasGLEffect && isFXAllowed
|
|
69
|
+
? ((0, jsx_runtime_1.jsx)("canvas", { style: inlineStyles, ref: fxCanvas, className: `img-canvas image-${item.id}`, width: rectWidth, height: rectHeight }))
|
|
70
|
+
: ((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: `
|
|
85
71
|
.image-wrapper-${item.id} {
|
|
86
72
|
position: absolute;
|
|
87
73
|
width: 100%;
|
|
@@ -116,19 +102,9 @@ const ImageItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityCha
|
|
|
116
102
|
${layoutParams.blur !== 0 ? 'will-change: transform;' : ''}
|
|
117
103
|
}
|
|
118
104
|
.image-${item.id} {
|
|
105
|
+
border-color: ${color_1.CntrlColor.parse(layoutParams.strokeColor).fmt('rgba')};
|
|
119
106
|
border-radius: ${layoutParams.radius * 100}vw;
|
|
120
|
-
|
|
121
|
-
.image-border-${item.id} {
|
|
122
|
-
position: absolute;
|
|
123
|
-
inset: 0;
|
|
124
|
-
border-radius: inherit;
|
|
125
|
-
pointer-events: none;
|
|
126
|
-
z-index: 2;
|
|
127
|
-
-webkit-mask:
|
|
128
|
-
linear-gradient(#fff 0 0) content-box,
|
|
129
|
-
linear-gradient(#fff 0 0);
|
|
130
|
-
-webkit-mask-composite: xor;
|
|
131
|
-
mask-composite: exclude;
|
|
107
|
+
border-width: ${layoutParams.strokeWidth * 100}vw;
|
|
132
108
|
}
|
|
133
109
|
`);
|
|
134
110
|
})}
|
|
@@ -7,6 +7,7 @@ exports.VideoItem = void 0;
|
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const react_1 = require("react");
|
|
9
9
|
const style_1 = __importDefault(require("styled-jsx/style"));
|
|
10
|
+
const color_1 = require("@cntrl-site/color");
|
|
10
11
|
const sdk_1 = require("@cntrl-site/sdk");
|
|
11
12
|
const LinkWrapper_1 = require("../LinkWrapper");
|
|
12
13
|
const useFileItem_1 = require("./useFileItem");
|
|
@@ -19,13 +20,12 @@ const getStyleFromItemStateAndParams_1 = require("../../../utils/getStyleFromIte
|
|
|
19
20
|
const useVideoFx_1 = require("../../../utils/effects/useVideoFx");
|
|
20
21
|
const useElementRect_1 = require("../../../utils/useElementRect");
|
|
21
22
|
const useItemFXData_1 = require("../../../common/useItemFXData");
|
|
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
|
|
24
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
25
25
|
const id = (0, react_1.useId)();
|
|
26
26
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
27
27
|
const layoutId = (0, useLayoutContext_1.useLayoutContext)();
|
|
28
|
-
const { radius: itemRadius, strokeWidth: itemStrokeWidth,
|
|
28
|
+
const { radius: itemRadius, strokeWidth: itemStrokeWidth, strokeColor: itemStrokeColor, opacity: itemOpacity, blur: itemBlur } = (0, useFileItem_1.useFileItem)(item, sectionId);
|
|
29
29
|
const [isVideoPlaying, setIsVideoPlaying] = (0, react_1.useState)(false);
|
|
30
30
|
const isScrollPausedRef = (0, react_1.useRef)(false);
|
|
31
31
|
const [userPaused, setUserPaused] = (0, react_1.useState)(false);
|
|
@@ -49,21 +49,17 @@ 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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
const
|
|
60
|
-
const
|
|
61
|
-
const
|
|
62
|
-
|
|
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'
|
|
66
|
-
: 'transparent';
|
|
52
|
+
const videoStateParams = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['strokeWidth', 'radius', 'strokeColor']);
|
|
53
|
+
const borderColor = (0, react_1.useMemo)(() => {
|
|
54
|
+
var _a;
|
|
55
|
+
const strokeColor = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_a = videoStateParams === null || videoStateParams === void 0 ? void 0 : videoStateParams.styles) === null || _a === void 0 ? void 0 : _a.color, itemStrokeColor);
|
|
56
|
+
return strokeColor ? color_1.CntrlColor.parse(strokeColor) : undefined;
|
|
57
|
+
}, [(_d = videoStateParams === null || videoStateParams === void 0 ? void 0 : videoStateParams.styles) === null || _d === void 0 ? void 0 : _d.color, itemStrokeColor]);
|
|
58
|
+
const angle = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_e = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.styles) === null || _e === void 0 ? void 0 : _e.angle, itemAngle);
|
|
59
|
+
const opacity = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_f = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.styles) === null || _f === void 0 ? void 0 : _f.opacity, itemOpacity);
|
|
60
|
+
const blur = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_g = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.styles) === null || _g === void 0 ? void 0 : _g.blur, itemBlur);
|
|
61
|
+
const strokeWidth = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_h = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.styles) === null || _h === void 0 ? void 0 : _h.strokeWidth, itemStrokeWidth);
|
|
62
|
+
const radius = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_j = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.styles) === null || _j === void 0 ? void 0 : _j.radius, itemRadius);
|
|
67
63
|
(0, react_1.useEffect)(() => {
|
|
68
64
|
isInitialRef.current = false;
|
|
69
65
|
}, []);
|
|
@@ -73,7 +69,7 @@ const VideoItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityCha
|
|
|
73
69
|
controls: controlsValues
|
|
74
70
|
}, width, height);
|
|
75
71
|
(0, useRegisterResize_1.useRegisterResize)(ref, onResize);
|
|
76
|
-
const inlineStyles = Object.assign(Object.assign({}, (radius !== undefined ? { borderRadius: `${radius * 100}vw` } : {})), { transition: (
|
|
72
|
+
const inlineStyles = Object.assign(Object.assign(Object.assign(Object.assign({}, (radius !== undefined ? { borderRadius: `${radius * 100}vw` } : {})), (strokeWidth !== undefined ? { borderWidth: `${strokeWidth * 100}vw` } : {})), (borderColor ? { borderColor: `${borderColor.toCss()}` } : {})), { transition: (_k = videoStateParams === null || videoStateParams === void 0 ? void 0 : videoStateParams.transition) !== null && _k !== void 0 ? _k : 'none' });
|
|
77
73
|
const isInteractive = opacity !== 0;
|
|
78
74
|
(0, react_1.useEffect)(() => {
|
|
79
75
|
onVisibilityChange === null || onVisibilityChange === void 0 ? void 0 : onVisibilityChange(isInteractive);
|
|
@@ -96,11 +92,7 @@ const VideoItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityCha
|
|
|
96
92
|
observer.observe(ref);
|
|
97
93
|
return () => observer.disconnect();
|
|
98
94
|
}, [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: () => {
|
|
95
|
+
return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, { url: (_l = item.link) === null || _l === void 0 ? void 0 : _l.url, target: (_m = item.link) === null || _m === void 0 ? void 0 : _m.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: (_o = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.transition) !== null && _o !== void 0 ? _o : '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: (_p = item.commonParams.coverUrl) !== null && _p !== void 0 ? _p : '', ref: setVideoRef, autoPlay: layoutParams.play === 'auto', preload: "auto", onClick: () => {
|
|
104
96
|
setIsVideoInteracted(true);
|
|
105
97
|
}, muted: layoutParams.muted, onPlay: () => {
|
|
106
98
|
setIsVideoPlaying(true);
|
|
@@ -123,7 +115,7 @@ const VideoItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityCha
|
|
|
123
115
|
return;
|
|
124
116
|
setIsVideoInteracted(true);
|
|
125
117
|
videoRef.play();
|
|
126
|
-
}, src: (
|
|
118
|
+
}, src: (_q = item.commonParams.coverUrl) !== null && _q !== void 0 ? _q : '', className: `video-cover-${item.id}`, onClick: () => {
|
|
127
119
|
if (!videoRef)
|
|
128
120
|
return;
|
|
129
121
|
setIsVideoInteracted(true);
|
|
@@ -138,13 +130,7 @@ const VideoItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityCha
|
|
|
138
130
|
else {
|
|
139
131
|
videoRef.play();
|
|
140
132
|
}
|
|
141
|
-
} })))] })), (0, jsx_runtime_1.jsx)(
|
|
142
|
-
backgroundPosition: 'center',
|
|
143
|
-
backgroundSize: strokeValue.behavior === 'repeat' ? `${strokeValue.backgroundSize}%` : strokeValue.behavior,
|
|
144
|
-
backgroundRepeat: strokeValue.behavior === 'repeat' ? 'repeat' : 'no-repeat'
|
|
145
|
-
} : {
|
|
146
|
-
background: stroke,
|
|
147
|
-
})) : { background: stroke })) })] }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
133
|
+
} })))] }))] }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
148
134
|
.video-wrapper-${item.id} {
|
|
149
135
|
position: absolute;
|
|
150
136
|
overflow: hidden;
|
|
@@ -180,7 +166,7 @@ const VideoItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityCha
|
|
|
180
166
|
border-style: solid;
|
|
181
167
|
}
|
|
182
168
|
.video-${item.id} {
|
|
183
|
-
border-
|
|
169
|
+
border-color: ${itemStrokeColor};
|
|
184
170
|
}
|
|
185
171
|
.video-playback-wrapper {
|
|
186
172
|
display: flex;
|
|
@@ -203,19 +189,9 @@ const VideoItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityCha
|
|
|
203
189
|
${layoutParams.blur !== 0 ? 'will-change: transform;' : ''}
|
|
204
190
|
}
|
|
205
191
|
.video-${item.id} {
|
|
192
|
+
border-color: ${color_1.CntrlColor.parse(layoutParams.strokeColor).fmt('rgba')};
|
|
206
193
|
border-radius: ${layoutParams.radius * 100}vw;
|
|
207
|
-
|
|
208
|
-
.video-border-${item.id} {
|
|
209
|
-
position: absolute;
|
|
210
|
-
inset: 0;
|
|
211
|
-
border-radius: inherit;
|
|
212
|
-
pointer-events: none;
|
|
213
|
-
z-index: 2;
|
|
214
|
-
-webkit-mask:
|
|
215
|
-
linear-gradient(#fff 0 0) content-box,
|
|
216
|
-
linear-gradient(#fff 0 0);
|
|
217
|
-
-webkit-mask-composite: xor;
|
|
218
|
-
mask-composite: exclude;
|
|
194
|
+
border-width: ${layoutParams.strokeWidth * 100}vw;
|
|
219
195
|
}
|
|
220
196
|
`);
|
|
221
197
|
})}
|
|
@@ -4,14 +4,7 @@ exports.useFileItem = void 0;
|
|
|
4
4
|
const sdk_1 = require("@cntrl-site/sdk");
|
|
5
5
|
const useKeyframeValue_1 = require("../../../common/useKeyframeValue");
|
|
6
6
|
const useLayoutContext_1 = require("../../useLayoutContext");
|
|
7
|
-
const
|
|
8
|
-
{
|
|
9
|
-
id: 'default',
|
|
10
|
-
type: 'solid',
|
|
11
|
-
value: 'rgba(0, 0, 0, 1)',
|
|
12
|
-
blendMode: 'normal'
|
|
13
|
-
}
|
|
14
|
-
];
|
|
7
|
+
const DEFAULT_COLOR = 'rgba(0, 0, 0, 1)';
|
|
15
8
|
function useFileItem(item, sectionId) {
|
|
16
9
|
const layoutId = (0, useLayoutContext_1.useLayoutContext)();
|
|
17
10
|
const radius = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.BorderRadius, (item, layoutId) => {
|
|
@@ -32,18 +25,18 @@ function useFileItem(item, sectionId) {
|
|
|
32
25
|
const layoutParams = item.layoutParams[layoutId];
|
|
33
26
|
return 'opacity' in layoutParams ? layoutParams.opacity : 1;
|
|
34
27
|
}, (animator, scroll, value) => value !== undefined ? animator.getOpacity({ opacity: value }, scroll).opacity : undefined, sectionId, [layoutId]);
|
|
35
|
-
const
|
|
28
|
+
const strokeColor = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.BorderColor, (item, layoutId) => {
|
|
36
29
|
if (!layoutId)
|
|
37
30
|
return;
|
|
38
31
|
const layoutParams = item.layoutParams[layoutId];
|
|
39
|
-
return '
|
|
40
|
-
}, (animator, scroll, value) => value ? animator.
|
|
32
|
+
return 'strokeColor' in layoutParams ? layoutParams.strokeColor : DEFAULT_COLOR;
|
|
33
|
+
}, (animator, scroll, value) => value ? animator.getBorderColor({ color: value }, scroll).color : undefined, sectionId, [layoutId]);
|
|
41
34
|
const blur = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.Blur, (item, layoutId) => {
|
|
42
35
|
if (!layoutId)
|
|
43
36
|
return;
|
|
44
37
|
const layoutParams = item.layoutParams[layoutId];
|
|
45
38
|
return 'blur' in layoutParams ? layoutParams.blur : 0;
|
|
46
39
|
}, (animator, scroll, value) => value !== undefined ? animator.getBlur({ blur: value }, scroll).blur : undefined, sectionId, [layoutId]);
|
|
47
|
-
return { radius, strokeWidth, opacity,
|
|
40
|
+
return { radius, strokeWidth, opacity, strokeColor, blur };
|
|
48
41
|
}
|
|
49
42
|
exports.useFileItem = useFileItem;
|
|
@@ -7,6 +7,7 @@ exports.RectangleItem = void 0;
|
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const react_1 = require("react");
|
|
9
9
|
const style_1 = __importDefault(require("styled-jsx/style"));
|
|
10
|
+
const color_1 = require("@cntrl-site/color");
|
|
10
11
|
const sdk_1 = require("@cntrl-site/sdk");
|
|
11
12
|
const LinkWrapper_1 = require("../LinkWrapper");
|
|
12
13
|
const useRectangleItem_1 = require("./useRectangleItem");
|
|
@@ -14,22 +15,22 @@ const useItemAngle_1 = require("../useItemAngle");
|
|
|
14
15
|
const useCntrlContext_1 = require("../../../provider/useCntrlContext");
|
|
15
16
|
const useRegisterResize_1 = require("../../../common/useRegisterResize");
|
|
16
17
|
const getStyleFromItemStateAndParams_1 = require("../../../utils/getStyleFromItemStateAndParams");
|
|
17
|
-
const getFill_1 = require("../../../utils/getFill");
|
|
18
|
-
const areFillsVisible_1 = require("../../../utils/areFillsVisible/areFillsVisible");
|
|
19
18
|
const RectangleItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityChange }) => {
|
|
20
|
-
var _a, _b, _c, _d
|
|
19
|
+
var _a, _b, _c, _d;
|
|
21
20
|
const id = (0, react_1.useId)();
|
|
22
21
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
23
|
-
const {
|
|
22
|
+
const { fillColor: itemFillColor, radius: itemRadius, strokeWidth: itemStrokeWidth, strokeColor: itemStrokeColor, blur: itemBlur, backdropBlur: itemBackdropBlur } = (0, useRectangleItem_1.useRectangleItem)(item, sectionId);
|
|
24
23
|
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']);
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
24
|
+
const stateParams = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['angle', 'fillColor', 'strokeWidth', 'radius', 'strokeColor', 'blur', 'backdropBlur']);
|
|
25
|
+
const styles = (_a = stateParams === null || stateParams === void 0 ? void 0 : stateParams.styles) !== null && _a !== void 0 ? _a : {};
|
|
26
|
+
const backgroundColor = (0, react_1.useMemo)(() => {
|
|
27
|
+
const fillColor = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)(styles === null || styles === void 0 ? void 0 : styles.fillColor, itemFillColor);
|
|
28
|
+
return fillColor ? color_1.CntrlColor.parse(fillColor) : undefined;
|
|
29
|
+
}, [itemFillColor, styles === null || styles === void 0 ? void 0 : styles.fillColor]);
|
|
30
|
+
const borderColor = (0, react_1.useMemo)(() => {
|
|
31
|
+
const strokeColor = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)(styles === null || styles === void 0 ? void 0 : styles.strokeColor, itemStrokeColor);
|
|
32
|
+
return strokeColor ? color_1.CntrlColor.parse(strokeColor) : undefined;
|
|
33
|
+
}, [itemStrokeColor, styles === null || styles === void 0 ? void 0 : styles.strokeColor]);
|
|
33
34
|
const layoutValues = [item.area, item.layoutParams];
|
|
34
35
|
const [ref, setRef] = (0, react_1.useState)(null);
|
|
35
36
|
(0, useRegisterResize_1.useRegisterResize)(ref, onResize);
|
|
@@ -39,92 +40,35 @@ const RectangleItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilit
|
|
|
39
40
|
const angle = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)(styles === null || styles === void 0 ? void 0 : styles.angle, itemAngle);
|
|
40
41
|
const blur = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)(styles === null || styles === void 0 ? void 0 : styles.blur, itemBlur);
|
|
41
42
|
const backdropFilterValue = backdropBlur ? `blur(${backdropBlur * 100}vw)` : undefined;
|
|
42
|
-
const isInteractive = (
|
|
43
|
+
const isInteractive = (backgroundColor === null || backgroundColor === void 0 ? void 0 : backgroundColor.getAlpha()) !== 0 || (strokeWidth !== 0 && (borderColor === null || borderColor === void 0 ? void 0 : borderColor.getAlpha()) !== 0);
|
|
43
44
|
(0, react_1.useEffect)(() => {
|
|
44
45
|
onVisibilityChange === null || onVisibilityChange === void 0 ? void 0 : onVisibilityChange(isInteractive);
|
|
45
46
|
}, [isInteractive, onVisibilityChange]);
|
|
46
|
-
|
|
47
|
-
? (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)(stateStrokeFillLayers[0], itemStrokeFill === null || itemStrokeFill === void 0 ? void 0 : itemStrokeFill[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'
|
|
51
|
-
: '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.jsxs)("div", { className: `rectangle-${item.id}`, ref: setRef, style: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (strokeValue ? Object.assign({ '--stroke-background': stroke }, (strokeValue.type === 'image' ? {
|
|
53
|
-
backgroundPosition: 'center',
|
|
54
|
-
backgroundSize: strokeValue.behavior === 'repeat' ? `${strokeValue.backgroundSize}%` : strokeValue.behavior,
|
|
55
|
-
backgroundRepeat: strokeValue.behavior === 'repeat' ? 'repeat' : 'no-repeat'
|
|
56
|
-
} : {})) : {})), (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
|
|
47
|
+
return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { url: (_b = item.link) === null || _b === void 0 ? void 0 : _b.url, target: (_c = item.link) === null || _c === void 0 ? void 0 : _c.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(Object.assign(Object.assign({}, (backgroundColor ? { backgroundColor: `${backgroundColor.fmt('rgba')}` } : {})), (borderColor ? { borderColor: `${borderColor.fmt('rgba')}` } : {})), (radius !== undefined ? { borderRadius: `${radius * 100}vw` } : {})), (strokeWidth !== undefined ? { borderWidth: `${strokeWidth * 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
48
|
? { backdropFilter: backdropFilterValue, WebkitBackdropFilter: backdropFilterValue }
|
|
58
|
-
: {})), { transition: (
|
|
59
|
-
backgroundPosition: 'center',
|
|
60
|
-
backgroundSize: strokeValue.behavior === 'repeat' ? `${strokeValue.backgroundSize}%` : strokeValue.behavior,
|
|
61
|
-
backgroundRepeat: strokeValue.behavior === 'repeat' ? 'repeat' : 'no-repeat'
|
|
62
|
-
} : {
|
|
63
|
-
background: stroke,
|
|
64
|
-
})) : { background: stroke })) }), itemFill && itemFill.map((fill) => {
|
|
65
|
-
var _a, _b;
|
|
66
|
-
const stateFillLayer = stateFillLayers === null || stateFillLayers === void 0 ? void 0 : stateFillLayers.find((layer) => layer.id === fill.id);
|
|
67
|
-
const value = stateFillLayer
|
|
68
|
-
? ((_a = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)(stateFillLayer, fill)) !== null && _a !== void 0 ? _a : fill)
|
|
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: `
|
|
49
|
+
: {})), { transition: (_d = stateParams === null || stateParams === void 0 ? void 0 : stateParams.transition) !== null && _d !== void 0 ? _d : 'none' }) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
75
50
|
.rectangle-${item.id} {
|
|
76
51
|
position: absolute;
|
|
77
52
|
width: 100%;
|
|
78
53
|
height: 100%;
|
|
54
|
+
border-style: solid;
|
|
79
55
|
box-sizing: border-box;
|
|
80
|
-
}
|
|
81
|
-
.image-fill-${item.id} {
|
|
82
|
-
position: absolute;
|
|
83
|
-
top: 0;
|
|
84
|
-
left: 0;
|
|
85
|
-
width: 100%;
|
|
86
|
-
height: 100%;
|
|
87
|
-
transform-origin: center center;
|
|
88
|
-
z-index: 1;
|
|
89
|
-
background-position: center;
|
|
90
|
-
},
|
|
56
|
+
}
|
|
91
57
|
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams]) => {
|
|
92
58
|
return (`
|
|
93
59
|
.rectangle-${item.id} {
|
|
94
|
-
|
|
60
|
+
background-color: ${color_1.CntrlColor.parse(layoutParams.fillColor).fmt('rgba')};
|
|
61
|
+
border-color: ${color_1.CntrlColor.parse(layoutParams.strokeColor).fmt('rgba')};
|
|
62
|
+
border-radius: ${layoutParams.radius * 100}vw;
|
|
63
|
+
border-width: ${layoutParams.strokeWidth * 100}vw;
|
|
95
64
|
transform: rotate(${area.angle}deg);
|
|
96
65
|
filter: ${layoutParams.blur !== 0 ? `blur(${layoutParams.blur * 100}vw)` : 'unset'};
|
|
97
66
|
${layoutParams.blur !== 0 ? 'will-change: transform;' : ''}
|
|
98
67
|
backdrop-filter: ${layoutParams.backdropBlur !== 0 ? `blur(${layoutParams.backdropBlur * 100}vw)` : 'unset'};
|
|
99
68
|
-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
69
|
}
|
|
113
70
|
`);
|
|
114
71
|
})}
|
|
115
72
|
` })] }) }));
|
|
116
73
|
};
|
|
117
74
|
exports.RectangleItem = RectangleItem;
|
|
118
|
-
function Fill({ fill, itemId, background, solidTransition }) {
|
|
119
|
-
const isRotatedImage = fill.type === 'image' && fill.rotation && fill.rotation !== 0;
|
|
120
|
-
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
|
-
? {
|
|
122
|
-
transform: `rotate(${fill.rotation}deg)`,
|
|
123
|
-
backgroundImage: `url(${fill.src})`,
|
|
124
|
-
backgroundSize: fill.behavior === 'repeat' ? `${fill.backgroundSize}%` : fill.behavior,
|
|
125
|
-
backgroundRepeat: fill.behavior === 'repeat' ? 'repeat' : 'no-repeat',
|
|
126
|
-
opacity: fill.opacity
|
|
127
|
-
}
|
|
128
|
-
: { background })), { position: 'absolute', mixBlendMode: fill.blendMode, top: 0, left: 0, width: '100%', height: '100%', pointerEvents: 'none' }), (isRotatedImage ? { overflow: 'hidden' } : {})) }, fill.id));
|
|
129
|
-
}
|
|
130
|
-
;
|
|
@@ -4,14 +4,7 @@ exports.useRectangleItem = void 0;
|
|
|
4
4
|
const sdk_1 = require("@cntrl-site/sdk");
|
|
5
5
|
const useKeyframeValue_1 = require("../../../common/useKeyframeValue");
|
|
6
6
|
const useLayoutContext_1 = require("../../useLayoutContext");
|
|
7
|
-
const
|
|
8
|
-
{
|
|
9
|
-
id: 'default',
|
|
10
|
-
type: 'solid',
|
|
11
|
-
value: 'rgba(0, 0, 0, 1)',
|
|
12
|
-
blendMode: 'normal'
|
|
13
|
-
}
|
|
14
|
-
];
|
|
7
|
+
const defaultColor = 'rgba(0, 0, 0, 1)';
|
|
15
8
|
function useRectangleItem(item, sectionId) {
|
|
16
9
|
const layoutId = (0, useLayoutContext_1.useLayoutContext)();
|
|
17
10
|
const radius = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.BorderRadius, (item, layoutId) => {
|
|
@@ -26,18 +19,18 @@ function useRectangleItem(item, sectionId) {
|
|
|
26
19
|
const layoutParams = item.layoutParams[layoutId];
|
|
27
20
|
return 'strokeWidth' in layoutParams ? layoutParams.strokeWidth : 0;
|
|
28
21
|
}, (animator, scroll, value) => value !== undefined ? animator.getBorderWidth({ borderWidth: value }, scroll).borderWidth : undefined, sectionId, [layoutId]);
|
|
29
|
-
const
|
|
22
|
+
const fillColor = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.Color, (item, layoutId) => {
|
|
30
23
|
if (!layoutId)
|
|
31
24
|
return;
|
|
32
25
|
const layoutParams = item.layoutParams[layoutId];
|
|
33
|
-
return '
|
|
34
|
-
}, (animator, scroll, value) => value ? animator.
|
|
35
|
-
const
|
|
26
|
+
return 'fillColor' in layoutParams ? layoutParams.fillColor : defaultColor;
|
|
27
|
+
}, (animator, scroll, value) => value ? animator.getColor({ color: value }, scroll).color : undefined, sectionId, [layoutId]);
|
|
28
|
+
const strokeColor = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.BorderColor, (item, layoutId) => {
|
|
36
29
|
if (!layoutId)
|
|
37
30
|
return;
|
|
38
31
|
const layoutParams = item.layoutParams[layoutId];
|
|
39
|
-
return '
|
|
40
|
-
}, (animator, scroll, value) => value ? animator.
|
|
32
|
+
return 'strokeColor' in layoutParams ? layoutParams.strokeColor : defaultColor;
|
|
33
|
+
}, (animator, scroll, value) => value ? animator.getBorderColor({ color: value }, scroll).color : undefined, sectionId, [layoutId]);
|
|
41
34
|
const blur = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.Blur, (item, layoutId) => {
|
|
42
35
|
if (!layoutId)
|
|
43
36
|
return;
|
|
@@ -50,6 +43,6 @@ function useRectangleItem(item, sectionId) {
|
|
|
50
43
|
const layoutParams = item.layoutParams[layoutId];
|
|
51
44
|
return 'backdropBlur' in layoutParams ? layoutParams.backdropBlur : 0;
|
|
52
45
|
}, (animator, scroll, value) => value !== undefined ? animator.getBackdropBlur({ backdropBlur: value }, scroll).backdropBlur : undefined, sectionId, [layoutId]);
|
|
53
|
-
return {
|
|
46
|
+
return { fillColor, strokeWidth, radius, strokeColor, blur, backdropBlur };
|
|
54
47
|
}
|
|
55
48
|
exports.useRectangleItem = useRectangleItem;
|
|
@@ -2,29 +2,29 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getStyleKeysFromCSSProperty = exports.CSSPropertyNameMap = void 0;
|
|
4
4
|
exports.CSSPropertyNameMap = {
|
|
5
|
-
width: 'width',
|
|
6
|
-
height: 'height',
|
|
7
|
-
top: 'top',
|
|
8
|
-
left: 'left',
|
|
9
|
-
scale: 'transform',
|
|
10
|
-
angle: 'transform',
|
|
11
|
-
opacity: 'opacity',
|
|
12
|
-
radius: 'border-radius',
|
|
13
|
-
strokeWidth: 'border-width',
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
blur: 'filter',
|
|
17
|
-
backdropBlur: 'backdrop-filter',
|
|
18
|
-
letterSpacing: 'letter-spacing',
|
|
19
|
-
wordSpacing: 'word-spacing',
|
|
20
|
-
color: 'color'
|
|
5
|
+
'width': 'width',
|
|
6
|
+
'height': 'height',
|
|
7
|
+
'top': 'top',
|
|
8
|
+
'left': 'left',
|
|
9
|
+
'scale': 'transform',
|
|
10
|
+
'angle': 'transform',
|
|
11
|
+
'opacity': 'opacity',
|
|
12
|
+
'radius': 'border-radius',
|
|
13
|
+
'strokeWidth': 'border-width',
|
|
14
|
+
'strokeColor': 'border-color',
|
|
15
|
+
'fillColor': 'background-color',
|
|
16
|
+
'blur': 'filter',
|
|
17
|
+
'backdropBlur': 'backdrop-filter',
|
|
18
|
+
'letterSpacing': 'letter-spacing',
|
|
19
|
+
'wordSpacing': 'word-spacing',
|
|
20
|
+
'color': 'color'
|
|
21
21
|
};
|
|
22
22
|
const PropertyNameCSSMap = {
|
|
23
23
|
'transform': ['angle', 'scale'],
|
|
24
24
|
'border-radius': ['radius'],
|
|
25
25
|
'border-width': ['strokeWidth'],
|
|
26
|
-
'border-color': ['
|
|
27
|
-
'background': ['
|
|
26
|
+
'border-color': ['strokeColor'],
|
|
27
|
+
'background-color': ['fillColor'],
|
|
28
28
|
'filter': ['blur'],
|
|
29
29
|
'backdrop-filter': ['backdrop-blur'],
|
|
30
30
|
'letter-spacing': ['letterSpacing'],
|