@cntrl-site/sdk-nextjs 1.0.19 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/jest.config.js +2 -2
- package/lib/components/Article.js +9 -8
- package/lib/components/Head.js +1 -1
- package/lib/components/Item.js +39 -21
- package/lib/components/items/CodeEmbedItem.js +15 -12
- package/lib/components/items/CustomItem.js +7 -9
- package/lib/components/items/GroupItem.js +15 -12
- package/lib/components/items/ImageItem.js +28 -21
- package/lib/components/items/RectangleItem.js +28 -15
- package/lib/components/items/RichTextItem.js +33 -12
- package/lib/components/items/VideoItem.js +26 -19
- package/lib/components/items/VimeoEmbed.js +22 -20
- package/lib/components/items/YoutubeEmbed.js +20 -18
- 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 +23 -0
- package/lib/utils/getStyleFromItemStateAndParams.js +9 -0
- package/package.json +7 -4
- package/src/components/Article.tsx +30 -27
- package/src/components/ArticleWrapper.tsx +1 -2
- package/src/components/Head.tsx +0 -1
- package/src/components/Item.tsx +75 -29
- package/src/components/items/CodeEmbedItem.tsx +15 -11
- package/src/components/items/CustomItem.tsx +9 -11
- package/src/components/items/GroupItem.tsx +17 -13
- package/src/components/items/ImageItem.tsx +35 -20
- package/src/components/items/RectangleItem.tsx +35 -14
- package/src/components/items/RichTextItem.tsx +41 -14
- package/src/components/items/VideoItem.tsx +34 -20
- package/src/components/items/VimeoEmbed.tsx +27 -19
- package/src/components/items/YoutubeEmbed.tsx +20 -18
- 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 +97 -0
- package/src/provider/InteractionsContext.tsx +28 -0
- package/src/utils/getStyleFromItemStateAndParams.ts +8 -0
- package/lib/utils/HoverStyles/HoverStyles.js +0 -77
- package/src/utils/HoverStyles/HoverStyles.ts +0 -85
package/jest.config.js
CHANGED
|
@@ -12,6 +12,7 @@ const Item_1 = require("./Item");
|
|
|
12
12
|
const useArticleRectObserver_1 = require("../utils/ArticleRectManager/useArticleRectObserver");
|
|
13
13
|
const ArticleRectContext_1 = require("../provider/ArticleRectContext");
|
|
14
14
|
const ArticleWrapper_1 = require("./ArticleWrapper");
|
|
15
|
+
const InteractionsContext_1 = require("../provider/InteractionsContext");
|
|
15
16
|
const Article = ({ article, sectionData }) => {
|
|
16
17
|
const articleRef = (0, react_1.useRef)(null);
|
|
17
18
|
const articleRectObserver = (0, useArticleRectObserver_1.useArticleRectObserver)(articleRef.current);
|
|
@@ -24,14 +25,14 @@ const Article = ({ article, sectionData }) => {
|
|
|
24
25
|
setArticleHeight(rect.height / rect.width);
|
|
25
26
|
});
|
|
26
27
|
}, [articleRectObserver]);
|
|
27
|
-
return ((0, jsx_runtime_1.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
+
const data = section.name ? sectionData[section.name] : {};
|
|
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
|
+
}) }) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
31
32
|
.article {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
` })] }));
|
|
33
|
+
position: relative;
|
|
34
|
+
overflow: clip;
|
|
35
|
+
}
|
|
36
|
+
` })] }) }));
|
|
36
37
|
};
|
|
37
38
|
exports.Article = Article;
|
package/lib/components/Head.js
CHANGED
|
@@ -25,7 +25,7 @@ const CNTRLHead = ({ meta, project }) => {
|
|
|
25
25
|
return;
|
|
26
26
|
return ((0, jsx_runtime_1.jsx)("link", { rel: rel, href: href }, `link-${rel}-${href}`));
|
|
27
27
|
});
|
|
28
|
-
return ((0, jsx_runtime_1.jsxs)(head_1.default, { children: [(0, jsx_runtime_1.jsx)("title", { children: meta.title }), (0, jsx_runtime_1.jsx)("meta", { name: "description", content: meta.description }), (0, jsx_runtime_1.jsx)("meta", { name: "og:description", content: meta.description }), (0, jsx_runtime_1.jsx)("meta", { name: "twitter:description", content: meta.description }), (0, jsx_runtime_1.jsx)("meta", { name: "keywords", content: meta.keywords }), (0, jsx_runtime_1.jsx)("meta", { name: "og:image", content: meta.opengraphThumbnail }), (0, jsx_runtime_1.jsx)("meta", { name: "
|
|
28
|
+
return ((0, jsx_runtime_1.jsxs)(head_1.default, { children: [(0, jsx_runtime_1.jsx)("title", { children: meta.title }), (0, jsx_runtime_1.jsx)("meta", { name: "description", content: meta.description }), (0, jsx_runtime_1.jsx)("meta", { name: "og:description", content: meta.description }), (0, jsx_runtime_1.jsx)("meta", { name: "twitter:description", content: meta.description }), (0, jsx_runtime_1.jsx)("meta", { name: "keywords", content: meta.keywords }), (0, jsx_runtime_1.jsx)("meta", { name: "og:image", content: meta.opengraphThumbnail }), (0, jsx_runtime_1.jsx)("meta", { name: "generator", content: "https://cntrl.site" }), (0, jsx_runtime_1.jsx)("link", { rel: "icon", href: meta.favicon }), customFonts.length > 0 && ((0, jsx_runtime_1.jsx)("style", { dangerouslySetInnerHTML: {
|
|
29
29
|
__html: ffGenerator.generate()
|
|
30
30
|
} })), links, htmlHead] }));
|
|
31
31
|
};
|
package/lib/components/Item.js
CHANGED
|
@@ -21,7 +21,6 @@ const useItemDimensions_1 = require("./useItemDimensions");
|
|
|
21
21
|
const useItemScale_1 = require("./useItemScale");
|
|
22
22
|
const ScaleAnchorMap_1 = require("../utils/ScaleAnchorMap");
|
|
23
23
|
const useSectionHeightMap_1 = require("./useSectionHeightMap");
|
|
24
|
-
const HoverStyles_1 = require("../utils/HoverStyles/HoverStyles");
|
|
25
24
|
const getItemTopStyle_1 = require("../utils/getItemTopStyle");
|
|
26
25
|
const useStickyItemTop_1 = require("./items/useStickyItemTop");
|
|
27
26
|
const getAnchoredItemTop_1 = require("../utils/getAnchoredItemTop");
|
|
@@ -31,6 +30,7 @@ const useExemplary_1 = require("../common/useExemplary");
|
|
|
31
30
|
const GroupItem_1 = require("./items/GroupItem");
|
|
32
31
|
const CodeEmbedItem_1 = require("./items/CodeEmbedItem");
|
|
33
32
|
const KeyframesContext_1 = require("../provider/KeyframesContext");
|
|
33
|
+
const useItemInteractionCtrl_1 = require("../interactions/useItemInteractionCtrl");
|
|
34
34
|
const itemsMap = {
|
|
35
35
|
[sdk_1.ArticleItemType.Rectangle]: RectangleItem_1.RectangleItem,
|
|
36
36
|
[sdk_1.ArticleItemType.Image]: ImageItem_1.ImageItem,
|
|
@@ -52,8 +52,10 @@ const RichTextWrapper = ({ isRichText, children }) => {
|
|
|
52
52
|
return ((0, jsx_runtime_1.jsx)("div", { style: { transformOrigin: 'top left', transform: 'scale(var(--layout-deviation))' }, children: children }));
|
|
53
53
|
};
|
|
54
54
|
const noop = () => null;
|
|
55
|
-
const Item = ({ item, sectionId, articleHeight, isInGroup = false }) => {
|
|
55
|
+
const Item = ({ item, sectionId, articleHeight, isParentVisible = true, isInGroup = false }) => {
|
|
56
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
56
57
|
const itemWrapperRef = (0, react_1.useRef)(null);
|
|
58
|
+
const itemInnerRef = (0, react_1.useRef)(null);
|
|
57
59
|
const rectObserver = (0, react_1.useContext)(ArticleRectContext_1.ArticleRectContext);
|
|
58
60
|
const keyframesRepo = (0, react_1.useContext)(KeyframesContext_1.KeyframesContext);
|
|
59
61
|
const id = (0, react_1.useId)();
|
|
@@ -61,14 +63,21 @@ const Item = ({ item, sectionId, articleHeight, isInGroup = false }) => {
|
|
|
61
63
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
62
64
|
const layout = (0, useLayoutContext_1.useLayoutContext)();
|
|
63
65
|
const exemplary = (0, useExemplary_1.useExemplary)();
|
|
66
|
+
const [allowPointerEvents, setAllowPointerEvents] = (0, react_1.useState)(isParentVisible);
|
|
64
67
|
const [wrapperHeight, setWrapperHeight] = (0, react_1.useState)(undefined);
|
|
65
68
|
const [itemHeight, setItemHeight] = (0, react_1.useState)(undefined);
|
|
66
|
-
const
|
|
67
|
-
const
|
|
69
|
+
const itemScale = (0, useItemScale_1.useItemScale)(item, sectionId);
|
|
70
|
+
const interactionCtrl = (0, useItemInteractionCtrl_1.useItemInteractionCtrl)(item.id);
|
|
71
|
+
const wrapperStateProps = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['top', 'left']);
|
|
72
|
+
const innerStateProps = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['width', 'height', 'scale']);
|
|
73
|
+
const position = (0, useItemPosition_1.useItemPosition)(item, sectionId, {
|
|
74
|
+
top: (_a = wrapperStateProps === null || wrapperStateProps === void 0 ? void 0 : wrapperStateProps.styles) === null || _a === void 0 ? void 0 : _a.top,
|
|
75
|
+
left: (_b = wrapperStateProps === null || wrapperStateProps === void 0 ? void 0 : wrapperStateProps.styles) === null || _b === void 0 ? void 0 : _b.left,
|
|
76
|
+
});
|
|
68
77
|
const sectionHeight = (0, useSectionHeightMap_1.useSectionHeightData)(sectionId);
|
|
69
78
|
const stickyTop = (0, useStickyItemTop_1.useStickyItemTop)(item, sectionHeight, sectionId);
|
|
70
79
|
const dimensions = (0, useItemDimensions_1.useItemDimensions)(item, sectionId);
|
|
71
|
-
const layoutValues = [item.area, item.hidden
|
|
80
|
+
const layoutValues = [item.area, item.hidden];
|
|
72
81
|
const isInitialRef = (0, react_1.useRef)(true);
|
|
73
82
|
layoutValues.push(item.sticky);
|
|
74
83
|
layoutValues.push(sectionHeight);
|
|
@@ -98,23 +107,41 @@ const Item = ({ item, sectionId, articleHeight, isInGroup = false }) => {
|
|
|
98
107
|
setItemHeight(height);
|
|
99
108
|
setWrapperHeight(wrapperHeight);
|
|
100
109
|
};
|
|
110
|
+
const handleVisibilityChange = (0, react_1.useCallback)((isVisible) => {
|
|
111
|
+
if (!isParentVisible)
|
|
112
|
+
return;
|
|
113
|
+
setAllowPointerEvents(isVisible);
|
|
114
|
+
}, [isParentVisible]);
|
|
101
115
|
(0, react_1.useEffect)(() => {
|
|
102
116
|
isInitialRef.current = false;
|
|
103
117
|
}, []);
|
|
104
118
|
const isRichText = isItemType(item, sdk_1.ArticleItemType.RichText);
|
|
105
|
-
|
|
119
|
+
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);
|
|
120
|
+
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);
|
|
121
|
+
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;
|
|
122
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: `item-wrapper-${item.id}`, ref: itemWrapperRef, onTransitionEnd: (e) => {
|
|
123
|
+
var _a;
|
|
124
|
+
e.stopPropagation();
|
|
125
|
+
(_a = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.handleTransitionEnd) === null || _a === void 0 ? void 0 : _a.call(interactionCtrl, e.propertyName);
|
|
126
|
+
}, 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: {
|
|
106
127
|
opacity: (keyframes.length !== 0 && !layout) ? 0 : 1,
|
|
107
128
|
top: `${stickyTop * 100}vw`,
|
|
108
129
|
height: isRichText && itemHeight ? `${itemHeight * 100}vw` : 'unset',
|
|
109
|
-
}, children: (0, jsx_runtime_1.jsx)(RichTextWrapper, { isRichText: isRichText, children: (0, jsx_runtime_1.jsx)("div", { className: `item-${item.id}-inner`,
|
|
130
|
+
}, children: (0, jsx_runtime_1.jsx)(RichTextWrapper, { isRichText: isRichText, children: (0, jsx_runtime_1.jsx)("div", { className: `item-${item.id}-inner`, ref: itemInnerRef, onClick: () => {
|
|
131
|
+
interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.sendTrigger('click');
|
|
132
|
+
}, onMouseEnter: () => {
|
|
133
|
+
interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.sendTrigger('hover-in');
|
|
134
|
+
}, onMouseLeave: () => {
|
|
135
|
+
interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.sendTrigger('hover-out');
|
|
136
|
+
}, style: Object.assign(Object.assign(Object.assign({}, ((width && height) ? {
|
|
110
137
|
width: `${sizingAxis.x === 'manual'
|
|
111
138
|
? isRichText
|
|
112
|
-
? `${
|
|
113
|
-
: `${
|
|
139
|
+
? `${width * exemplary}px`
|
|
140
|
+
: `${width * 100}vw`
|
|
114
141
|
: 'max-content'}`,
|
|
115
|
-
height: `${sizingAxis.y === 'manual' ? `${
|
|
116
|
-
} : {})), (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: `
|
|
117
|
-
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, hidden,
|
|
142
|
+
height: `${sizingAxis.y === 'manual' ? `${height * 100}vw` : 'unset'}`
|
|
143
|
+
} : {})), (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', pointerEvents: allowPointerEvents ? 'auto' : 'none' }), children: (0, jsx_runtime_1.jsx)(ItemComponent, { item: item, sectionId: sectionId, onResize: handleItemResize, articleHeight: articleHeight, interactionCtrl: interactionCtrl, onVisibilityChange: handleVisibilityChange }) }) }) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
144
|
+
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, hidden, sticky, sectionHeight, layoutParams], exemplary) => {
|
|
118
145
|
const sizingAxis = parseSizing(layoutParams.sizing);
|
|
119
146
|
const isScreenBasedBottom = area.positionType === sdk_1.PositionType.ScreenBased && area.anchorSide === sdk_1.AnchorSide.Bottom;
|
|
120
147
|
const scaleAnchor = area.scaleAnchor;
|
|
@@ -128,8 +155,6 @@ const Item = ({ item, sectionId, articleHeight, isInGroup = false }) => {
|
|
|
128
155
|
height: fit-content;
|
|
129
156
|
}
|
|
130
157
|
.item-${item.id}-inner {
|
|
131
|
-
transition: ${(0, HoverStyles_1.getTransitions)(['width', 'height', 'scale'], hoverParams)};
|
|
132
|
-
pointer-events: auto;
|
|
133
158
|
width: ${sizingAxis.x === 'manual'
|
|
134
159
|
? `${area.width * 100}vw`
|
|
135
160
|
: 'max-content'};
|
|
@@ -145,13 +170,6 @@ const Item = ({ item, sectionId, articleHeight, isInGroup = false }) => {
|
|
|
145
170
|
bottom: ${isScreenBasedBottom ? `${-area.top * 100}vw` : 'unset'};
|
|
146
171
|
top: ${isScreenBasedBottom ? 'unset' : (0, getItemTopStyle_1.getItemTopStyle)(area.top, area.anchorSide)};
|
|
147
172
|
left: ${area.left * 100}vw;
|
|
148
|
-
transition: ${(0, HoverStyles_1.getTransitions)(['left', 'top'], hoverParams)};
|
|
149
|
-
}
|
|
150
|
-
.item-${item.id}-inner:hover {
|
|
151
|
-
${(0, HoverStyles_1.getHoverStyles)(['width', 'height', 'scale'], hoverParams)};
|
|
152
|
-
}
|
|
153
|
-
.item-wrapper-${item.id}:hover {
|
|
154
|
-
${(0, HoverStyles_1.getHoverStyles)(['left', 'top'], hoverParams, area.anchorSide)};
|
|
155
173
|
}
|
|
156
174
|
`);
|
|
157
175
|
})}
|
|
@@ -8,7 +8,6 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
8
8
|
const sdk_1 = require("@cntrl-site/sdk");
|
|
9
9
|
const react_1 = require("react");
|
|
10
10
|
const useCntrlContext_1 = require("../../provider/useCntrlContext");
|
|
11
|
-
const HoverStyles_1 = require("../../utils/HoverStyles/HoverStyles");
|
|
12
11
|
const style_1 = __importDefault(require("styled-jsx/style"));
|
|
13
12
|
const useRegisterResize_1 = require("../../common/useRegisterResize");
|
|
14
13
|
const useItemAngle_1 = require("../useItemAngle");
|
|
@@ -25,17 +24,21 @@ const stylesMap = {
|
|
|
25
24
|
[sdk_1.AreaAnchor.BottomCenter]: { justifyContent: 'center', alignItems: 'flex-end' },
|
|
26
25
|
[sdk_1.AreaAnchor.BottomRight]: { justifyContent: 'flex-end', alignItems: 'flex-end' }
|
|
27
26
|
};
|
|
28
|
-
const CodeEmbedItem = ({ item, sectionId, onResize }) => {
|
|
29
|
-
var _a, _b;
|
|
27
|
+
const CodeEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityChange }) => {
|
|
28
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
30
29
|
const id = (0, react_1.useId)();
|
|
31
30
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
32
|
-
const { anchor, blur, opacity } = (0, useCodeEmbedItem_1.useCodeEmbedItem)(item, sectionId);
|
|
33
|
-
const
|
|
31
|
+
const { anchor, blur: itemBlur, opacity: itemOpacity } = (0, useCodeEmbedItem_1.useCodeEmbedItem)(item, sectionId);
|
|
32
|
+
const itemAngle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
|
|
34
33
|
const { html } = item.commonParams;
|
|
35
34
|
const [ref, setRef] = (0, react_1.useState)(null);
|
|
36
35
|
(0, useRegisterResize_1.useRegisterResize)(ref, onResize);
|
|
37
36
|
const pos = stylesMap[anchor];
|
|
38
|
-
const layoutValues = [item.area, item.layoutParams
|
|
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;
|
|
39
42
|
(0, react_1.useEffect)(() => {
|
|
40
43
|
if (!ref)
|
|
41
44
|
return;
|
|
@@ -58,7 +61,11 @@ const CodeEmbedItem = ({ item, sectionId, onResize }) => {
|
|
|
58
61
|
return;
|
|
59
62
|
iframe.srcdoc = item.commonParams.html;
|
|
60
63
|
}, [item.commonParams.html, item.commonParams.iframe, ref]);
|
|
61
|
-
|
|
64
|
+
const isInteractive = opacity !== 0;
|
|
65
|
+
(0, react_1.useEffect)(() => {
|
|
66
|
+
onVisibilityChange === null || onVisibilityChange === void 0 ? void 0 : onVisibilityChange(isInteractive);
|
|
67
|
+
}, [isInteractive, onVisibilityChange]);
|
|
68
|
+
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: `
|
|
62
69
|
.embed-wrapper-${item.id} {
|
|
63
70
|
position: absolute;
|
|
64
71
|
width: 100%;
|
|
@@ -70,21 +77,17 @@ const CodeEmbedItem = ({ item, sectionId, onResize }) => {
|
|
|
70
77
|
z-index: 1;
|
|
71
78
|
border: none;
|
|
72
79
|
}
|
|
73
|
-
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams
|
|
80
|
+
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams], exemplary) => {
|
|
74
81
|
return (`
|
|
75
82
|
.embed-wrapper-${item.id} {
|
|
76
83
|
opacity: ${layoutParams.opacity};
|
|
77
84
|
transform: rotate(${area.angle}deg);
|
|
78
85
|
filter: ${layoutParams.blur !== 0 ? `blur(${layoutParams.blur * 100}vw)` : 'unset'};
|
|
79
|
-
transition: ${(0, HoverStyles_1.getTransitions)(['angle', 'blur', 'opacity'], hoverParams)};
|
|
80
86
|
}
|
|
81
87
|
.embed-${item.id} {
|
|
82
88
|
width: ${item.commonParams.scale ? `${area.width * exemplary}px` : '100%'};
|
|
83
89
|
height: ${item.commonParams.scale ? `${area.height * exemplary}px` : '100%'};
|
|
84
90
|
}
|
|
85
|
-
.embed-wrapper-${item.id}:hover {
|
|
86
|
-
${(0, HoverStyles_1.getHoverStyles)(['angle', 'blur', 'opacity'], hoverParams)}
|
|
87
|
-
}
|
|
88
91
|
`);
|
|
89
92
|
})}
|
|
90
93
|
` })] }));
|
|
@@ -8,34 +8,32 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
8
8
|
const sdk_1 = require("@cntrl-site/sdk");
|
|
9
9
|
const react_1 = require("react");
|
|
10
10
|
const useCntrlContext_1 = require("../../provider/useCntrlContext");
|
|
11
|
-
const HoverStyles_1 = require("../../utils/HoverStyles/HoverStyles");
|
|
12
11
|
const style_1 = __importDefault(require("styled-jsx/style"));
|
|
13
12
|
const useRegisterResize_1 = require("../../common/useRegisterResize");
|
|
14
13
|
const useItemAngle_1 = require("../useItemAngle");
|
|
15
|
-
const CustomItem = ({ item, onResize, sectionId }) => {
|
|
14
|
+
const CustomItem = ({ item, onResize, sectionId, interactionCtrl }) => {
|
|
15
|
+
var _a, _b, _c;
|
|
16
16
|
const sdk = (0, useCntrlContext_1.useCntrlContext)();
|
|
17
17
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
18
|
-
const
|
|
18
|
+
const itemAngle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
|
|
19
19
|
const component = sdk.customItems.get(item.commonParams.name);
|
|
20
|
-
const layoutValues = [item.area
|
|
20
|
+
const layoutValues = [item.area];
|
|
21
21
|
const [ref, setRef] = (0, react_1.useState)(null);
|
|
22
22
|
(0, useRegisterResize_1.useRegisterResize)(ref, onResize);
|
|
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;
|
|
23
25
|
if (!component)
|
|
24
26
|
return null;
|
|
25
|
-
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({}, (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), children: component({}) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: item.id, children: `${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area
|
|
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]) => {
|
|
26
28
|
return (`
|
|
27
29
|
.custom-component-${item.id} {
|
|
28
30
|
transform: rotate(${area.angle}deg);
|
|
29
|
-
transition: ${(0, HoverStyles_1.getTransitions)(['angle'], hoverParams)};
|
|
30
31
|
height: 100%;
|
|
31
32
|
width: 100%;
|
|
32
33
|
position: absolute;
|
|
33
34
|
left: 0;
|
|
34
35
|
top: 0;
|
|
35
36
|
}
|
|
36
|
-
.custom-component-${item.id}:hover {
|
|
37
|
-
${(0, HoverStyles_1.getHoverStyles)(['angle'], hoverParams)};
|
|
38
|
-
}
|
|
39
37
|
`);
|
|
40
38
|
})}` })] }));
|
|
41
39
|
};
|
|
@@ -9,38 +9,41 @@ const react_1 = require("react");
|
|
|
9
9
|
const Item_1 = require("../Item");
|
|
10
10
|
const style_1 = __importDefault(require("styled-jsx/style"));
|
|
11
11
|
const sdk_1 = require("@cntrl-site/sdk");
|
|
12
|
-
const HoverStyles_1 = require("../../utils/HoverStyles/HoverStyles");
|
|
13
12
|
const LinkWrapper_1 = require("../LinkWrapper");
|
|
14
13
|
const useRegisterResize_1 = require("../../common/useRegisterResize");
|
|
15
14
|
const useCntrlContext_1 = require("../../provider/useCntrlContext");
|
|
16
15
|
const useItemAngle_1 = require("../useItemAngle");
|
|
17
16
|
const useGroupItem_1 = require("./useGroupItem");
|
|
18
|
-
const
|
|
19
|
-
|
|
17
|
+
const getStyleFromItemStateAndParams_1 = require("../../utils/getStyleFromItemStateAndParams");
|
|
18
|
+
const GroupItem = ({ item, sectionId, onResize, articleHeight, interactionCtrl, onVisibilityChange }) => {
|
|
19
|
+
var _a, _b, _c, _d, _e;
|
|
20
20
|
const id = (0, react_1.useId)();
|
|
21
21
|
const { items } = item;
|
|
22
|
-
const
|
|
22
|
+
const itemAngle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
|
|
23
23
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
24
|
-
const { opacity } = (0, useGroupItem_1.useGroupItem)(item, sectionId);
|
|
25
|
-
const layoutValues = [item.area, item.layoutParams
|
|
24
|
+
const { opacity: itemOpacity } = (0, useGroupItem_1.useGroupItem)(item, sectionId);
|
|
25
|
+
const layoutValues = [item.area, item.layoutParams];
|
|
26
26
|
const [ref, setRef] = (0, react_1.useState)(null);
|
|
27
27
|
(0, useRegisterResize_1.useRegisterResize)(ref, onResize);
|
|
28
|
-
|
|
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
|
+
const isInteractive = opacity !== 0 && opacity !== undefined;
|
|
32
|
+
(0, react_1.useEffect)(() => {
|
|
33
|
+
onVisibilityChange === null || onVisibilityChange === void 0 ? void 0 : onVisibilityChange(isInteractive);
|
|
34
|
+
}, [isInteractive, onVisibilityChange]);
|
|
35
|
+
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, isParentVisible: isInteractive, isInGroup: true }, item.id))) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
29
36
|
.group-${item.id} {
|
|
30
37
|
position: absolute;
|
|
31
38
|
width: 100%;
|
|
32
39
|
height: 100%;
|
|
33
40
|
box-sizing: border-box;
|
|
34
41
|
}
|
|
35
|
-
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams
|
|
42
|
+
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams]) => {
|
|
36
43
|
return (`
|
|
37
44
|
.group-${item.id} {
|
|
38
45
|
opacity: ${layoutParams.opacity};
|
|
39
46
|
transform: rotate(${area.angle}deg);
|
|
40
|
-
transition: ${(0, HoverStyles_1.getTransitions)(['opacity', 'angle'], hoverParams)};
|
|
41
|
-
}
|
|
42
|
-
.group-${item.id}:hover {
|
|
43
|
-
${(0, HoverStyles_1.getHoverStyles)(['opacity', 'angle'], hoverParams)};
|
|
44
47
|
}
|
|
45
48
|
`);
|
|
46
49
|
})}
|
|
@@ -13,11 +13,11 @@ const LinkWrapper_1 = require("../LinkWrapper");
|
|
|
13
13
|
const useFileItem_1 = require("./useFileItem");
|
|
14
14
|
const useItemAngle_1 = require("../useItemAngle");
|
|
15
15
|
const useCntrlContext_1 = require("../../provider/useCntrlContext");
|
|
16
|
-
const HoverStyles_1 = require("../../utils/HoverStyles/HoverStyles");
|
|
17
16
|
const useRegisterResize_1 = require("../../common/useRegisterResize");
|
|
18
17
|
const useImageFx_1 = require("../../utils/effects/useImageFx");
|
|
19
18
|
const useElementRect_1 = require("../../utils/useElementRect");
|
|
20
19
|
const useLayoutContext_1 = require("../useLayoutContext");
|
|
20
|
+
const getStyleFromItemStateAndParams_1 = require("../../utils/getStyleFromItemStateAndParams");
|
|
21
21
|
const baseVariables = `precision mediump float;
|
|
22
22
|
uniform sampler2D u_image;
|
|
23
23
|
uniform sampler2D u_pattern;
|
|
@@ -26,16 +26,15 @@ uniform vec2 u_patternDimensions;
|
|
|
26
26
|
uniform float u_time;
|
|
27
27
|
uniform vec2 u_cursor;
|
|
28
28
|
varying vec2 v_texCoord;`;
|
|
29
|
-
const ImageItem = ({ item, sectionId, onResize }) => {
|
|
30
|
-
var _a, _b, _c, _d, _e;
|
|
29
|
+
const ImageItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityChange }) => {
|
|
30
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
31
31
|
const id = (0, react_1.useId)();
|
|
32
32
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
33
33
|
const layoutId = (0, useLayoutContext_1.useLayoutContext)();
|
|
34
|
-
const { radius, strokeWidth, opacity, strokeColor, blur } = (0, useFileItem_1.useFileItem)(item, sectionId);
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
(0, useRegisterResize_1.useRegisterResize)(ref, onResize);
|
|
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);
|
|
36
|
+
const [wrapperRef, setWrapperRef] = (0, react_1.useState)(null);
|
|
37
|
+
(0, useRegisterResize_1.useRegisterResize)(wrapperRef, onResize);
|
|
39
38
|
const { url, hasGLEffect, fragmentShader, FXControls, FXCursor } = item.commonParams;
|
|
40
39
|
const fxCanvas = (0, react_1.useRef)(null);
|
|
41
40
|
const isInitialRef = (0, react_1.useRef)(true);
|
|
@@ -46,12 +45,14 @@ const ImageItem = ({ item, sectionId, onResize }) => {
|
|
|
46
45
|
acc[control.shaderParam] = control.value;
|
|
47
46
|
return acc;
|
|
48
47
|
}, {});
|
|
49
|
-
const layoutValues = [item.area, item.layoutParams
|
|
48
|
+
const layoutValues = [item.area, item.layoutParams];
|
|
50
49
|
const fullShaderCode = `${baseVariables}\n${controlsVariables}\n${fragmentShader}`;
|
|
51
50
|
const area = layoutId ? item.area[layoutId] : null;
|
|
52
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;
|
|
53
52
|
const width = area && exemplary ? area.width * exemplary : 0;
|
|
54
53
|
const height = area && exemplary ? area.height * exemplary : 0;
|
|
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']);
|
|
55
56
|
(0, react_1.useEffect)(() => {
|
|
56
57
|
isInitialRef.current = false;
|
|
57
58
|
}, []);
|
|
@@ -61,11 +62,25 @@ const ImageItem = ({ item, sectionId, onResize }) => {
|
|
|
61
62
|
cursor: FXCursor,
|
|
62
63
|
controls: controlValues
|
|
63
64
|
}, width, height);
|
|
64
|
-
const rect = (0, useElementRect_1.useElementRect)(
|
|
65
|
+
const rect = (0, useElementRect_1.useElementRect)(wrapperRef);
|
|
65
66
|
const rectWidth = Math.floor((_b = rect === null || rect === void 0 ? void 0 : rect.width) !== null && _b !== void 0 ? _b : 0);
|
|
66
67
|
const rectHeight = Math.floor((_c = rect === null || rect === void 0 ? void 0 : rect.height) !== null && _c !== void 0 ? _c : 0);
|
|
67
|
-
const
|
|
68
|
-
|
|
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
|
+
const isInteractive = opacity !== 0;
|
|
80
|
+
(0, react_1.useEffect)(() => {
|
|
81
|
+
onVisibilityChange === null || onVisibilityChange === void 0 ? void 0 : onVisibilityChange(isInteractive);
|
|
82
|
+
}, [isInteractive, onVisibilityChange]);
|
|
83
|
+
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: `
|
|
69
84
|
.image-wrapper-${item.id} {
|
|
70
85
|
position: absolute;
|
|
71
86
|
width: 100%;
|
|
@@ -91,25 +106,17 @@ const ImageItem = ({ item, sectionId, onResize }) => {
|
|
|
91
106
|
border-width: 0;
|
|
92
107
|
box-sizing: border-box;
|
|
93
108
|
}
|
|
94
|
-
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams
|
|
109
|
+
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams]) => {
|
|
95
110
|
return (`
|
|
96
111
|
.image-wrapper-${item.id} {
|
|
97
112
|
opacity: ${layoutParams.opacity};
|
|
98
113
|
transform: rotate(${area.angle}deg);
|
|
99
114
|
filter: ${layoutParams.blur !== 0 ? `blur(${layoutParams.blur * 100}vw)` : 'unset'};
|
|
100
|
-
transition: ${(0, HoverStyles_1.getTransitions)(['angle', 'opacity', 'blur'], hoverParams)};
|
|
101
|
-
}
|
|
102
|
-
.image-wrapper-${item.id}:hover {
|
|
103
|
-
${(0, HoverStyles_1.getHoverStyles)(['angle', 'opacity', 'blur'], hoverParams)};
|
|
104
115
|
}
|
|
105
116
|
.image-${item.id} {
|
|
106
117
|
border-color: ${color_1.CntrlColor.parse(layoutParams.strokeColor).fmt('rgba')};
|
|
107
118
|
border-radius: ${layoutParams.radius * 100}vw;
|
|
108
119
|
border-width: ${layoutParams.strokeWidth * 100}vw;
|
|
109
|
-
transition: ${(0, HoverStyles_1.getTransitions)(['strokeWidth', 'radius', 'strokeColor'], hoverParams)};
|
|
110
|
-
}
|
|
111
|
-
.image-wrapper-${item.id}:hover .image, .image-wrapper-${item.id}:hover .img-canvas {
|
|
112
|
-
${(0, HoverStyles_1.getHoverStyles)(['strokeWidth', 'radius', 'strokeColor'], hoverParams)};
|
|
113
120
|
}
|
|
114
121
|
`);
|
|
115
122
|
})}
|
|
@@ -13,23 +13,40 @@ const LinkWrapper_1 = require("../LinkWrapper");
|
|
|
13
13
|
const useRectangleItem_1 = require("./useRectangleItem");
|
|
14
14
|
const useItemAngle_1 = require("../useItemAngle");
|
|
15
15
|
const useCntrlContext_1 = require("../../provider/useCntrlContext");
|
|
16
|
-
const HoverStyles_1 = require("../../utils/HoverStyles/HoverStyles");
|
|
17
16
|
const useRegisterResize_1 = require("../../common/useRegisterResize");
|
|
18
|
-
const
|
|
19
|
-
|
|
17
|
+
const getStyleFromItemStateAndParams_1 = require("../../utils/getStyleFromItemStateAndParams");
|
|
18
|
+
const RectangleItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityChange }) => {
|
|
19
|
+
var _a, _b, _c, _d;
|
|
20
20
|
const id = (0, react_1.useId)();
|
|
21
21
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
22
|
-
const { fillColor, radius, strokeWidth, strokeColor, blur, backdropBlur } = (0, useRectangleItem_1.useRectangleItem)(item, sectionId);
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
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];
|
|
27
35
|
const [ref, setRef] = (0, react_1.useState)(null);
|
|
28
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);
|
|
29
42
|
const backdropFilterValue = backdropBlur ? `blur(${backdropBlur * 100}vw)` : undefined;
|
|
30
|
-
|
|
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);
|
|
44
|
+
(0, react_1.useEffect)(() => {
|
|
45
|
+
onVisibilityChange === null || onVisibilityChange === void 0 ? void 0 : onVisibilityChange(isInteractive);
|
|
46
|
+
}, [isInteractive, onVisibilityChange]);
|
|
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({}, (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
|
|
31
48
|
? { backdropFilter: backdropFilterValue, WebkitBackdropFilter: backdropFilterValue }
|
|
32
|
-
: {})) }), (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: `
|
|
33
50
|
.rectangle-${item.id} {
|
|
34
51
|
position: absolute;
|
|
35
52
|
width: 100%;
|
|
@@ -37,7 +54,7 @@ const RectangleItem = ({ item, sectionId, onResize }) => {
|
|
|
37
54
|
border-style: solid;
|
|
38
55
|
box-sizing: border-box;
|
|
39
56
|
}
|
|
40
|
-
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams
|
|
57
|
+
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams]) => {
|
|
41
58
|
return (`
|
|
42
59
|
.rectangle-${item.id} {
|
|
43
60
|
background-color: ${color_1.CntrlColor.parse(layoutParams.fillColor).fmt('rgba')};
|
|
@@ -48,10 +65,6 @@ const RectangleItem = ({ item, sectionId, onResize }) => {
|
|
|
48
65
|
filter: ${layoutParams.blur !== 0 ? `blur(${layoutParams.blur * 100}vw)` : 'unset'};
|
|
49
66
|
backdrop-filter: ${layoutParams.backdropFilter !== 0 ? `blur(${layoutParams.blur * 100}vw)` : 'unset'};
|
|
50
67
|
-webkit-backdrop-filter: ${layoutParams.backdropFilter !== 0 ? `blur(${layoutParams.blur * 100}vw)` : 'unset'};
|
|
51
|
-
transition: ${(0, HoverStyles_1.getTransitions)(['angle', 'fillColor', 'strokeWidth', 'radius', 'strokeColor', 'blur', 'backdropBlur'], hoverParams)};
|
|
52
|
-
}
|
|
53
|
-
.rectangle-${item.id}:hover {
|
|
54
|
-
${(0, HoverStyles_1.getHoverStyles)(['angle', 'fillColor', 'strokeWidth', 'radius', 'strokeColor', 'blur', 'backdropBlur'], hoverParams)};
|
|
55
68
|
}
|
|
56
69
|
`);
|
|
57
70
|
})}
|