@cntrl-site/sdk-nextjs 1.0.19-alpha.3 → 1.0.19-alpha.5
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/cntrl-site-sdk-nextjs-1.0.19-alpha.4.tgz +0 -0
- package/cntrl-site-sdk-nextjs-1.0.19-alpha.5.tgz +0 -0
- package/lib/components/Article.js +1 -1
- package/lib/components/Item.js +29 -36
- package/lib/components/items/CodeEmbedItem.js +11 -14
- package/lib/components/items/CustomItem.js +7 -11
- package/lib/components/items/GroupItem.js +11 -14
- package/lib/components/items/ImageItem.js +21 -22
- package/lib/components/items/RectangleItem.js +24 -17
- package/lib/components/items/RichTextItem.js +19 -13
- package/lib/components/items/VideoItem.js +22 -21
- package/lib/components/items/VimeoEmbed.js +16 -20
- package/lib/components/items/YoutubeEmbed.js +16 -21
- package/lib/components/useItemPosition.js +10 -5
- package/lib/interactions/CSSPropertyNameMap.js +38 -0
- package/lib/interactions/InteractionsRegistry.js +220 -0
- package/lib/interactions/ItemInteractionCtrl.js +61 -0
- package/lib/interactions/getTransition.js +21 -0
- package/lib/interactions/types.js +2 -0
- package/lib/interactions/useItemInteractionCtrl.js +17 -0
- package/lib/provider/InteractionsContext.js +17 -39
- package/lib/utils/getStyleFromItemStateAndParams.js +9 -0
- package/package.json +1 -1
- package/src/components/Article.tsx +2 -2
- package/src/components/Item.tsx +38 -34
- package/src/components/items/CodeEmbedItem.tsx +11 -13
- package/src/components/items/CustomItem.tsx +8 -12
- package/src/components/items/GroupItem.tsx +12 -13
- package/src/components/items/ImageItem.tsx +29 -23
- package/src/components/items/RectangleItem.tsx +30 -15
- package/src/components/items/RichTextItem.tsx +26 -19
- package/src/components/items/VideoItem.tsx +31 -23
- package/src/components/items/VimeoEmbed.tsx +21 -19
- package/src/components/items/YoutubeEmbed.tsx +17 -21
- package/src/components/useItemPosition.ts +12 -5
- package/src/interactions/CSSPropertyNameMap.ts +38 -0
- package/src/interactions/InteractionsRegistry.ts +244 -0
- package/src/interactions/ItemInteractionCtrl.ts +62 -0
- package/src/interactions/getTransition.ts +27 -0
- package/src/interactions/types.ts +32 -0
- package/src/interactions/useItemInteractionCtrl.ts +18 -0
- package/src/provider/InteractionsContext.old.tsx +65 -0
- package/src/provider/InteractionsContext.test.tsx +7 -7
- package/src/provider/InteractionsContext.tsx +17 -54
- package/src/utils/getStyleFromItemStateAndParams.ts +8 -0
- package/lib/components/useStatesClassNames.js +0 -18
- package/lib/components/useStatesTransitions.js +0 -89
- package/lib/utils/StateStyles/StateStyles.js +0 -89
- package/lib/utils/getStatesCSS.js +0 -16
- package/src/components/useStatesClassNames.ts +0 -23
- package/src/components/useStatesTransitions.ts +0 -95
- package/src/utils/StateStyles/StateStyles.ts +0 -99
- package/src/utils/getStatesCSS.ts +0 -24
|
Binary file
|
|
Binary file
|
|
@@ -25,7 +25,7 @@ const Article = ({ article, sectionData }) => {
|
|
|
25
25
|
setArticleHeight(rect.height / rect.width);
|
|
26
26
|
});
|
|
27
27
|
}, [articleRectObserver]);
|
|
28
|
-
return ((0, jsx_runtime_1.jsx)(ArticleRectContext_1.ArticleRectContext.Provider, { value: articleRectObserver, children: (0, jsx_runtime_1.jsxs)(InteractionsContext_1.InteractionsProvider, {
|
|
28
|
+
return ((0, jsx_runtime_1.jsx)(ArticleRectContext_1.ArticleRectContext.Provider, { value: articleRectObserver, children: (0, jsx_runtime_1.jsxs)(InteractionsContext_1.InteractionsProvider, { article: article, children: [(0, jsx_runtime_1.jsx)(ArticleWrapper_1.ArticleWrapper, { children: (0, jsx_runtime_1.jsx)("div", { className: "article", ref: articleRef, children: article.sections.map((section, i) => {
|
|
29
29
|
const data = section.name ? sectionData[section.name] : {};
|
|
30
30
|
return ((0, jsx_runtime_1.jsx)(Section_1.Section, { section: section, data: data, children: article.sections[i].items.map(item => ((0, jsx_runtime_1.jsx)(Item_1.Item, { item: item, sectionId: section.id, articleHeight: articleHeight }, item.id))) }, section.id));
|
|
31
31
|
}) }) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
package/lib/components/Item.js
CHANGED
|
@@ -30,10 +30,7 @@ const useExemplary_1 = require("../common/useExemplary");
|
|
|
30
30
|
const GroupItem_1 = require("./items/GroupItem");
|
|
31
31
|
const CodeEmbedItem_1 = require("./items/CodeEmbedItem");
|
|
32
32
|
const KeyframesContext_1 = require("../provider/KeyframesContext");
|
|
33
|
-
const
|
|
34
|
-
const getStatesCSS_1 = require("../utils/getStatesCSS");
|
|
35
|
-
const useStatesClassNames_1 = require("./useStatesClassNames");
|
|
36
|
-
const useStatesTransitions_1 = require("./useStatesTransitions");
|
|
33
|
+
const useItemInteractionCtrl_1 = require("../interactions/useItemInteractionCtrl");
|
|
37
34
|
const itemsMap = {
|
|
38
35
|
[sdk_1.ArticleItemType.Rectangle]: RectangleItem_1.RectangleItem,
|
|
39
36
|
[sdk_1.ArticleItemType.Image]: ImageItem_1.ImageItem,
|
|
@@ -56,6 +53,7 @@ const RichTextWrapper = ({ isRichText, children }) => {
|
|
|
56
53
|
};
|
|
57
54
|
const noop = () => null;
|
|
58
55
|
const Item = ({ item, sectionId, articleHeight, isInGroup = false }) => {
|
|
56
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
59
57
|
const itemWrapperRef = (0, react_1.useRef)(null);
|
|
60
58
|
const itemInnerRef = (0, react_1.useRef)(null);
|
|
61
59
|
const rectObserver = (0, react_1.useContext)(ArticleRectContext_1.ArticleRectContext);
|
|
@@ -67,14 +65,19 @@ const Item = ({ item, sectionId, articleHeight, isInGroup = false }) => {
|
|
|
67
65
|
const exemplary = (0, useExemplary_1.useExemplary)();
|
|
68
66
|
const [wrapperHeight, setWrapperHeight] = (0, react_1.useState)(undefined);
|
|
69
67
|
const [itemHeight, setItemHeight] = (0, react_1.useState)(undefined);
|
|
70
|
-
const
|
|
71
|
-
const
|
|
68
|
+
const itemScale = (0, useItemScale_1.useItemScale)(item, sectionId);
|
|
69
|
+
const interactionCtrl = (0, useItemInteractionCtrl_1.useItemInteractionCtrl)(item.id);
|
|
70
|
+
const wrapperStateProps = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['top', 'left']);
|
|
71
|
+
const innerStateProps = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['width', 'height', 'scale']);
|
|
72
|
+
const position = (0, useItemPosition_1.useItemPosition)(item, sectionId, {
|
|
73
|
+
top: (_a = wrapperStateProps === null || wrapperStateProps === void 0 ? void 0 : wrapperStateProps.styles) === null || _a === void 0 ? void 0 : _a.top,
|
|
74
|
+
left: (_b = wrapperStateProps === null || wrapperStateProps === void 0 ? void 0 : wrapperStateProps.styles) === null || _b === void 0 ? void 0 : _b.left,
|
|
75
|
+
});
|
|
72
76
|
const sectionHeight = (0, useSectionHeightMap_1.useSectionHeightData)(sectionId);
|
|
73
77
|
const stickyTop = (0, useStickyItemTop_1.useStickyItemTop)(item, sectionHeight, sectionId);
|
|
74
78
|
const dimensions = (0, useItemDimensions_1.useItemDimensions)(item, sectionId);
|
|
75
|
-
const layoutValues = [item.area, item.hidden
|
|
79
|
+
const layoutValues = [item.area, item.hidden];
|
|
76
80
|
const isInitialRef = (0, react_1.useRef)(true);
|
|
77
|
-
const { transitionTo, getItemTrigger } = (0, react_1.useContext)(InteractionsContext_1.InteractionsContext);
|
|
78
81
|
layoutValues.push(item.sticky);
|
|
79
82
|
layoutValues.push(sectionHeight);
|
|
80
83
|
if (item.layoutParams) {
|
|
@@ -107,43 +110,35 @@ const Item = ({ item, sectionId, articleHeight, isInGroup = false }) => {
|
|
|
107
110
|
isInitialRef.current = false;
|
|
108
111
|
}, []);
|
|
109
112
|
const isRichText = isItemType(item, sdk_1.ArticleItemType.RichText);
|
|
110
|
-
const
|
|
111
|
-
const
|
|
112
|
-
(0
|
|
113
|
-
(0,
|
|
114
|
-
|
|
113
|
+
const width = ((_d = (_c = innerStateProps === null || innerStateProps === void 0 ? void 0 : innerStateProps.styles) === null || _c === void 0 ? void 0 : _c.width) !== null && _d !== void 0 ? _d : dimensions === null || dimensions === void 0 ? void 0 : dimensions.width);
|
|
114
|
+
const height = ((_f = (_e = innerStateProps === null || innerStateProps === void 0 ? void 0 : innerStateProps.styles) === null || _e === void 0 ? void 0 : _e.height) !== null && _f !== void 0 ? _f : dimensions === null || dimensions === void 0 ? void 0 : dimensions.height);
|
|
115
|
+
const scale = (_h = (_g = innerStateProps === null || innerStateProps === void 0 ? void 0 : innerStateProps.styles) === null || _g === void 0 ? void 0 : _g.scale) !== null && _h !== void 0 ? _h : itemScale;
|
|
116
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: `item-wrapper-${item.id}`, ref: itemWrapperRef, onTransitionEnd: (e) => {
|
|
117
|
+
var _a;
|
|
118
|
+
e.stopPropagation();
|
|
119
|
+
(_a = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.handleTransitionEnd) === null || _a === void 0 ? void 0 : _a.call(interactionCtrl, e.propertyName);
|
|
120
|
+
}, style: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (position ? { top: position.top } : {})), (position ? { left: position.left } : {})), (position ? { bottom: position.bottom } : {})), (wrapperHeight !== undefined ? { height: `${wrapperHeight * 100}vw` } : {})), { transition: (_j = wrapperStateProps === null || wrapperStateProps === void 0 ? void 0 : wrapperStateProps.transition) !== null && _j !== void 0 ? _j : 'none' }), children: [(0, jsx_runtime_1.jsx)("div", { suppressHydrationWarning: true, className: `item-${item.id}`, style: {
|
|
115
121
|
opacity: (keyframes.length !== 0 && !layout) ? 0 : 1,
|
|
116
122
|
top: `${stickyTop * 100}vw`,
|
|
117
123
|
height: isRichText && itemHeight ? `${itemHeight * 100}vw` : 'unset',
|
|
118
|
-
}, children: (0, jsx_runtime_1.jsx)(RichTextWrapper, { isRichText: isRichText, children: (0, jsx_runtime_1.jsx)("div", { className: `item-${item.id}-inner
|
|
119
|
-
|
|
120
|
-
if (!trigger)
|
|
121
|
-
return;
|
|
122
|
-
transitionTo(trigger.id, trigger.to);
|
|
124
|
+
}, children: (0, jsx_runtime_1.jsx)(RichTextWrapper, { isRichText: isRichText, children: (0, jsx_runtime_1.jsx)("div", { className: `item-${item.id}-inner`, ref: itemInnerRef, onClick: () => {
|
|
125
|
+
interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.sendTrigger('click');
|
|
123
126
|
}, onMouseEnter: () => {
|
|
124
|
-
|
|
125
|
-
if (!trigger)
|
|
126
|
-
return;
|
|
127
|
-
transitionTo(trigger.id, trigger.to);
|
|
127
|
+
interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.sendTrigger('hover-in');
|
|
128
128
|
}, onMouseLeave: () => {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
return;
|
|
132
|
-
transitionTo(trigger.id, trigger.to);
|
|
133
|
-
}, style: Object.assign(Object.assign({}, (dimensions ? {
|
|
129
|
+
interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.sendTrigger('hover-out');
|
|
130
|
+
}, style: Object.assign(Object.assign(Object.assign({}, ((width && height) ? {
|
|
134
131
|
width: `${sizingAxis.x === 'manual'
|
|
135
132
|
? isRichText
|
|
136
|
-
? `${
|
|
137
|
-
: `${
|
|
133
|
+
? `${width * exemplary}px`
|
|
134
|
+
: `${width * 100}vw`
|
|
138
135
|
: 'max-content'}`,
|
|
139
|
-
height: `${sizingAxis.y === 'manual' ? `${
|
|
140
|
-
} : {})), (scale !== undefined ? { transform: `scale(${scale})`, 'WebkitTransform': `scale(${scale})` } : {})), children: (0, jsx_runtime_1.jsx)(ItemComponent, { item: item, sectionId: sectionId, onResize: handleItemResize, articleHeight: articleHeight }) }) }) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
141
|
-
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, hidden,
|
|
136
|
+
height: `${sizingAxis.y === 'manual' ? `${height * 100}vw` : 'unset'}`
|
|
137
|
+
} : {})), (scale !== undefined ? { transform: `scale(${scale})`, 'WebkitTransform': `scale(${scale})` } : {})), { transition: (_k = innerStateProps === null || innerStateProps === void 0 ? void 0 : innerStateProps.transition) !== null && _k !== void 0 ? _k : 'none' }), children: (0, jsx_runtime_1.jsx)(ItemComponent, { item: item, sectionId: sectionId, onResize: handleItemResize, articleHeight: articleHeight, interactionCtrl: interactionCtrl }) }) }) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
138
|
+
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, hidden, sticky, sectionHeight, layoutParams], exemplary) => {
|
|
142
139
|
const sizingAxis = parseSizing(layoutParams.sizing);
|
|
143
140
|
const isScreenBasedBottom = area.positionType === sdk_1.PositionType.ScreenBased && area.anchorSide === sdk_1.AnchorSide.Bottom;
|
|
144
141
|
const scaleAnchor = area.scaleAnchor;
|
|
145
|
-
const statesInnerCSS = (0, getStatesCSS_1.getStatesCSS)(item.id, 'item-inner', ['width', 'height', 'scale'], states);
|
|
146
|
-
const statesWrapperCSS = (0, getStatesCSS_1.getStatesCSS)(item.id, 'item-wrapper', ['top', 'left'], states, area.anchorSide);
|
|
147
142
|
return (`
|
|
148
143
|
.item-${item.id} {
|
|
149
144
|
position: ${sticky ? 'sticky' : 'absolute'};
|
|
@@ -171,8 +166,6 @@ const Item = ({ item, sectionId, articleHeight, isInGroup = false }) => {
|
|
|
171
166
|
top: ${isScreenBasedBottom ? 'unset' : (0, getItemTopStyle_1.getItemTopStyle)(area.top, area.anchorSide)};
|
|
172
167
|
left: ${area.left * 100}vw;
|
|
173
168
|
}
|
|
174
|
-
${statesWrapperCSS}
|
|
175
|
-
${statesInnerCSS}
|
|
176
169
|
`);
|
|
177
170
|
})}
|
|
178
171
|
` })] }));
|
|
@@ -13,9 +13,6 @@ const useRegisterResize_1 = require("../../common/useRegisterResize");
|
|
|
13
13
|
const useItemAngle_1 = require("../useItemAngle");
|
|
14
14
|
const LinkWrapper_1 = require("../LinkWrapper");
|
|
15
15
|
const useCodeEmbedItem_1 = require("./useCodeEmbedItem");
|
|
16
|
-
const getStatesCSS_1 = require("../../utils/getStatesCSS");
|
|
17
|
-
const useStatesClassNames_1 = require("../useStatesClassNames");
|
|
18
|
-
const useStatesTransitions_1 = require("../useStatesTransitions");
|
|
19
16
|
const stylesMap = {
|
|
20
17
|
[sdk_1.AreaAnchor.TopLeft]: {},
|
|
21
18
|
[sdk_1.AreaAnchor.TopCenter]: { justifyContent: 'center' },
|
|
@@ -27,19 +24,21 @@ const stylesMap = {
|
|
|
27
24
|
[sdk_1.AreaAnchor.BottomCenter]: { justifyContent: 'center', alignItems: 'flex-end' },
|
|
28
25
|
[sdk_1.AreaAnchor.BottomRight]: { justifyContent: 'flex-end', alignItems: 'flex-end' }
|
|
29
26
|
};
|
|
30
|
-
const CodeEmbedItem = ({ item, sectionId, onResize }) => {
|
|
31
|
-
var _a, _b;
|
|
27
|
+
const CodeEmbedItem = ({ item, sectionId, onResize, interactionCtrl }) => {
|
|
28
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
32
29
|
const id = (0, react_1.useId)();
|
|
33
30
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
34
|
-
const { anchor, blur, opacity } = (0, useCodeEmbedItem_1.useCodeEmbedItem)(item, sectionId);
|
|
35
|
-
const
|
|
31
|
+
const { anchor, blur: itemBlur, opacity: itemOpacity } = (0, useCodeEmbedItem_1.useCodeEmbedItem)(item, sectionId);
|
|
32
|
+
const itemAngle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
|
|
36
33
|
const { html } = item.commonParams;
|
|
37
34
|
const [ref, setRef] = (0, react_1.useState)(null);
|
|
38
35
|
(0, useRegisterResize_1.useRegisterResize)(ref, onResize);
|
|
39
36
|
const pos = stylesMap[anchor];
|
|
40
|
-
const layoutValues = [item.area, item.layoutParams
|
|
41
|
-
const
|
|
42
|
-
(0
|
|
37
|
+
const layoutValues = [item.area, item.layoutParams];
|
|
38
|
+
const stateParams = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['angle', 'blur', 'opacity']);
|
|
39
|
+
const blur = ((_b = (_a = stateParams === null || stateParams === void 0 ? void 0 : stateParams.styles) === null || _a === void 0 ? void 0 : _a.blur) !== null && _b !== void 0 ? _b : itemBlur);
|
|
40
|
+
const opacity = (_d = (_c = stateParams === null || stateParams === void 0 ? void 0 : stateParams.styles) === null || _c === void 0 ? void 0 : _c.opacity) !== null && _d !== void 0 ? _d : itemOpacity;
|
|
41
|
+
const angle = (_f = (_e = stateParams === null || stateParams === void 0 ? void 0 : stateParams.styles) === null || _e === void 0 ? void 0 : _e.angle) !== null && _f !== void 0 ? _f : itemAngle;
|
|
43
42
|
(0, react_1.useEffect)(() => {
|
|
44
43
|
if (!ref)
|
|
45
44
|
return;
|
|
@@ -62,7 +61,7 @@ const CodeEmbedItem = ({ item, sectionId, onResize }) => {
|
|
|
62
61
|
return;
|
|
63
62
|
iframe.srcdoc = item.commonParams.html;
|
|
64
63
|
}, [item.commonParams.html, item.commonParams.iframe, ref]);
|
|
65
|
-
return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, { url: (
|
|
64
|
+
return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, { url: (_g = item.link) === null || _g === void 0 ? void 0 : _g.url, target: (_h = item.link) === null || _h === void 0 ? void 0 : _h.target, children: [(0, jsx_runtime_1.jsx)("div", { className: `embed-wrapper-${item.id}`, style: Object.assign(Object.assign(Object.assign(Object.assign({}, (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), (opacity !== undefined ? { opacity } : {})), { transition: (_j = stateParams === null || stateParams === void 0 ? void 0 : stateParams.transition) !== null && _j !== void 0 ? _j : 'none' }), ref: setRef, children: item.commonParams.iframe ? ((0, jsx_runtime_1.jsx)("iframe", { "data-embed": item.id, className: `embed-${item.id}`, style: Object.assign(Object.assign({}, pos), { border: 'unset' }) })) : ((0, jsx_runtime_1.jsx)("div", { className: `embed-${item.id}`, style: Object.assign({}, pos), dangerouslySetInnerHTML: { __html: html } })) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
66
65
|
.embed-wrapper-${item.id} {
|
|
67
66
|
position: absolute;
|
|
68
67
|
width: 100%;
|
|
@@ -74,8 +73,7 @@ const CodeEmbedItem = ({ item, sectionId, onResize }) => {
|
|
|
74
73
|
z-index: 1;
|
|
75
74
|
border: none;
|
|
76
75
|
}
|
|
77
|
-
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams
|
|
78
|
-
const statesCSS = (0, getStatesCSS_1.getStatesCSS)(item.id, 'embed-wrapper', ['angle', 'blur', 'opacity'], stateParams);
|
|
76
|
+
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams], exemplary) => {
|
|
79
77
|
return (`
|
|
80
78
|
.embed-wrapper-${item.id} {
|
|
81
79
|
opacity: ${layoutParams.opacity};
|
|
@@ -86,7 +84,6 @@ const CodeEmbedItem = ({ item, sectionId, onResize }) => {
|
|
|
86
84
|
width: ${item.commonParams.scale ? `${area.width * exemplary}px` : '100%'};
|
|
87
85
|
height: ${item.commonParams.scale ? `${area.height * exemplary}px` : '100%'};
|
|
88
86
|
}
|
|
89
|
-
${statesCSS}
|
|
90
87
|
`);
|
|
91
88
|
})}
|
|
92
89
|
` })] }));
|
|
@@ -11,23 +11,20 @@ const useCntrlContext_1 = require("../../provider/useCntrlContext");
|
|
|
11
11
|
const style_1 = __importDefault(require("styled-jsx/style"));
|
|
12
12
|
const useRegisterResize_1 = require("../../common/useRegisterResize");
|
|
13
13
|
const useItemAngle_1 = require("../useItemAngle");
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
const useStatesTransitions_1 = require("../useStatesTransitions");
|
|
17
|
-
const CustomItem = ({ item, onResize, sectionId }) => {
|
|
14
|
+
const CustomItem = ({ item, onResize, sectionId, interactionCtrl }) => {
|
|
15
|
+
var _a, _b, _c;
|
|
18
16
|
const sdk = (0, useCntrlContext_1.useCntrlContext)();
|
|
19
17
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
20
|
-
const
|
|
18
|
+
const itemAngle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
|
|
21
19
|
const component = sdk.customItems.get(item.commonParams.name);
|
|
22
|
-
const layoutValues = [item.area
|
|
20
|
+
const layoutValues = [item.area];
|
|
23
21
|
const [ref, setRef] = (0, react_1.useState)(null);
|
|
24
22
|
(0, useRegisterResize_1.useRegisterResize)(ref, onResize);
|
|
25
|
-
const
|
|
26
|
-
(0
|
|
23
|
+
const stateParams = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['angle']);
|
|
24
|
+
const angle = (_b = (_a = stateParams === null || stateParams === void 0 ? void 0 : stateParams.styles) === null || _a === void 0 ? void 0 : _a.angle) !== null && _b !== void 0 ? _b : itemAngle;
|
|
27
25
|
if (!component)
|
|
28
26
|
return null;
|
|
29
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `custom-component-${item.id}
|
|
30
|
-
const statesCSS = (0, getStatesCSS_1.getStatesCSS)(item.id, 'custom-component', ['angle'], stateParams);
|
|
27
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `custom-component-${item.id}`, ref: setRef, style: Object.assign(Object.assign({}, (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), { transition: (_c = stateParams === null || stateParams === void 0 ? void 0 : stateParams.transition) !== null && _c !== void 0 ? _c : 'none' }), children: component({}) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: item.id, children: `${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area]) => {
|
|
31
28
|
return (`
|
|
32
29
|
.custom-component-${item.id} {
|
|
33
30
|
transform: rotate(${area.angle}deg);
|
|
@@ -37,7 +34,6 @@ const CustomItem = ({ item, onResize, sectionId }) => {
|
|
|
37
34
|
left: 0;
|
|
38
35
|
top: 0;
|
|
39
36
|
}
|
|
40
|
-
${statesCSS}
|
|
41
37
|
`);
|
|
42
38
|
})}` })] }));
|
|
43
39
|
};
|
|
@@ -14,36 +14,33 @@ const useRegisterResize_1 = require("../../common/useRegisterResize");
|
|
|
14
14
|
const useCntrlContext_1 = require("../../provider/useCntrlContext");
|
|
15
15
|
const useItemAngle_1 = require("../useItemAngle");
|
|
16
16
|
const useGroupItem_1 = require("./useGroupItem");
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
const GroupItem = ({ item, sectionId, onResize, articleHeight }) => {
|
|
21
|
-
var _a, _b;
|
|
17
|
+
const getStyleFromItemStateAndParams_1 = require("../../utils/getStyleFromItemStateAndParams");
|
|
18
|
+
const GroupItem = ({ item, sectionId, onResize, articleHeight, interactionCtrl }) => {
|
|
19
|
+
var _a, _b, _c, _d, _e;
|
|
22
20
|
const id = (0, react_1.useId)();
|
|
23
21
|
const { items } = item;
|
|
24
|
-
const
|
|
22
|
+
const itemAngle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
|
|
25
23
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
26
|
-
const { opacity } = (0, useGroupItem_1.useGroupItem)(item, sectionId);
|
|
27
|
-
const layoutValues = [item.area, item.layoutParams
|
|
28
|
-
const statesClassNames = (0, useStatesClassNames_1.useStatesClassNames)(item.id, item.state, 'group');
|
|
24
|
+
const { opacity: itemOpacity } = (0, useGroupItem_1.useGroupItem)(item, sectionId);
|
|
25
|
+
const layoutValues = [item.area, item.layoutParams];
|
|
29
26
|
const [ref, setRef] = (0, react_1.useState)(null);
|
|
30
27
|
(0, useRegisterResize_1.useRegisterResize)(ref, onResize);
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
const stateParams = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['opacity', 'angle']);
|
|
29
|
+
const angle = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_a = stateParams === null || stateParams === void 0 ? void 0 : stateParams.styles) === null || _a === void 0 ? void 0 : _a.angle, itemAngle);
|
|
30
|
+
const opacity = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_b = stateParams === null || stateParams === void 0 ? void 0 : stateParams.styles) === null || _b === void 0 ? void 0 : _b.opacity, itemOpacity);
|
|
31
|
+
return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { url: (_c = item.link) === null || _c === void 0 ? void 0 : _c.url, target: (_d = item.link) === null || _d === void 0 ? void 0 : _d.target, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `group-${item.id}`, ref: setRef, style: Object.assign(Object.assign(Object.assign({}, (opacity !== undefined ? { opacity } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), { transition: (_e = stateParams === null || stateParams === void 0 ? void 0 : stateParams.transition) !== null && _e !== void 0 ? _e : 'none' }), children: items && items.map(item => ((0, jsx_runtime_1.jsx)(Item_1.Item, { item: item, sectionId: sectionId, articleHeight: articleHeight, interactionCtrl: interactionCtrl, isInGroup: true }, item.id))) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
33
32
|
.group-${item.id} {
|
|
34
33
|
position: absolute;
|
|
35
34
|
width: 100%;
|
|
36
35
|
height: 100%;
|
|
37
36
|
box-sizing: border-box;
|
|
38
37
|
}
|
|
39
|
-
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams
|
|
40
|
-
const statesCSS = (0, getStatesCSS_1.getStatesCSS)(item.id, 'group', ['opacity', 'angle'], stateParams);
|
|
38
|
+
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams]) => {
|
|
41
39
|
return (`
|
|
42
40
|
.group-${item.id} {
|
|
43
41
|
opacity: ${layoutParams.opacity};
|
|
44
42
|
transform: rotate(${area.angle}deg);
|
|
45
43
|
}
|
|
46
|
-
${statesCSS}
|
|
47
44
|
`);
|
|
48
45
|
})}
|
|
49
46
|
` })] }) }));
|
|
@@ -17,9 +17,7 @@ const useRegisterResize_1 = require("../../common/useRegisterResize");
|
|
|
17
17
|
const useImageFx_1 = require("../../utils/effects/useImageFx");
|
|
18
18
|
const useElementRect_1 = require("../../utils/useElementRect");
|
|
19
19
|
const useLayoutContext_1 = require("../useLayoutContext");
|
|
20
|
-
const
|
|
21
|
-
const getStatesCSS_1 = require("../../utils/getStatesCSS");
|
|
22
|
-
const useStatesTransitions_1 = require("../useStatesTransitions");
|
|
20
|
+
const getStyleFromItemStateAndParams_1 = require("../../utils/getStyleFromItemStateAndParams");
|
|
23
21
|
const baseVariables = `precision mediump float;
|
|
24
22
|
uniform sampler2D u_image;
|
|
25
23
|
uniform sampler2D u_pattern;
|
|
@@ -28,16 +26,14 @@ uniform vec2 u_patternDimensions;
|
|
|
28
26
|
uniform float u_time;
|
|
29
27
|
uniform vec2 u_cursor;
|
|
30
28
|
varying vec2 v_texCoord;`;
|
|
31
|
-
const ImageItem = ({ item, sectionId, onResize }) => {
|
|
32
|
-
var _a, _b, _c, _d, _e;
|
|
29
|
+
const ImageItem = ({ item, sectionId, onResize, interactionCtrl }) => {
|
|
30
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
33
31
|
const id = (0, react_1.useId)();
|
|
34
32
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
35
33
|
const layoutId = (0, useLayoutContext_1.useLayoutContext)();
|
|
36
|
-
const { radius, strokeWidth, opacity, strokeColor, blur } = (0, useFileItem_1.useFileItem)(item, sectionId);
|
|
37
|
-
const
|
|
38
|
-
const borderColor = (0, react_1.useMemo)(() => strokeColor ? color_1.CntrlColor.parse(strokeColor) : undefined, [strokeColor]);
|
|
34
|
+
const { radius: itemRadius, strokeWidth: itemStrokeWidth, opacity: itemOpacity, strokeColor: itemStrokeColor, blur: itemBlur } = (0, useFileItem_1.useFileItem)(item, sectionId);
|
|
35
|
+
const itemAngle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
|
|
39
36
|
const [wrapperRef, setWrapperRef] = (0, react_1.useState)(null);
|
|
40
|
-
const [imgRef, setImgRef] = (0, react_1.useState)(null);
|
|
41
37
|
(0, useRegisterResize_1.useRegisterResize)(wrapperRef, onResize);
|
|
42
38
|
const { url, hasGLEffect, fragmentShader, FXControls, FXCursor } = item.commonParams;
|
|
43
39
|
const fxCanvas = (0, react_1.useRef)(null);
|
|
@@ -49,17 +45,14 @@ const ImageItem = ({ item, sectionId, onResize }) => {
|
|
|
49
45
|
acc[control.shaderParam] = control.value;
|
|
50
46
|
return acc;
|
|
51
47
|
}, {});
|
|
52
|
-
const layoutValues = [item.area, item.layoutParams
|
|
48
|
+
const layoutValues = [item.area, item.layoutParams];
|
|
53
49
|
const fullShaderCode = `${baseVariables}\n${controlsVariables}\n${fragmentShader}`;
|
|
54
50
|
const area = layoutId ? item.area[layoutId] : null;
|
|
55
51
|
const exemplary = (_a = layouts === null || layouts === void 0 ? void 0 : layouts.find(l => l.id === layoutId)) === null || _a === void 0 ? void 0 : _a.exemplary;
|
|
56
52
|
const width = area && exemplary ? area.width * exemplary : 0;
|
|
57
53
|
const height = area && exemplary ? area.height * exemplary : 0;
|
|
58
|
-
const
|
|
59
|
-
const
|
|
60
|
-
(0, useStatesTransitions_1.useStatesTransitions)(wrapperRef, item.state, ['angle', 'opacity', 'blur']);
|
|
61
|
-
(0, useStatesTransitions_1.useStatesTransitions)(imgRef, item.state, ['strokeWidth', 'radius', 'strokeColor']);
|
|
62
|
-
(0, useStatesTransitions_1.useStatesTransitions)(fxCanvas.current, item.state, ['strokeWidth', 'radius', 'strokeColor']);
|
|
54
|
+
const wrapperStateParams = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['angle', 'opacity', 'blur']);
|
|
55
|
+
const imgStateParams = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['strokeWidth', 'radius', 'strokeColor']);
|
|
63
56
|
(0, react_1.useEffect)(() => {
|
|
64
57
|
isInitialRef.current = false;
|
|
65
58
|
}, []);
|
|
@@ -72,8 +65,18 @@ const ImageItem = ({ item, sectionId, onResize }) => {
|
|
|
72
65
|
const rect = (0, useElementRect_1.useElementRect)(wrapperRef);
|
|
73
66
|
const rectWidth = Math.floor((_b = rect === null || rect === void 0 ? void 0 : rect.width) !== null && _b !== void 0 ? _b : 0);
|
|
74
67
|
const rectHeight = Math.floor((_c = rect === null || rect === void 0 ? void 0 : rect.height) !== null && _c !== void 0 ? _c : 0);
|
|
75
|
-
const
|
|
76
|
-
|
|
68
|
+
const borderColor = (0, react_1.useMemo)(() => {
|
|
69
|
+
var _a;
|
|
70
|
+
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);
|
|
71
|
+
return borderColor ? color_1.CntrlColor.parse(borderColor) : undefined;
|
|
72
|
+
}, [itemStrokeColor, (_d = imgStateParams === null || imgStateParams === void 0 ? void 0 : imgStateParams.styles) === null || _d === void 0 ? void 0 : _d.strokeColor]);
|
|
73
|
+
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);
|
|
74
|
+
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);
|
|
75
|
+
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);
|
|
76
|
+
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);
|
|
77
|
+
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);
|
|
78
|
+
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' });
|
|
79
|
+
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)` } : {})), { transition: (_o = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.transition) !== null && _o !== void 0 ? _o : 'none' }), children: hasGLEffect && isFXAllowed ? ((0, jsx_runtime_1.jsx)("canvas", { style: inlineStyles, ref: fxCanvas, className: `img-canvas image-${item.id}`, width: rectWidth, height: rectHeight })) : ((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: `
|
|
77
80
|
.image-wrapper-${item.id} {
|
|
78
81
|
position: absolute;
|
|
79
82
|
width: 100%;
|
|
@@ -99,9 +102,7 @@ const ImageItem = ({ item, sectionId, onResize }) => {
|
|
|
99
102
|
border-width: 0;
|
|
100
103
|
box-sizing: border-box;
|
|
101
104
|
}
|
|
102
|
-
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams
|
|
103
|
-
const wrapperStatesCSS = (0, getStatesCSS_1.getStatesCSS)(item.id, 'image-wrapper', ['angle', 'opacity', 'blur'], stateParams);
|
|
104
|
-
const imgStatesCSS = (0, getStatesCSS_1.getStatesCSS)(item.id, 'image', ['strokeWidth', 'radius', 'strokeColor'], stateParams);
|
|
105
|
+
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams]) => {
|
|
105
106
|
return (`
|
|
106
107
|
.image-wrapper-${item.id} {
|
|
107
108
|
opacity: ${layoutParams.opacity};
|
|
@@ -113,8 +114,6 @@ const ImageItem = ({ item, sectionId, onResize }) => {
|
|
|
113
114
|
border-radius: ${layoutParams.radius * 100}vw;
|
|
114
115
|
border-width: ${layoutParams.strokeWidth * 100}vw;
|
|
115
116
|
}
|
|
116
|
-
${wrapperStatesCSS}
|
|
117
|
-
${imgStatesCSS}
|
|
118
117
|
`);
|
|
119
118
|
})}
|
|
120
119
|
` })] }) }));
|
|
@@ -14,26 +14,35 @@ const useRectangleItem_1 = require("./useRectangleItem");
|
|
|
14
14
|
const useItemAngle_1 = require("../useItemAngle");
|
|
15
15
|
const useCntrlContext_1 = require("../../provider/useCntrlContext");
|
|
16
16
|
const useRegisterResize_1 = require("../../common/useRegisterResize");
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
const RectangleItem = ({ item, sectionId, onResize }) => {
|
|
21
|
-
var _a, _b;
|
|
17
|
+
const getStyleFromItemStateAndParams_1 = require("../../utils/getStyleFromItemStateAndParams");
|
|
18
|
+
const RectangleItem = ({ item, sectionId, onResize, interactionCtrl }) => {
|
|
19
|
+
var _a, _b, _c, _d;
|
|
22
20
|
const id = (0, react_1.useId)();
|
|
23
21
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
24
|
-
const { fillColor, radius, strokeWidth, strokeColor, blur, backdropBlur } = (0, useRectangleItem_1.useRectangleItem)(item, sectionId);
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const
|
|
22
|
+
const { fillColor: itemFillColor, radius: itemRadius, strokeWidth: itemStrokeWidth, strokeColor: itemStrokeColor, blur: itemBlur, backdropBlur: itemBackdropBlur } = (0, useRectangleItem_1.useRectangleItem)(item, sectionId);
|
|
23
|
+
const itemAngle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
|
|
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]);
|
|
34
|
+
const layoutValues = [item.area, item.layoutParams];
|
|
29
35
|
const [ref, setRef] = (0, react_1.useState)(null);
|
|
30
|
-
const statesClassNames = (0, useStatesClassNames_1.useStatesClassNames)(item.id, item.state, 'rectangle');
|
|
31
36
|
(0, useRegisterResize_1.useRegisterResize)(ref, onResize);
|
|
37
|
+
const backdropBlur = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)(styles === null || styles === void 0 ? void 0 : styles.backdropBlur, itemBackdropBlur);
|
|
38
|
+
const radius = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)(styles === null || styles === void 0 ? void 0 : styles.radius, itemRadius);
|
|
39
|
+
const strokeWidth = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)(styles === null || styles === void 0 ? void 0 : styles.strokeWidth, itemStrokeWidth);
|
|
40
|
+
const angle = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)(styles === null || styles === void 0 ? void 0 : styles.angle, itemAngle);
|
|
41
|
+
const blur = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)(styles === null || styles === void 0 ? void 0 : styles.blur, itemBlur);
|
|
32
42
|
const backdropFilterValue = backdropBlur ? `blur(${backdropBlur * 100}vw)` : undefined;
|
|
33
|
-
(0,
|
|
34
|
-
return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { url: (_a = item.link) === null || _a === void 0 ? void 0 : _a.url, target: (_b = item.link) === null || _b === void 0 ? void 0 : _b.target, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `rectangle-${item.id} ${statesClassNames}`, ref: setRef, style: 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)` } : {})), (backdropFilterValue !== undefined
|
|
43
|
+
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({}, (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)` } : {})), (backdropFilterValue !== undefined
|
|
35
44
|
? { backdropFilter: backdropFilterValue, WebkitBackdropFilter: backdropFilterValue }
|
|
36
|
-
: {})) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
45
|
+
: {})), { 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: `
|
|
37
46
|
.rectangle-${item.id} {
|
|
38
47
|
position: absolute;
|
|
39
48
|
width: 100%;
|
|
@@ -41,8 +50,7 @@ const RectangleItem = ({ item, sectionId, onResize }) => {
|
|
|
41
50
|
border-style: solid;
|
|
42
51
|
box-sizing: border-box;
|
|
43
52
|
}
|
|
44
|
-
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams
|
|
45
|
-
const statesCSS = (0, getStatesCSS_1.getStatesCSS)(item.id, 'rectangle', ['angle', 'fillColor', 'strokeWidth', 'radius', 'strokeColor', 'blur', 'backdropBlur'], states);
|
|
53
|
+
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams]) => {
|
|
46
54
|
return (`
|
|
47
55
|
.rectangle-${item.id} {
|
|
48
56
|
background-color: ${color_1.CntrlColor.parse(layoutParams.fillColor).fmt('rgba')};
|
|
@@ -54,7 +62,6 @@ const RectangleItem = ({ item, sectionId, onResize }) => {
|
|
|
54
62
|
backdrop-filter: ${layoutParams.backdropFilter !== 0 ? `blur(${layoutParams.blur * 100}vw)` : 'unset'};
|
|
55
63
|
-webkit-backdrop-filter: ${layoutParams.backdropFilter !== 0 ? `blur(${layoutParams.blur * 100}vw)` : 'unset'};
|
|
56
64
|
}
|
|
57
|
-
${statesCSS}
|
|
58
65
|
`);
|
|
59
66
|
})}
|
|
60
67
|
` })] }) }));
|
|
@@ -16,25 +16,32 @@ const useRegisterResize_1 = require("../../common/useRegisterResize");
|
|
|
16
16
|
const getFontFamilyValue_1 = require("../../utils/getFontFamilyValue");
|
|
17
17
|
const useExemplary_1 = require("../../common/useExemplary");
|
|
18
18
|
const useItemAngle_1 = require("../useItemAngle");
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
const RichTextItem = ({ item, sectionId, onResize }) => {
|
|
19
|
+
const getStyleFromItemStateAndParams_1 = require("../../utils/getStyleFromItemStateAndParams");
|
|
20
|
+
const RichTextItem = ({ item, sectionId, onResize, interactionCtrl }) => {
|
|
21
|
+
var _a, _b;
|
|
23
22
|
const [content, styles] = (0, useRichTextItem_1.useRichTextItem)(item);
|
|
24
23
|
const id = (0, react_1.useId)();
|
|
25
24
|
const [ref, setRef] = (0, react_1.useState)(null);
|
|
26
25
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
27
|
-
const
|
|
28
|
-
const { blur, wordSpacing, letterSpacing, color, fontSize, lineHeight } = (0, useRichTextItemValues_1.useRichTextItemValues)(item, sectionId);
|
|
29
|
-
const
|
|
30
|
-
const layoutValues = [item.area, item.layoutParams, item.state];
|
|
26
|
+
const itemAngle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
|
|
27
|
+
const { blur: itemBlur, wordSpacing: itemWordSpacing, letterSpacing: itemLetterSpacing, color: itemColor, fontSize, lineHeight } = (0, useRichTextItemValues_1.useRichTextItemValues)(item, sectionId);
|
|
28
|
+
const layoutValues = [item.area, item.layoutParams];
|
|
31
29
|
const exemplary = (0, useExemplary_1.useExemplary)();
|
|
32
|
-
const stateClassNames = (0, useStatesClassNames_1.useStatesClassNames)(item.id, item.state, 'rich-text-wrapper');
|
|
33
30
|
(0, useRegisterResize_1.useRegisterResize)(ref, onResize);
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
const stateParams = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['angle', 'blur', 'letterSpacing', 'wordSpacing', 'color']);
|
|
32
|
+
const stateStyles = (_a = stateParams === null || stateParams === void 0 ? void 0 : stateParams.styles) !== null && _a !== void 0 ? _a : {};
|
|
33
|
+
const transition = (_b = stateParams === null || stateParams === void 0 ? void 0 : stateParams.transition) !== null && _b !== void 0 ? _b : 'none';
|
|
34
|
+
const textColor = (0, react_1.useMemo)(() => {
|
|
35
|
+
var _a;
|
|
36
|
+
const color = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_a = stateParams === null || stateParams === void 0 ? void 0 : stateParams.styles) === null || _a === void 0 ? void 0 : _a.color, itemColor);
|
|
37
|
+
return color ? color_1.CntrlColor.parse(color) : undefined;
|
|
38
|
+
}, [itemColor, stateStyles.color]);
|
|
39
|
+
const angle = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)(stateStyles.angle, itemAngle);
|
|
40
|
+
const blur = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)(stateStyles.blur, itemBlur);
|
|
41
|
+
const letterSpacing = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)(stateStyles.letterSpacing, itemLetterSpacing);
|
|
42
|
+
const wordSpacing = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)(stateStyles.wordSpacing, itemWordSpacing);
|
|
43
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { ref: setRef, className: `rich-text-wrapper-${item.id}`, style: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), (textColor ? { color: `${textColor.fmt('rgba')}` } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (letterSpacing !== undefined ? { letterSpacing: `${letterSpacing * exemplary}px` } : {})), (wordSpacing !== undefined ? { wordSpacing: `${wordSpacing * exemplary}px` } : {})), (fontSize !== undefined ? { fontSize: `${Math.round(fontSize * exemplary)}px` } : {})), (lineHeight !== undefined ? { lineHeight: `${lineHeight * exemplary}px` } : {})), { transition }), children: content }), (0, jsx_runtime_1.jsxs)(style_1.default, { id: id, children: [styles, `${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams]) => {
|
|
36
44
|
const color = color_1.CntrlColor.parse(layoutParams.color);
|
|
37
|
-
const statesCSS = (0, getStatesCSS_1.getStatesCSS)(item.id, 'rich-text-wrapper', ['angle', 'blur', 'letterSpacing', 'wordSpacing', 'color'], states);
|
|
38
45
|
return (`
|
|
39
46
|
.rich-text-wrapper-${item.id} {
|
|
40
47
|
font-size: ${layoutParams.fontSize * 100}vw;
|
|
@@ -56,7 +63,6 @@ const RichTextItem = ({ item, sectionId, onResize }) => {
|
|
|
56
63
|
color: ${color.fmt('rgba')};
|
|
57
64
|
}
|
|
58
65
|
}
|
|
59
|
-
${statesCSS}
|
|
60
66
|
`);
|
|
61
67
|
})}`] })] }));
|
|
62
68
|
};
|