@cntrl-site/sdk-nextjs 1.0.19-alpha.2 → 1.0.19
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 +8 -9
- package/lib/components/Head.js +1 -1
- package/lib/components/Item.js +13 -33
- package/lib/components/items/CodeEmbedItem.js +8 -11
- package/lib/components/items/CustomItem.js +7 -10
- package/lib/components/items/GroupItem.js +8 -11
- package/lib/components/items/ImageItem.js +15 -21
- package/lib/components/items/RectangleItem.js +8 -11
- package/lib/components/items/RichTextItem.js +7 -10
- package/lib/components/items/VideoItem.js +12 -16
- package/lib/components/items/VimeoEmbed.js +15 -19
- package/lib/components/items/YoutubeEmbed.js +13 -18
- package/lib/utils/{StateStyles/StateStyles.js → HoverStyles/HoverStyles.js} +24 -36
- package/package.json +4 -7
- package/src/components/Article.tsx +28 -31
- package/src/components/ArticleWrapper.tsx +2 -1
- package/src/components/Head.tsx +1 -0
- package/src/components/Item.tsx +18 -38
- package/src/components/items/CodeEmbedItem.tsx +9 -12
- package/src/components/items/CustomItem.tsx +9 -12
- package/src/components/items/GroupItem.tsx +9 -12
- package/src/components/items/ImageItem.tsx +19 -26
- package/src/components/items/RectangleItem.tsx +10 -13
- package/src/components/items/RichTextItem.tsx +9 -17
- package/src/components/items/VideoItem.tsx +15 -19
- package/src/components/items/VimeoEmbed.tsx +16 -20
- package/src/components/items/YoutubeEmbed.tsx +16 -20
- package/src/utils/{StateStyles/StateStyles.ts → HoverStyles/HoverStyles.ts} +27 -41
- package/lib/components/useStatesClassNames.js +0 -18
- package/lib/components/useStatesTransitions.js +0 -89
- package/lib/provider/InteractionsContext.js +0 -45
- package/lib/utils/getStatesCSS.js +0 -16
- package/src/components/useStatesClassNames.ts +0 -23
- package/src/components/useStatesTransitions.ts +0 -95
- package/src/provider/InteractionsContext.test.tsx +0 -97
- package/src/provider/InteractionsContext.tsx +0 -65
- package/src/utils/getStatesCSS.ts +0 -24
package/jest.config.js
CHANGED
|
@@ -12,7 +12,6 @@ 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");
|
|
16
15
|
const Article = ({ article, sectionData }) => {
|
|
17
16
|
const articleRef = (0, react_1.useRef)(null);
|
|
18
17
|
const articleRectObserver = (0, useArticleRectObserver_1.useArticleRectObserver)(articleRef.current);
|
|
@@ -25,14 +24,14 @@ const Article = ({ article, sectionData }) => {
|
|
|
25
24
|
setArticleHeight(rect.height / rect.width);
|
|
26
25
|
});
|
|
27
26
|
}, [articleRectObserver]);
|
|
28
|
-
return ((0, jsx_runtime_1.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
return ((0, jsx_runtime_1.jsxs)(ArticleRectContext_1.ArticleRectContext.Provider, { value: articleRectObserver, 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) => {
|
|
28
|
+
const data = section.name ? sectionData[section.name] : {};
|
|
29
|
+
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));
|
|
30
|
+
}) }) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
32
31
|
.article {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
` })] })
|
|
32
|
+
position: relative;
|
|
33
|
+
overflow: clip;
|
|
34
|
+
}
|
|
35
|
+
` })] }));
|
|
37
36
|
};
|
|
38
37
|
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: "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: {
|
|
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: "twitter: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,6 +21,7 @@ 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");
|
|
24
25
|
const getItemTopStyle_1 = require("../utils/getItemTopStyle");
|
|
25
26
|
const useStickyItemTop_1 = require("./items/useStickyItemTop");
|
|
26
27
|
const getAnchoredItemTop_1 = require("../utils/getAnchoredItemTop");
|
|
@@ -30,10 +31,6 @@ const useExemplary_1 = require("../common/useExemplary");
|
|
|
30
31
|
const GroupItem_1 = require("./items/GroupItem");
|
|
31
32
|
const CodeEmbedItem_1 = require("./items/CodeEmbedItem");
|
|
32
33
|
const KeyframesContext_1 = require("../provider/KeyframesContext");
|
|
33
|
-
const InteractionsContext_1 = require("../provider/InteractionsContext");
|
|
34
|
-
const getStatesCSS_1 = require("../utils/getStatesCSS");
|
|
35
|
-
const useStatesClassNames_1 = require("./useStatesClassNames");
|
|
36
|
-
const useStatesTransitions_1 = require("./useStatesTransitions");
|
|
37
34
|
const itemsMap = {
|
|
38
35
|
[sdk_1.ArticleItemType.Rectangle]: RectangleItem_1.RectangleItem,
|
|
39
36
|
[sdk_1.ArticleItemType.Image]: ImageItem_1.ImageItem,
|
|
@@ -57,7 +54,6 @@ const RichTextWrapper = ({ isRichText, children }) => {
|
|
|
57
54
|
const noop = () => null;
|
|
58
55
|
const Item = ({ item, sectionId, articleHeight, isInGroup = false }) => {
|
|
59
56
|
const itemWrapperRef = (0, react_1.useRef)(null);
|
|
60
|
-
const itemInnerRef = (0, react_1.useRef)(null);
|
|
61
57
|
const rectObserver = (0, react_1.useContext)(ArticleRectContext_1.ArticleRectContext);
|
|
62
58
|
const keyframesRepo = (0, react_1.useContext)(KeyframesContext_1.KeyframesContext);
|
|
63
59
|
const id = (0, react_1.useId)();
|
|
@@ -72,9 +68,8 @@ const Item = ({ item, sectionId, articleHeight, isInGroup = false }) => {
|
|
|
72
68
|
const sectionHeight = (0, useSectionHeightMap_1.useSectionHeightData)(sectionId);
|
|
73
69
|
const stickyTop = (0, useStickyItemTop_1.useStickyItemTop)(item, sectionHeight, sectionId);
|
|
74
70
|
const dimensions = (0, useItemDimensions_1.useItemDimensions)(item, sectionId);
|
|
75
|
-
const layoutValues = [item.area, item.hidden, item.state];
|
|
71
|
+
const layoutValues = [item.area, item.hidden, item.state.hover];
|
|
76
72
|
const isInitialRef = (0, react_1.useRef)(true);
|
|
77
|
-
const { transitionTo, getItemTrigger } = (0, react_1.useContext)(InteractionsContext_1.InteractionsContext);
|
|
78
73
|
layoutValues.push(item.sticky);
|
|
79
74
|
layoutValues.push(sectionHeight);
|
|
80
75
|
if (item.layoutParams) {
|
|
@@ -107,30 +102,11 @@ const Item = ({ item, sectionId, articleHeight, isInGroup = false }) => {
|
|
|
107
102
|
isInitialRef.current = false;
|
|
108
103
|
}, []);
|
|
109
104
|
const isRichText = isItemType(item, sdk_1.ArticleItemType.RichText);
|
|
110
|
-
|
|
111
|
-
const wrapperStatesClassNames = (0, useStatesClassNames_1.useStatesClassNames)(item.id, item.state, 'item-wrapper');
|
|
112
|
-
(0, useStatesTransitions_1.useStatesTransitions)(itemWrapperRef.current, item.state, ['top', 'left']);
|
|
113
|
-
(0, useStatesTransitions_1.useStatesTransitions)(itemInnerRef.current, item.state, ['width', 'height', 'scale']);
|
|
114
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: `item-wrapper-${item.id} ${wrapperStatesClassNames}`, ref: itemWrapperRef, style: 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` } : {})), children: [(0, jsx_runtime_1.jsx)("div", { suppressHydrationWarning: true, className: `item-${item.id}`, style: {
|
|
105
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: `item-wrapper-${item.id}`, ref: itemWrapperRef, style: 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` } : {})), children: [(0, jsx_runtime_1.jsx)("div", { suppressHydrationWarning: true, className: `item-${item.id}`, style: {
|
|
115
106
|
opacity: (keyframes.length !== 0 && !layout) ? 0 : 1,
|
|
116
107
|
top: `${stickyTop * 100}vw`,
|
|
117
108
|
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
|
-
const trigger = getItemTrigger(item.id, 'click');
|
|
120
|
-
if (!trigger)
|
|
121
|
-
return;
|
|
122
|
-
transitionTo(trigger.id, trigger.to);
|
|
123
|
-
}, onMouseEnter: () => {
|
|
124
|
-
const trigger = getItemTrigger(item.id, 'hover-in');
|
|
125
|
-
if (!trigger)
|
|
126
|
-
return;
|
|
127
|
-
transitionTo(trigger.id, trigger.to);
|
|
128
|
-
}, onMouseLeave: () => {
|
|
129
|
-
const trigger = getItemTrigger(item.id, 'hover-out');
|
|
130
|
-
if (!trigger)
|
|
131
|
-
return;
|
|
132
|
-
transitionTo(trigger.id, trigger.to);
|
|
133
|
-
}, style: Object.assign(Object.assign({}, (dimensions ? {
|
|
109
|
+
}, children: (0, jsx_runtime_1.jsx)(RichTextWrapper, { isRichText: isRichText, children: (0, jsx_runtime_1.jsx)("div", { className: `item-${item.id}-inner`, style: Object.assign(Object.assign({}, (dimensions ? {
|
|
134
110
|
width: `${sizingAxis.x === 'manual'
|
|
135
111
|
? isRichText
|
|
136
112
|
? `${dimensions.width * exemplary}px`
|
|
@@ -138,12 +114,10 @@ const Item = ({ item, sectionId, articleHeight, isInGroup = false }) => {
|
|
|
138
114
|
: 'max-content'}`,
|
|
139
115
|
height: `${sizingAxis.y === 'manual' ? `${dimensions.height * 100}vw` : 'unset'}`
|
|
140
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: `
|
|
141
|
-
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, hidden,
|
|
117
|
+
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, hidden, hoverParams, sticky, sectionHeight, layoutParams], exemplary) => {
|
|
142
118
|
const sizingAxis = parseSizing(layoutParams.sizing);
|
|
143
119
|
const isScreenBasedBottom = area.positionType === sdk_1.PositionType.ScreenBased && area.anchorSide === sdk_1.AnchorSide.Bottom;
|
|
144
120
|
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
121
|
return (`
|
|
148
122
|
.item-${item.id} {
|
|
149
123
|
position: ${sticky ? 'sticky' : 'absolute'};
|
|
@@ -154,6 +128,7 @@ const Item = ({ item, sectionId, articleHeight, isInGroup = false }) => {
|
|
|
154
128
|
height: fit-content;
|
|
155
129
|
}
|
|
156
130
|
.item-${item.id}-inner {
|
|
131
|
+
transition: ${(0, HoverStyles_1.getTransitions)(['width', 'height', 'scale'], hoverParams)};
|
|
157
132
|
pointer-events: auto;
|
|
158
133
|
width: ${sizingAxis.x === 'manual'
|
|
159
134
|
? `${area.width * 100}vw`
|
|
@@ -170,9 +145,14 @@ const Item = ({ item, sectionId, articleHeight, isInGroup = false }) => {
|
|
|
170
145
|
bottom: ${isScreenBasedBottom ? `${-area.top * 100}vw` : 'unset'};
|
|
171
146
|
top: ${isScreenBasedBottom ? 'unset' : (0, getItemTopStyle_1.getItemTopStyle)(area.top, area.anchorSide)};
|
|
172
147
|
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)};
|
|
173
155
|
}
|
|
174
|
-
${statesWrapperCSS}
|
|
175
|
-
${statesInnerCSS}
|
|
176
156
|
`);
|
|
177
157
|
})}
|
|
178
158
|
` })] }));
|
|
@@ -8,14 +8,12 @@ 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");
|
|
11
12
|
const style_1 = __importDefault(require("styled-jsx/style"));
|
|
12
13
|
const useRegisterResize_1 = require("../../common/useRegisterResize");
|
|
13
14
|
const useItemAngle_1 = require("../useItemAngle");
|
|
14
15
|
const LinkWrapper_1 = require("../LinkWrapper");
|
|
15
16
|
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
17
|
const stylesMap = {
|
|
20
18
|
[sdk_1.AreaAnchor.TopLeft]: {},
|
|
21
19
|
[sdk_1.AreaAnchor.TopCenter]: { justifyContent: 'center' },
|
|
@@ -37,9 +35,7 @@ const CodeEmbedItem = ({ item, sectionId, onResize }) => {
|
|
|
37
35
|
const [ref, setRef] = (0, react_1.useState)(null);
|
|
38
36
|
(0, useRegisterResize_1.useRegisterResize)(ref, onResize);
|
|
39
37
|
const pos = stylesMap[anchor];
|
|
40
|
-
const layoutValues = [item.area, item.layoutParams, item.state];
|
|
41
|
-
const statesClassNames = (0, useStatesClassNames_1.useStatesClassNames)(item.id, item.state, 'embed-wrapper');
|
|
42
|
-
(0, useStatesTransitions_1.useStatesTransitions)(ref, item.state, ['angle', 'blur', 'opacity']);
|
|
38
|
+
const layoutValues = [item.area, item.layoutParams, item.state.hover];
|
|
43
39
|
(0, react_1.useEffect)(() => {
|
|
44
40
|
if (!ref)
|
|
45
41
|
return;
|
|
@@ -62,7 +58,7 @@ const CodeEmbedItem = ({ item, sectionId, onResize }) => {
|
|
|
62
58
|
return;
|
|
63
59
|
iframe.srcdoc = item.commonParams.html;
|
|
64
60
|
}, [item.commonParams.html, item.commonParams.iframe, ref]);
|
|
65
|
-
return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, { url: (_a = item.link) === null || _a === void 0 ? void 0 : _a.url, target: (_b = item.link) === null || _b === void 0 ? void 0 : _b.target, children: [(0, jsx_runtime_1.jsx)("div", { className: `embed-wrapper-${item.id}
|
|
61
|
+
return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, { url: (_a = item.link) === null || _a === void 0 ? void 0 : _a.url, target: (_b = item.link) === null || _b === void 0 ? void 0 : _b.target, children: [(0, jsx_runtime_1.jsx)("div", { className: `embed-wrapper-${item.id}`, style: Object.assign(Object.assign(Object.assign({}, (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), (opacity !== undefined ? { opacity } : {})), 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
62
|
.embed-wrapper-${item.id} {
|
|
67
63
|
position: absolute;
|
|
68
64
|
width: 100%;
|
|
@@ -74,20 +70,21 @@ const CodeEmbedItem = ({ item, sectionId, onResize }) => {
|
|
|
74
70
|
z-index: 1;
|
|
75
71
|
border: none;
|
|
76
72
|
}
|
|
77
|
-
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams,
|
|
78
|
-
const statesCSS = (0, getStatesCSS_1.getStatesCSS)(item.id, 'embed-wrapper', ['angle', 'blur', 'opacity'], stateParams);
|
|
73
|
+
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams, hoverParams], exemplary) => {
|
|
79
74
|
return (`
|
|
80
75
|
.embed-wrapper-${item.id} {
|
|
81
76
|
opacity: ${layoutParams.opacity};
|
|
82
77
|
transform: rotate(${area.angle}deg);
|
|
83
78
|
filter: ${layoutParams.blur !== 0 ? `blur(${layoutParams.blur * 100}vw)` : 'unset'};
|
|
84
|
-
transition:
|
|
79
|
+
transition: ${(0, HoverStyles_1.getTransitions)(['angle', 'blur', 'opacity'], hoverParams)};
|
|
85
80
|
}
|
|
86
81
|
.embed-${item.id} {
|
|
87
82
|
width: ${item.commonParams.scale ? `${area.width * exemplary}px` : '100%'};
|
|
88
83
|
height: ${item.commonParams.scale ? `${area.height * exemplary}px` : '100%'};
|
|
89
84
|
}
|
|
90
|
-
|
|
85
|
+
.embed-wrapper-${item.id}:hover {
|
|
86
|
+
${(0, HoverStyles_1.getHoverStyles)(['angle', 'blur', 'opacity'], hoverParams)}
|
|
87
|
+
}
|
|
91
88
|
`);
|
|
92
89
|
})}
|
|
93
90
|
` })] }));
|
|
@@ -8,37 +8,34 @@ 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");
|
|
11
12
|
const style_1 = __importDefault(require("styled-jsx/style"));
|
|
12
13
|
const useRegisterResize_1 = require("../../common/useRegisterResize");
|
|
13
14
|
const useItemAngle_1 = require("../useItemAngle");
|
|
14
|
-
const useStatesClassNames_1 = require("../useStatesClassNames");
|
|
15
|
-
const getStatesCSS_1 = require("../../utils/getStatesCSS");
|
|
16
|
-
const useStatesTransitions_1 = require("../useStatesTransitions");
|
|
17
15
|
const CustomItem = ({ item, onResize, sectionId }) => {
|
|
18
16
|
const sdk = (0, useCntrlContext_1.useCntrlContext)();
|
|
19
17
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
20
18
|
const angle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
|
|
21
19
|
const component = sdk.customItems.get(item.commonParams.name);
|
|
22
|
-
const layoutValues = [item.area, item.state];
|
|
20
|
+
const layoutValues = [item.area, item.state.hover];
|
|
23
21
|
const [ref, setRef] = (0, react_1.useState)(null);
|
|
24
22
|
(0, useRegisterResize_1.useRegisterResize)(ref, onResize);
|
|
25
|
-
const statesClassNames = (0, useStatesClassNames_1.useStatesClassNames)(item.id, item.state, 'custom-component');
|
|
26
|
-
(0, useStatesTransitions_1.useStatesTransitions)(ref, item.state, ['angle']);
|
|
27
23
|
if (!component)
|
|
28
24
|
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);
|
|
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, hoverParams]) => {
|
|
31
26
|
return (`
|
|
32
27
|
.custom-component-${item.id} {
|
|
33
28
|
transform: rotate(${area.angle}deg);
|
|
34
|
-
transition:
|
|
29
|
+
transition: ${(0, HoverStyles_1.getTransitions)(['angle'], hoverParams)};
|
|
35
30
|
height: 100%;
|
|
36
31
|
width: 100%;
|
|
37
32
|
position: absolute;
|
|
38
33
|
left: 0;
|
|
39
34
|
top: 0;
|
|
40
35
|
}
|
|
41
|
-
|
|
36
|
+
.custom-component-${item.id}:hover {
|
|
37
|
+
${(0, HoverStyles_1.getHoverStyles)(['angle'], hoverParams)};
|
|
38
|
+
}
|
|
42
39
|
`);
|
|
43
40
|
})}` })] }));
|
|
44
41
|
};
|
|
@@ -9,14 +9,12 @@ 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");
|
|
12
13
|
const LinkWrapper_1 = require("../LinkWrapper");
|
|
13
14
|
const useRegisterResize_1 = require("../../common/useRegisterResize");
|
|
14
15
|
const useCntrlContext_1 = require("../../provider/useCntrlContext");
|
|
15
16
|
const useItemAngle_1 = require("../useItemAngle");
|
|
16
17
|
const useGroupItem_1 = require("./useGroupItem");
|
|
17
|
-
const useStatesClassNames_1 = require("../useStatesClassNames");
|
|
18
|
-
const getStatesCSS_1 = require("../../utils/getStatesCSS");
|
|
19
|
-
const useStatesTransitions_1 = require("../useStatesTransitions");
|
|
20
18
|
const GroupItem = ({ item, sectionId, onResize, articleHeight }) => {
|
|
21
19
|
var _a, _b;
|
|
22
20
|
const id = (0, react_1.useId)();
|
|
@@ -24,27 +22,26 @@ const GroupItem = ({ item, sectionId, onResize, articleHeight }) => {
|
|
|
24
22
|
const angle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
|
|
25
23
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
26
24
|
const { opacity } = (0, useGroupItem_1.useGroupItem)(item, sectionId);
|
|
27
|
-
const layoutValues = [item.area, item.layoutParams, item.state];
|
|
28
|
-
const statesClassNames = (0, useStatesClassNames_1.useStatesClassNames)(item.id, item.state, 'group');
|
|
25
|
+
const layoutValues = [item.area, item.layoutParams, item.state.hover];
|
|
29
26
|
const [ref, setRef] = (0, react_1.useState)(null);
|
|
30
27
|
(0, useRegisterResize_1.useRegisterResize)(ref, onResize);
|
|
31
|
-
(0,
|
|
32
|
-
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: `group-${item.id} ${statesClassNames}`, ref: setRef, style: Object.assign(Object.assign({}, (opacity !== undefined ? { opacity } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), children: items && items.map(item => ((0, jsx_runtime_1.jsx)(Item_1.Item, { item: item, sectionId: sectionId, articleHeight: articleHeight, isInGroup: true }, item.id))) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
28
|
+
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: `group-${item.id}`, ref: setRef, style: Object.assign(Object.assign({}, (opacity !== undefined ? { opacity } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), children: items && items.map(item => ((0, jsx_runtime_1.jsx)(Item_1.Item, { item: item, sectionId: sectionId, articleHeight: articleHeight, isInGroup: true }, item.id))) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
33
29
|
.group-${item.id} {
|
|
34
30
|
position: absolute;
|
|
35
31
|
width: 100%;
|
|
36
32
|
height: 100%;
|
|
37
33
|
box-sizing: border-box;
|
|
38
34
|
}
|
|
39
|
-
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams,
|
|
40
|
-
const statesCSS = (0, getStatesCSS_1.getStatesCSS)(item.id, 'group', ['opacity', 'angle'], stateParams);
|
|
35
|
+
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams, hoverParams]) => {
|
|
41
36
|
return (`
|
|
42
37
|
.group-${item.id} {
|
|
43
38
|
opacity: ${layoutParams.opacity};
|
|
44
39
|
transform: rotate(${area.angle}deg);
|
|
45
|
-
transition:
|
|
40
|
+
transition: ${(0, HoverStyles_1.getTransitions)(['opacity', 'angle'], hoverParams)};
|
|
41
|
+
}
|
|
42
|
+
.group-${item.id}:hover {
|
|
43
|
+
${(0, HoverStyles_1.getHoverStyles)(['opacity', 'angle'], hoverParams)};
|
|
46
44
|
}
|
|
47
|
-
${statesCSS}
|
|
48
45
|
`);
|
|
49
46
|
})}
|
|
50
47
|
` })] }) }));
|
|
@@ -13,13 +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");
|
|
16
17
|
const useRegisterResize_1 = require("../../common/useRegisterResize");
|
|
17
18
|
const useImageFx_1 = require("../../utils/effects/useImageFx");
|
|
18
19
|
const useElementRect_1 = require("../../utils/useElementRect");
|
|
19
20
|
const useLayoutContext_1 = require("../useLayoutContext");
|
|
20
|
-
const useStatesClassNames_1 = require("../useStatesClassNames");
|
|
21
|
-
const getStatesCSS_1 = require("../../utils/getStatesCSS");
|
|
22
|
-
const useStatesTransitions_1 = require("../useStatesTransitions");
|
|
23
21
|
const baseVariables = `precision mediump float;
|
|
24
22
|
uniform sampler2D u_image;
|
|
25
23
|
uniform sampler2D u_pattern;
|
|
@@ -36,9 +34,8 @@ const ImageItem = ({ item, sectionId, onResize }) => {
|
|
|
36
34
|
const { radius, strokeWidth, opacity, strokeColor, blur } = (0, useFileItem_1.useFileItem)(item, sectionId);
|
|
37
35
|
const angle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
|
|
38
36
|
const borderColor = (0, react_1.useMemo)(() => strokeColor ? color_1.CntrlColor.parse(strokeColor) : undefined, [strokeColor]);
|
|
39
|
-
const [
|
|
40
|
-
|
|
41
|
-
(0, useRegisterResize_1.useRegisterResize)(wrapperRef, onResize);
|
|
37
|
+
const [ref, setRef] = (0, react_1.useState)(null);
|
|
38
|
+
(0, useRegisterResize_1.useRegisterResize)(ref, onResize);
|
|
42
39
|
const { url, hasGLEffect, fragmentShader, FXControls, FXCursor } = item.commonParams;
|
|
43
40
|
const fxCanvas = (0, react_1.useRef)(null);
|
|
44
41
|
const isInitialRef = (0, react_1.useRef)(true);
|
|
@@ -49,17 +46,12 @@ const ImageItem = ({ item, sectionId, onResize }) => {
|
|
|
49
46
|
acc[control.shaderParam] = control.value;
|
|
50
47
|
return acc;
|
|
51
48
|
}, {});
|
|
52
|
-
const layoutValues = [item.area, item.layoutParams, item.state];
|
|
49
|
+
const layoutValues = [item.area, item.layoutParams, item.state.hover];
|
|
53
50
|
const fullShaderCode = `${baseVariables}\n${controlsVariables}\n${fragmentShader}`;
|
|
54
51
|
const area = layoutId ? item.area[layoutId] : null;
|
|
55
52
|
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
53
|
const width = area && exemplary ? area.width * exemplary : 0;
|
|
57
54
|
const height = area && exemplary ? area.height * exemplary : 0;
|
|
58
|
-
const statesWrapperClassNames = (0, useStatesClassNames_1.useStatesClassNames)(item.id, item.state, 'image-wrapper');
|
|
59
|
-
const statesImgClassNames = (0, useStatesClassNames_1.useStatesClassNames)(item.id, item.state, 'image');
|
|
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']);
|
|
63
55
|
(0, react_1.useEffect)(() => {
|
|
64
56
|
isInitialRef.current = false;
|
|
65
57
|
}, []);
|
|
@@ -69,11 +61,11 @@ const ImageItem = ({ item, sectionId, onResize }) => {
|
|
|
69
61
|
cursor: FXCursor,
|
|
70
62
|
controls: controlValues
|
|
71
63
|
}, width, height);
|
|
72
|
-
const rect = (0, useElementRect_1.useElementRect)(
|
|
64
|
+
const rect = (0, useElementRect_1.useElementRect)(ref);
|
|
73
65
|
const rectWidth = Math.floor((_b = rect === null || rect === void 0 ? void 0 : rect.width) !== null && _b !== void 0 ? _b : 0);
|
|
74
66
|
const rectHeight = Math.floor((_c = rect === null || rect === void 0 ? void 0 : rect.height) !== null && _c !== void 0 ? _c : 0);
|
|
75
67
|
const inlineStyles = Object.assign(Object.assign(Object.assign({}, (borderColor ? { borderColor: `${borderColor.fmt('rgba')}` } : {})), (radius !== undefined ? { borderRadius: `${radius * 100}vw` } : {})), (strokeWidth !== undefined ? { borderWidth: `${strokeWidth * 100}vw` } : {}));
|
|
76
|
-
return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { url: (_d = item.link) === null || _d === void 0 ? void 0 : _d.url, target: (_e = item.link) === null || _e === void 0 ? void 0 : _e.target, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `image-wrapper-${item.id}
|
|
68
|
+
return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { url: (_d = item.link) === null || _d === void 0 ? void 0 : _d.url, target: (_e = item.link) === null || _e === void 0 ? void 0 : _e.target, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `image-wrapper-${item.id}`, ref: setRef, style: Object.assign(Object.assign(Object.assign({}, (opacity !== undefined ? { opacity } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), 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
69
|
.image-wrapper-${item.id} {
|
|
78
70
|
position: absolute;
|
|
79
71
|
width: 100%;
|
|
@@ -99,24 +91,26 @@ const ImageItem = ({ item, sectionId, onResize }) => {
|
|
|
99
91
|
border-width: 0;
|
|
100
92
|
box-sizing: border-box;
|
|
101
93
|
}
|
|
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);
|
|
94
|
+
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams, hoverParams]) => {
|
|
105
95
|
return (`
|
|
106
96
|
.image-wrapper-${item.id} {
|
|
107
97
|
opacity: ${layoutParams.opacity};
|
|
108
98
|
transform: rotate(${area.angle}deg);
|
|
109
99
|
filter: ${layoutParams.blur !== 0 ? `blur(${layoutParams.blur * 100}vw)` : 'unset'};
|
|
110
|
-
transition:
|
|
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)};
|
|
111
104
|
}
|
|
112
105
|
.image-${item.id} {
|
|
113
106
|
border-color: ${color_1.CntrlColor.parse(layoutParams.strokeColor).fmt('rgba')};
|
|
114
107
|
border-radius: ${layoutParams.radius * 100}vw;
|
|
115
108
|
border-width: ${layoutParams.strokeWidth * 100}vw;
|
|
116
|
-
transition:
|
|
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)};
|
|
117
113
|
}
|
|
118
|
-
${wrapperStatesCSS}
|
|
119
|
-
${imgStatesCSS}
|
|
120
114
|
`);
|
|
121
115
|
})}
|
|
122
116
|
` })] }) }));
|
|
@@ -13,10 +13,8 @@ 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");
|
|
16
17
|
const useRegisterResize_1 = require("../../common/useRegisterResize");
|
|
17
|
-
const getStatesCSS_1 = require("../../utils/getStatesCSS");
|
|
18
|
-
const useStatesClassNames_1 = require("../useStatesClassNames");
|
|
19
|
-
const useStatesTransitions_1 = require("../useStatesTransitions");
|
|
20
18
|
const RectangleItem = ({ item, sectionId, onResize }) => {
|
|
21
19
|
var _a, _b;
|
|
22
20
|
const id = (0, react_1.useId)();
|
|
@@ -25,13 +23,11 @@ const RectangleItem = ({ item, sectionId, onResize }) => {
|
|
|
25
23
|
const angle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
|
|
26
24
|
const backgroundColor = (0, react_1.useMemo)(() => fillColor ? color_1.CntrlColor.parse(fillColor) : undefined, [fillColor]);
|
|
27
25
|
const borderColor = (0, react_1.useMemo)(() => strokeColor ? color_1.CntrlColor.parse(strokeColor) : undefined, [strokeColor]);
|
|
28
|
-
const layoutValues = [item.area, item.layoutParams, item.state];
|
|
26
|
+
const layoutValues = [item.area, item.layoutParams, item.state.hover];
|
|
29
27
|
const [ref, setRef] = (0, react_1.useState)(null);
|
|
30
|
-
const statesClassNames = (0, useStatesClassNames_1.useStatesClassNames)(item.id, item.state, 'rectangle');
|
|
31
28
|
(0, useRegisterResize_1.useRegisterResize)(ref, onResize);
|
|
32
29
|
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
|
|
30
|
+
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}`, 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
|
|
35
31
|
? { backdropFilter: backdropFilterValue, WebkitBackdropFilter: backdropFilterValue }
|
|
36
32
|
: {})) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
37
33
|
.rectangle-${item.id} {
|
|
@@ -41,8 +37,7 @@ const RectangleItem = ({ item, sectionId, onResize }) => {
|
|
|
41
37
|
border-style: solid;
|
|
42
38
|
box-sizing: border-box;
|
|
43
39
|
}
|
|
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);
|
|
40
|
+
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams, hoverParams]) => {
|
|
46
41
|
return (`
|
|
47
42
|
.rectangle-${item.id} {
|
|
48
43
|
background-color: ${color_1.CntrlColor.parse(layoutParams.fillColor).fmt('rgba')};
|
|
@@ -53,9 +48,11 @@ const RectangleItem = ({ item, sectionId, onResize }) => {
|
|
|
53
48
|
filter: ${layoutParams.blur !== 0 ? `blur(${layoutParams.blur * 100}vw)` : 'unset'};
|
|
54
49
|
backdrop-filter: ${layoutParams.backdropFilter !== 0 ? `blur(${layoutParams.blur * 100}vw)` : 'unset'};
|
|
55
50
|
-webkit-backdrop-filter: ${layoutParams.backdropFilter !== 0 ? `blur(${layoutParams.blur * 100}vw)` : 'unset'};
|
|
56
|
-
transition:
|
|
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)};
|
|
57
55
|
}
|
|
58
|
-
${statesCSS}
|
|
59
56
|
`);
|
|
60
57
|
})}
|
|
61
58
|
` })] }) }));
|
|
@@ -11,14 +11,12 @@ const sdk_1 = require("@cntrl-site/sdk");
|
|
|
11
11
|
const style_1 = __importDefault(require("styled-jsx/style"));
|
|
12
12
|
const useRichTextItem_1 = require("./useRichTextItem");
|
|
13
13
|
const useCntrlContext_1 = require("../../provider/useCntrlContext");
|
|
14
|
+
const HoverStyles_1 = require("../../utils/HoverStyles/HoverStyles");
|
|
14
15
|
const useRichTextItemValues_1 = require("./useRichTextItemValues");
|
|
15
16
|
const useRegisterResize_1 = require("../../common/useRegisterResize");
|
|
16
17
|
const getFontFamilyValue_1 = require("../../utils/getFontFamilyValue");
|
|
17
18
|
const useExemplary_1 = require("../../common/useExemplary");
|
|
18
19
|
const useItemAngle_1 = require("../useItemAngle");
|
|
19
|
-
const useStatesClassNames_1 = require("../useStatesClassNames");
|
|
20
|
-
const getStatesCSS_1 = require("../../utils/getStatesCSS");
|
|
21
|
-
const useStatesTransitions_1 = require("../useStatesTransitions");
|
|
22
20
|
const RichTextItem = ({ item, sectionId, onResize }) => {
|
|
23
21
|
const [content, styles] = (0, useRichTextItem_1.useRichTextItem)(item);
|
|
24
22
|
const id = (0, react_1.useId)();
|
|
@@ -27,14 +25,11 @@ const RichTextItem = ({ item, sectionId, onResize }) => {
|
|
|
27
25
|
const angle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
|
|
28
26
|
const { blur, wordSpacing, letterSpacing, color, fontSize, lineHeight } = (0, useRichTextItemValues_1.useRichTextItemValues)(item, sectionId);
|
|
29
27
|
const textColor = (0, react_1.useMemo)(() => color ? color_1.CntrlColor.parse(color) : undefined, [color]);
|
|
30
|
-
const layoutValues = [item.area, item.layoutParams, item.state];
|
|
28
|
+
const layoutValues = [item.area, item.layoutParams, item.state.hover];
|
|
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
|
-
(0,
|
|
35
|
-
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} ${stateClassNames}`, style: 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` } : {})), children: content }), (0, jsx_runtime_1.jsxs)(style_1.default, { id: id, children: [styles, `${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams, states]) => {
|
|
31
|
+
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({}, (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` } : {})), children: content }), (0, jsx_runtime_1.jsxs)(style_1.default, { id: id, children: [styles, `${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams, hoverParams]) => {
|
|
36
32
|
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
33
|
return (`
|
|
39
34
|
.rich-text-wrapper-${item.id} {
|
|
40
35
|
font-size: ${layoutParams.fontSize * 100}vw;
|
|
@@ -50,14 +45,16 @@ const RichTextItem = ({ item, sectionId, onResize }) => {
|
|
|
50
45
|
transform: rotate(${area.angle}deg);
|
|
51
46
|
filter: ${layoutParams.blur !== 0 ? `blur(${layoutParams.blur * 100}vw)` : 'unset'};
|
|
52
47
|
text-transform: ${layoutParams.textTransform};
|
|
53
|
-
transition:
|
|
48
|
+
transition: ${(0, HoverStyles_1.getTransitions)(['angle', 'blur', 'letterSpacing', 'wordSpacing', 'color'], hoverParams)};
|
|
49
|
+
}
|
|
50
|
+
.rich-text-wrapper-${item.id}:hover {
|
|
51
|
+
${(0, HoverStyles_1.getHoverStyles)(['angle', 'blur', 'letterSpacing', 'wordSpacing', 'color'], hoverParams)};
|
|
54
52
|
}
|
|
55
53
|
@supports not (color: oklch(42% 0.3 90 / 1)) {
|
|
56
54
|
.rich-text-wrapper-${item.id} {
|
|
57
55
|
color: ${color.fmt('rgba')};
|
|
58
56
|
}
|
|
59
57
|
}
|
|
60
|
-
${statesCSS}
|
|
61
58
|
`);
|
|
62
59
|
})}`] })] }));
|
|
63
60
|
};
|
|
@@ -13,12 +13,10 @@ 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");
|
|
16
17
|
const useRegisterResize_1 = require("../../common/useRegisterResize");
|
|
17
18
|
const useLayoutContext_1 = require("../useLayoutContext");
|
|
18
19
|
const ScrollPlaybackVideo_1 = require("../ScrollPlaybackVideo");
|
|
19
|
-
const useStatesClassNames_1 = require("../useStatesClassNames");
|
|
20
|
-
const getStatesCSS_1 = require("../../utils/getStatesCSS");
|
|
21
|
-
const useStatesTransitions_1 = require("../useStatesTransitions");
|
|
22
20
|
const VideoItem = ({ item, sectionId, onResize }) => {
|
|
23
21
|
var _a, _b, _c;
|
|
24
22
|
const id = (0, react_1.useId)();
|
|
@@ -30,15 +28,11 @@ const VideoItem = ({ item, sectionId, onResize }) => {
|
|
|
30
28
|
const videoRef = (0, react_1.useRef)(null);
|
|
31
29
|
const layoutId = (0, useLayoutContext_1.useLayoutContext)();
|
|
32
30
|
const scrollPlayback = layoutId ? item.layoutParams[layoutId].scrollPlayback : null;
|
|
33
|
-
const layoutValues = [item.area, item.layoutParams, item.state];
|
|
34
|
-
const statesWrapperClassNames = (0, useStatesClassNames_1.useStatesClassNames)(item.id, item.state, 'video-wrapper');
|
|
35
|
-
const statesVideoClassNames = (0, useStatesClassNames_1.useStatesClassNames)(item.id, item.state, 'video');
|
|
31
|
+
const layoutValues = [item.area, item.layoutParams, item.state.hover];
|
|
36
32
|
const hasScrollPlayback = scrollPlayback !== null;
|
|
37
|
-
(0, useStatesTransitions_1.useStatesTransitions)(ref, item.state, ['angle', 'opacity', 'blur']);
|
|
38
|
-
(0, useStatesTransitions_1.useStatesTransitions)(videoRef.current, item.state, ['strokeWidth', 'radius', 'strokeColor']);
|
|
39
33
|
(0, useRegisterResize_1.useRegisterResize)(ref, onResize);
|
|
40
34
|
const inlineStyles = Object.assign(Object.assign(Object.assign({}, (radius !== undefined ? { borderRadius: `${radius * 100}vw` } : {})), (strokeWidth !== undefined ? { borderWidth: `${strokeWidth * 100}vw` } : {})), (borderColor ? { borderColor: `${borderColor.toCss()}` } : {}));
|
|
41
|
-
return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, { url: (_a = item.link) === null || _a === void 0 ? void 0 : _a.url, target: (_b = item.link) === null || _b === void 0 ? void 0 : _b.target, children: [(0, jsx_runtime_1.jsx)("div", { className: `video-wrapper-${item.id}
|
|
35
|
+
return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, { url: (_a = item.link) === null || _a === void 0 ? void 0 : _a.url, target: (_b = item.link) === null || _b === void 0 ? void 0 : _b.target, children: [(0, jsx_runtime_1.jsx)("div", { className: `video-wrapper-${item.id}`, ref: setRef, style: Object.assign(Object.assign(Object.assign({}, (opacity !== undefined ? { opacity } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), children: hasScrollPlayback ? ((0, jsx_runtime_1.jsx)(ScrollPlaybackVideo_1.ScrollPlaybackVideo, { sectionId: sectionId, src: item.commonParams.url, playbackParams: scrollPlayback, style: inlineStyles, className: `video video-playback-wrapper video-${item.id}` })) : ((0, jsx_runtime_1.jsx)("video", { poster: (_c = item.commonParams.coverUrl) !== null && _c !== void 0 ? _c : '', ref: videoRef, autoPlay: true, muted: true, loop: true, playsInline: true, className: `video video-${item.id}`, style: inlineStyles, children: (0, jsx_runtime_1.jsx)("source", { src: item.commonParams.url }) })) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
42
36
|
.video-wrapper-${item.id} {
|
|
43
37
|
position: absolute;
|
|
44
38
|
overflow: hidden;
|
|
@@ -65,24 +59,26 @@ const VideoItem = ({ item, sectionId, onResize }) => {
|
|
|
65
59
|
display: flex;
|
|
66
60
|
justify-content: center;
|
|
67
61
|
}
|
|
68
|
-
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams,
|
|
69
|
-
const wrapperStatesCSS = (0, getStatesCSS_1.getStatesCSS)(item.id, 'video-wrapper', ['angle', 'opacity', 'blur'], stateParams);
|
|
70
|
-
const videoStatesCSS = (0, getStatesCSS_1.getStatesCSS)(item.id, 'video', ['strokeWidth', 'radius', 'strokeColor'], stateParams);
|
|
62
|
+
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams, hoverParams]) => {
|
|
71
63
|
return (`
|
|
72
64
|
.video-wrapper-${item.id} {
|
|
73
65
|
opacity: ${layoutParams.opacity};
|
|
74
66
|
transform: rotate(${area.angle}deg);
|
|
75
67
|
filter: ${layoutParams.blur !== 0 ? `blur(${layoutParams.blur * 100}vw)` : 'unset'};
|
|
76
|
-
transition:
|
|
68
|
+
transition: ${(0, HoverStyles_1.getTransitions)(['angle', 'opacity', 'blur'], hoverParams)};
|
|
69
|
+
}
|
|
70
|
+
.video-wrapper-${item.id}:hover {
|
|
71
|
+
${(0, HoverStyles_1.getHoverStyles)(['angle', 'opacity', 'blur'], hoverParams)};
|
|
77
72
|
}
|
|
78
73
|
.video-${item.id} {
|
|
79
74
|
border-color: ${color_1.CntrlColor.parse(layoutParams.strokeColor).fmt('rgba')};
|
|
80
75
|
border-radius: ${layoutParams.radius * 100}vw;
|
|
81
76
|
border-width: ${layoutParams.strokeWidth * 100}vw;
|
|
82
|
-
transition:
|
|
77
|
+
transition: ${(0, HoverStyles_1.getTransitions)(['strokeWidth', 'radius', 'strokeColor'], hoverParams)};
|
|
78
|
+
}
|
|
79
|
+
.video-wrapper-${item.id}:hover .video {
|
|
80
|
+
${(0, HoverStyles_1.getHoverStyles)(['strokeWidth', 'radius', 'strokeColor'], hoverParams)};
|
|
83
81
|
}
|
|
84
|
-
${wrapperStatesCSS}
|
|
85
|
-
${videoStatesCSS}
|
|
86
82
|
`);
|
|
87
83
|
})}
|
|
88
84
|
` })] }));
|