@cntrl-site/sdk-nextjs 1.0.18 → 1.0.19-alpha.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/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/inspectionProfiles/Project_Default.xml +15 -0
- package/jest.config.js +2 -2
- package/lib/components/Article.js +9 -8
- package/lib/components/Item.js +31 -13
- package/lib/components/items/CodeEmbedItem.js +9 -8
- package/lib/components/items/CustomItem.js +8 -7
- package/lib/components/items/GroupItem.js +9 -8
- package/lib/components/items/ImageItem.js +13 -12
- package/lib/components/items/RectangleItem.js +9 -8
- package/lib/components/items/RichTextItem.js +8 -7
- package/lib/components/items/VideoItem.js +13 -12
- package/lib/components/items/VimeoEmbed.js +16 -15
- package/lib/components/items/YoutubeEmbed.js +14 -13
- package/lib/components/useStatesClassNames.js +18 -0
- package/lib/provider/InteractionsContext.js +45 -0
- package/lib/utils/{HoverStyles/HoverStyles.js → StateStyles/StateStyles.js} +18 -16
- package/lib/utils/getStatesCSS.js +16 -0
- package/package.json +7 -4
- package/src/components/Article.tsx +31 -28
- package/src/components/ArticleWrapper.tsx +1 -2
- package/src/components/Item.tsx +35 -18
- package/src/components/items/CodeEmbedItem.tsx +10 -9
- package/src/components/items/CustomItem.tsx +10 -9
- package/src/components/items/GroupItem.tsx +10 -9
- package/src/components/items/ImageItem.tsx +16 -15
- package/src/components/items/RectangleItem.tsx +11 -10
- package/src/components/items/RichTextItem.tsx +15 -9
- package/src/components/items/VideoItem.tsx +16 -15
- package/src/components/items/VimeoEmbed.tsx +17 -16
- package/src/components/items/YoutubeEmbed.tsx +15 -15
- package/src/components/useStatesClassNames.ts +23 -0
- package/src/provider/InteractionsContext.test.tsx +97 -0
- package/src/provider/InteractionsContext.tsx +65 -0
- package/src/utils/{HoverStyles/HoverStyles.ts → StateStyles/StateStyles.ts} +22 -21
- package/src/utils/getStatesCSS.ts +21 -0
- package/cntrl-site-sdk-nextjs-1.0.17.tgz +0 -0
- package/cntrl-site-sdk-nextjs-1.0.18.tgz +0 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<component name="InspectionProjectProfileManager">
|
|
2
|
+
<profile version="1.0">
|
|
3
|
+
<option name="myName" value="Project Default" />
|
|
4
|
+
<inspection_tool class="HtmlUnknownAttribute" enabled="true" level="WARNING" enabled_by_default="true">
|
|
5
|
+
<option name="myValues">
|
|
6
|
+
<value>
|
|
7
|
+
<list size="1">
|
|
8
|
+
<item index="0" class="java.lang.String" itemvalue="jsx" />
|
|
9
|
+
</list>
|
|
10
|
+
</value>
|
|
11
|
+
</option>
|
|
12
|
+
<option name="myCustomValuesEnabled" value="true" />
|
|
13
|
+
</inspection_tool>
|
|
14
|
+
</profile>
|
|
15
|
+
</component>
|
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, { interactions: article.interactions, 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/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,9 @@ 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 InteractionsContext_1 = require("../provider/InteractionsContext");
|
|
34
|
+
const getStatesCSS_1 = require("../utils/getStatesCSS");
|
|
35
|
+
const useStatesClassNames_1 = require("./useStatesClassNames");
|
|
34
36
|
const itemsMap = {
|
|
35
37
|
[sdk_1.ArticleItemType.Rectangle]: RectangleItem_1.RectangleItem,
|
|
36
38
|
[sdk_1.ArticleItemType.Image]: ImageItem_1.ImageItem,
|
|
@@ -68,8 +70,9 @@ const Item = ({ item, sectionId, articleHeight, isInGroup = false }) => {
|
|
|
68
70
|
const sectionHeight = (0, useSectionHeightMap_1.useSectionHeightData)(sectionId);
|
|
69
71
|
const stickyTop = (0, useStickyItemTop_1.useStickyItemTop)(item, sectionHeight, sectionId);
|
|
70
72
|
const dimensions = (0, useItemDimensions_1.useItemDimensions)(item, sectionId);
|
|
71
|
-
const layoutValues = [item.area, item.hidden, item.state
|
|
73
|
+
const layoutValues = [item.area, item.hidden, item.state];
|
|
72
74
|
const isInitialRef = (0, react_1.useRef)(true);
|
|
75
|
+
const { transitionTo, getItemTrigger } = (0, react_1.useContext)(InteractionsContext_1.InteractionsContext);
|
|
73
76
|
layoutValues.push(item.sticky);
|
|
74
77
|
layoutValues.push(sectionHeight);
|
|
75
78
|
if (item.layoutParams) {
|
|
@@ -102,11 +105,28 @@ const Item = ({ item, sectionId, articleHeight, isInGroup = false }) => {
|
|
|
102
105
|
isInitialRef.current = false;
|
|
103
106
|
}, []);
|
|
104
107
|
const isRichText = isItemType(item, sdk_1.ArticleItemType.RichText);
|
|
105
|
-
|
|
108
|
+
const innerStatesClassNames = (0, useStatesClassNames_1.useStatesClassNames)(item.id, item.state, 'item-inner');
|
|
109
|
+
const wrapperStatesClassNames = (0, useStatesClassNames_1.useStatesClassNames)(item.id, item.state, 'item-wrapper');
|
|
110
|
+
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: {
|
|
106
111
|
opacity: (keyframes.length !== 0 && !layout) ? 0 : 1,
|
|
107
112
|
top: `${stickyTop * 100}vw`,
|
|
108
113
|
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`,
|
|
114
|
+
}, children: (0, jsx_runtime_1.jsx)(RichTextWrapper, { isRichText: isRichText, children: (0, jsx_runtime_1.jsx)("div", { className: `item-${item.id}-inner ${innerStatesClassNames}`, onClick: () => {
|
|
115
|
+
const trigger = getItemTrigger(item.id, 'click');
|
|
116
|
+
if (!trigger)
|
|
117
|
+
return;
|
|
118
|
+
transitionTo(trigger.id, trigger.to);
|
|
119
|
+
}, onMouseEnter: () => {
|
|
120
|
+
const trigger = getItemTrigger(item.id, 'hover-in');
|
|
121
|
+
if (!trigger)
|
|
122
|
+
return;
|
|
123
|
+
transitionTo(trigger.id, trigger.to);
|
|
124
|
+
}, onMouseLeave: () => {
|
|
125
|
+
const trigger = getItemTrigger(item.id, 'hover-out');
|
|
126
|
+
if (!trigger)
|
|
127
|
+
return;
|
|
128
|
+
transitionTo(trigger.id, trigger.to);
|
|
129
|
+
}, style: Object.assign(Object.assign({}, (dimensions ? {
|
|
110
130
|
width: `${sizingAxis.x === 'manual'
|
|
111
131
|
? isRichText
|
|
112
132
|
? `${dimensions.width * exemplary}px`
|
|
@@ -114,10 +134,12 @@ const Item = ({ item, sectionId, articleHeight, isInGroup = false }) => {
|
|
|
114
134
|
: 'max-content'}`,
|
|
115
135
|
height: `${sizingAxis.y === 'manual' ? `${dimensions.height * 100}vw` : 'unset'}`
|
|
116
136
|
} : {})), (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,
|
|
137
|
+
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, hidden, states, sticky, sectionHeight, layoutParams], exemplary) => {
|
|
118
138
|
const sizingAxis = parseSizing(layoutParams.sizing);
|
|
119
139
|
const isScreenBasedBottom = area.positionType === sdk_1.PositionType.ScreenBased && area.anchorSide === sdk_1.AnchorSide.Bottom;
|
|
120
140
|
const scaleAnchor = area.scaleAnchor;
|
|
141
|
+
const statesInnerCSS = (0, getStatesCSS_1.getStatesCSS)(item.id, 'item-inner', ['width', 'height', 'scale'], states);
|
|
142
|
+
const statesWrapperCSS = (0, getStatesCSS_1.getStatesCSS)(item.id, 'item-wrapper', ['top', 'left'], states, area.anchorSide);
|
|
121
143
|
return (`
|
|
122
144
|
.item-${item.id} {
|
|
123
145
|
position: ${sticky ? 'sticky' : 'absolute'};
|
|
@@ -128,7 +150,6 @@ const Item = ({ item, sectionId, articleHeight, isInGroup = false }) => {
|
|
|
128
150
|
height: fit-content;
|
|
129
151
|
}
|
|
130
152
|
.item-${item.id}-inner {
|
|
131
|
-
transition: ${(0, HoverStyles_1.getTransitions)(['width', 'height', 'scale'], hoverParams)};
|
|
132
153
|
pointer-events: auto;
|
|
133
154
|
width: ${sizingAxis.x === 'manual'
|
|
134
155
|
? `${area.width * 100}vw`
|
|
@@ -136,6 +157,7 @@ const Item = ({ item, sectionId, articleHeight, isInGroup = false }) => {
|
|
|
136
157
|
height: ${sizingAxis.y === 'manual' ? `${area.height * 100}vw` : 'unset'};
|
|
137
158
|
transform-origin: ${ScaleAnchorMap_1.ScaleAnchorMap[scaleAnchor]};
|
|
138
159
|
transform: scale(${area.scale});
|
|
160
|
+
transition: all 0.2s ease;
|
|
139
161
|
}
|
|
140
162
|
.item-wrapper-${item.id} {
|
|
141
163
|
position: ${area.positionType === sdk_1.PositionType.ScreenBased ? 'fixed' : 'absolute'};
|
|
@@ -145,14 +167,10 @@ const Item = ({ item, sectionId, articleHeight, isInGroup = false }) => {
|
|
|
145
167
|
bottom: ${isScreenBasedBottom ? `${-area.top * 100}vw` : 'unset'};
|
|
146
168
|
top: ${isScreenBasedBottom ? 'unset' : (0, getItemTopStyle_1.getItemTopStyle)(area.top, area.anchorSide)};
|
|
147
169
|
left: ${area.left * 100}vw;
|
|
148
|
-
transition:
|
|
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)};
|
|
170
|
+
transition: all 0.2s ease;
|
|
155
171
|
}
|
|
172
|
+
${statesWrapperCSS}
|
|
173
|
+
${statesInnerCSS}
|
|
156
174
|
`);
|
|
157
175
|
})}
|
|
158
176
|
` })] }));
|
|
@@ -8,12 +8,13 @@ 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
14
|
const LinkWrapper_1 = require("../LinkWrapper");
|
|
16
15
|
const useCodeEmbedItem_1 = require("./useCodeEmbedItem");
|
|
16
|
+
const getStatesCSS_1 = require("../../utils/getStatesCSS");
|
|
17
|
+
const useStatesClassNames_1 = require("../useStatesClassNames");
|
|
17
18
|
const stylesMap = {
|
|
18
19
|
[sdk_1.AreaAnchor.TopLeft]: {},
|
|
19
20
|
[sdk_1.AreaAnchor.TopCenter]: { justifyContent: 'center' },
|
|
@@ -35,7 +36,8 @@ const CodeEmbedItem = ({ item, sectionId, onResize }) => {
|
|
|
35
36
|
const [ref, setRef] = (0, react_1.useState)(null);
|
|
36
37
|
(0, useRegisterResize_1.useRegisterResize)(ref, onResize);
|
|
37
38
|
const pos = stylesMap[anchor];
|
|
38
|
-
const layoutValues = [item.area, item.layoutParams, item.state
|
|
39
|
+
const layoutValues = [item.area, item.layoutParams, item.state];
|
|
40
|
+
const statesClassNames = (0, useStatesClassNames_1.useStatesClassNames)(item.id, item.state, 'embed-wrapper');
|
|
39
41
|
(0, react_1.useEffect)(() => {
|
|
40
42
|
if (!ref)
|
|
41
43
|
return;
|
|
@@ -58,7 +60,7 @@ const CodeEmbedItem = ({ item, sectionId, onResize }) => {
|
|
|
58
60
|
return;
|
|
59
61
|
iframe.srcdoc = item.commonParams.html;
|
|
60
62
|
}, [item.commonParams.html, item.commonParams.iframe, ref]);
|
|
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: `
|
|
63
|
+
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} ${statesClassNames}`, 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: `
|
|
62
64
|
.embed-wrapper-${item.id} {
|
|
63
65
|
position: absolute;
|
|
64
66
|
width: 100%;
|
|
@@ -70,21 +72,20 @@ const CodeEmbedItem = ({ item, sectionId, onResize }) => {
|
|
|
70
72
|
z-index: 1;
|
|
71
73
|
border: none;
|
|
72
74
|
}
|
|
73
|
-
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams,
|
|
75
|
+
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams, stateParams], exemplary) => {
|
|
76
|
+
const statesCSS = (0, getStatesCSS_1.getStatesCSS)(item.id, 'embed-wrapper', ['angle', 'blur', 'opacity'], stateParams);
|
|
74
77
|
return (`
|
|
75
78
|
.embed-wrapper-${item.id} {
|
|
76
79
|
opacity: ${layoutParams.opacity};
|
|
77
80
|
transform: rotate(${area.angle}deg);
|
|
78
81
|
filter: ${layoutParams.blur !== 0 ? `blur(${layoutParams.blur * 100}vw)` : 'unset'};
|
|
79
|
-
transition:
|
|
82
|
+
transition: all 0.2s ease;
|
|
80
83
|
}
|
|
81
84
|
.embed-${item.id} {
|
|
82
85
|
width: ${item.commonParams.scale ? `${area.width * exemplary}px` : '100%'};
|
|
83
86
|
height: ${item.commonParams.scale ? `${area.height * exemplary}px` : '100%'};
|
|
84
87
|
}
|
|
85
|
-
|
|
86
|
-
${(0, HoverStyles_1.getHoverStyles)(['angle', 'blur', 'opacity'], hoverParams)}
|
|
87
|
-
}
|
|
88
|
+
${statesCSS}
|
|
88
89
|
`);
|
|
89
90
|
})}
|
|
90
91
|
` })] }));
|
|
@@ -8,34 +8,35 @@ 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");
|
|
14
|
+
const useStatesClassNames_1 = require("../useStatesClassNames");
|
|
15
|
+
const getStatesCSS_1 = require("../../utils/getStatesCSS");
|
|
15
16
|
const CustomItem = ({ item, onResize, sectionId }) => {
|
|
16
17
|
const sdk = (0, useCntrlContext_1.useCntrlContext)();
|
|
17
18
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
18
19
|
const angle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
|
|
19
20
|
const component = sdk.customItems.get(item.commonParams.name);
|
|
20
|
-
const layoutValues = [item.area, item.state
|
|
21
|
+
const layoutValues = [item.area, item.state];
|
|
21
22
|
const [ref, setRef] = (0, react_1.useState)(null);
|
|
22
23
|
(0, useRegisterResize_1.useRegisterResize)(ref, onResize);
|
|
24
|
+
const statesClassNames = (0, useStatesClassNames_1.useStatesClassNames)(item.id, item.state, 'custom-component');
|
|
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} ${statesClassNames}`, 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, stateParams]) => {
|
|
28
|
+
const statesCSS = (0, getStatesCSS_1.getStatesCSS)(item.id, 'custom-component', ['angle'], stateParams);
|
|
26
29
|
return (`
|
|
27
30
|
.custom-component-${item.id} {
|
|
28
31
|
transform: rotate(${area.angle}deg);
|
|
29
|
-
transition:
|
|
32
|
+
transition: all 0.2s ease;
|
|
30
33
|
height: 100%;
|
|
31
34
|
width: 100%;
|
|
32
35
|
position: absolute;
|
|
33
36
|
left: 0;
|
|
34
37
|
top: 0;
|
|
35
38
|
}
|
|
36
|
-
|
|
37
|
-
${(0, HoverStyles_1.getHoverStyles)(['angle'], hoverParams)};
|
|
38
|
-
}
|
|
39
|
+
${statesCSS}
|
|
39
40
|
`);
|
|
40
41
|
})}` })] }));
|
|
41
42
|
};
|
|
@@ -9,12 +9,13 @@ 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");
|
|
17
|
+
const useStatesClassNames_1 = require("../useStatesClassNames");
|
|
18
|
+
const getStatesCSS_1 = require("../../utils/getStatesCSS");
|
|
18
19
|
const GroupItem = ({ item, sectionId, onResize, articleHeight }) => {
|
|
19
20
|
var _a, _b;
|
|
20
21
|
const id = (0, react_1.useId)();
|
|
@@ -22,26 +23,26 @@ const GroupItem = ({ item, sectionId, onResize, articleHeight }) => {
|
|
|
22
23
|
const angle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
|
|
23
24
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
24
25
|
const { opacity } = (0, useGroupItem_1.useGroupItem)(item, sectionId);
|
|
25
|
-
const layoutValues = [item.area, item.layoutParams, item.state
|
|
26
|
+
const layoutValues = [item.area, item.layoutParams, item.state];
|
|
27
|
+
const statesClassNames = (0, useStatesClassNames_1.useStatesClassNames)(item.id, item.state, 'group');
|
|
26
28
|
const [ref, setRef] = (0, react_1.useState)(null);
|
|
27
29
|
(0, useRegisterResize_1.useRegisterResize)(ref, onResize);
|
|
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: `
|
|
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: `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: `
|
|
29
31
|
.group-${item.id} {
|
|
30
32
|
position: absolute;
|
|
31
33
|
width: 100%;
|
|
32
34
|
height: 100%;
|
|
33
35
|
box-sizing: border-box;
|
|
34
36
|
}
|
|
35
|
-
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams,
|
|
37
|
+
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams, stateParams]) => {
|
|
38
|
+
const statesCSS = (0, getStatesCSS_1.getStatesCSS)(item.id, 'group', ['opacity', 'angle'], stateParams);
|
|
36
39
|
return (`
|
|
37
40
|
.group-${item.id} {
|
|
38
41
|
opacity: ${layoutParams.opacity};
|
|
39
42
|
transform: rotate(${area.angle}deg);
|
|
40
|
-
transition:
|
|
41
|
-
}
|
|
42
|
-
.group-${item.id}:hover {
|
|
43
|
-
${(0, HoverStyles_1.getHoverStyles)(['opacity', 'angle'], hoverParams)};
|
|
43
|
+
transition: all 0.2s ease;
|
|
44
44
|
}
|
|
45
|
+
${statesCSS}
|
|
45
46
|
`);
|
|
46
47
|
})}
|
|
47
48
|
` })] }) }));
|
|
@@ -13,11 +13,12 @@ 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 useStatesClassNames_1 = require("../useStatesClassNames");
|
|
21
|
+
const getStatesCSS_1 = require("../../utils/getStatesCSS");
|
|
21
22
|
const baseVariables = `precision mediump float;
|
|
22
23
|
uniform sampler2D u_image;
|
|
23
24
|
uniform sampler2D u_pattern;
|
|
@@ -46,12 +47,14 @@ const ImageItem = ({ item, sectionId, onResize }) => {
|
|
|
46
47
|
acc[control.shaderParam] = control.value;
|
|
47
48
|
return acc;
|
|
48
49
|
}, {});
|
|
49
|
-
const layoutValues = [item.area, item.layoutParams, item.state
|
|
50
|
+
const layoutValues = [item.area, item.layoutParams, item.state];
|
|
50
51
|
const fullShaderCode = `${baseVariables}\n${controlsVariables}\n${fragmentShader}`;
|
|
51
52
|
const area = layoutId ? item.area[layoutId] : null;
|
|
52
53
|
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
54
|
const width = area && exemplary ? area.width * exemplary : 0;
|
|
54
55
|
const height = area && exemplary ? area.height * exemplary : 0;
|
|
56
|
+
const statesWrapperClassNames = (0, useStatesClassNames_1.useStatesClassNames)(item.id, item.state, 'image-wrapper');
|
|
57
|
+
const statesImgClassNames = (0, useStatesClassNames_1.useStatesClassNames)(item.id, item.state, 'image');
|
|
55
58
|
(0, react_1.useEffect)(() => {
|
|
56
59
|
isInitialRef.current = false;
|
|
57
60
|
}, []);
|
|
@@ -65,7 +68,7 @@ const ImageItem = ({ item, sectionId, onResize }) => {
|
|
|
65
68
|
const rectWidth = Math.floor((_b = rect === null || rect === void 0 ? void 0 : rect.width) !== null && _b !== void 0 ? _b : 0);
|
|
66
69
|
const rectHeight = Math.floor((_c = rect === null || rect === void 0 ? void 0 : rect.height) !== null && _c !== void 0 ? _c : 0);
|
|
67
70
|
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` } : {}));
|
|
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: `
|
|
71
|
+
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} ${statesWrapperClassNames}`, 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} ${statesImgClassNames}`, width: rectWidth, height: rectHeight })) : ((0, jsx_runtime_1.jsx)("img", { alt: "", className: `image image-${item.id} ${statesImgClassNames}`, style: inlineStyles, src: item.commonParams.url })) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
69
72
|
.image-wrapper-${item.id} {
|
|
70
73
|
position: absolute;
|
|
71
74
|
width: 100%;
|
|
@@ -91,26 +94,24 @@ const ImageItem = ({ item, sectionId, onResize }) => {
|
|
|
91
94
|
border-width: 0;
|
|
92
95
|
box-sizing: border-box;
|
|
93
96
|
}
|
|
94
|
-
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams,
|
|
97
|
+
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams, stateParams]) => {
|
|
98
|
+
const wrapperStatesCSS = (0, getStatesCSS_1.getStatesCSS)(item.id, 'image-wrapper', ['angle', 'opacity', 'blur'], stateParams);
|
|
99
|
+
const imgStatesCSS = (0, getStatesCSS_1.getStatesCSS)(item.id, 'image', ['strokeWidth', 'radius', 'strokeColor'], stateParams);
|
|
95
100
|
return (`
|
|
96
101
|
.image-wrapper-${item.id} {
|
|
97
102
|
opacity: ${layoutParams.opacity};
|
|
98
103
|
transform: rotate(${area.angle}deg);
|
|
99
104
|
filter: ${layoutParams.blur !== 0 ? `blur(${layoutParams.blur * 100}vw)` : 'unset'};
|
|
100
|
-
transition:
|
|
101
|
-
}
|
|
102
|
-
.image-wrapper-${item.id}:hover {
|
|
103
|
-
${(0, HoverStyles_1.getHoverStyles)(['angle', 'opacity', 'blur'], hoverParams)};
|
|
105
|
+
transition: all 0.2s ease;
|
|
104
106
|
}
|
|
105
107
|
.image-${item.id} {
|
|
106
108
|
border-color: ${color_1.CntrlColor.parse(layoutParams.strokeColor).fmt('rgba')};
|
|
107
109
|
border-radius: ${layoutParams.radius * 100}vw;
|
|
108
110
|
border-width: ${layoutParams.strokeWidth * 100}vw;
|
|
109
|
-
transition:
|
|
110
|
-
}
|
|
111
|
-
.image-wrapper-${item.id}:hover .image, .image-wrapper-${item.id}:hover .img-canvas {
|
|
112
|
-
${(0, HoverStyles_1.getHoverStyles)(['strokeWidth', 'radius', 'strokeColor'], hoverParams)};
|
|
111
|
+
transition: all 0.2s ease;
|
|
113
112
|
}
|
|
113
|
+
${wrapperStatesCSS}
|
|
114
|
+
${imgStatesCSS}
|
|
114
115
|
`);
|
|
115
116
|
})}
|
|
116
117
|
` })] }) }));
|
|
@@ -13,8 +13,9 @@ 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");
|
|
17
|
+
const getStatesCSS_1 = require("../../utils/getStatesCSS");
|
|
18
|
+
const useStatesClassNames_1 = require("../useStatesClassNames");
|
|
18
19
|
const RectangleItem = ({ item, sectionId, onResize }) => {
|
|
19
20
|
var _a, _b;
|
|
20
21
|
const id = (0, react_1.useId)();
|
|
@@ -23,11 +24,12 @@ const RectangleItem = ({ item, sectionId, onResize }) => {
|
|
|
23
24
|
const angle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
|
|
24
25
|
const backgroundColor = (0, react_1.useMemo)(() => fillColor ? color_1.CntrlColor.parse(fillColor) : undefined, [fillColor]);
|
|
25
26
|
const borderColor = (0, react_1.useMemo)(() => strokeColor ? color_1.CntrlColor.parse(strokeColor) : undefined, [strokeColor]);
|
|
26
|
-
const layoutValues = [item.area, item.layoutParams, item.state
|
|
27
|
+
const layoutValues = [item.area, item.layoutParams, item.state];
|
|
27
28
|
const [ref, setRef] = (0, react_1.useState)(null);
|
|
29
|
+
const statesClassNames = (0, useStatesClassNames_1.useStatesClassNames)(item.id, item.state, 'rectangle');
|
|
28
30
|
(0, useRegisterResize_1.useRegisterResize)(ref, onResize);
|
|
29
31
|
const backdropFilterValue = backdropBlur ? `blur(${backdropBlur * 100}vw)` : 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
|
|
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: `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
|
|
31
33
|
? { backdropFilter: backdropFilterValue, WebkitBackdropFilter: backdropFilterValue }
|
|
32
34
|
: {})) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
33
35
|
.rectangle-${item.id} {
|
|
@@ -37,7 +39,8 @@ const RectangleItem = ({ item, sectionId, onResize }) => {
|
|
|
37
39
|
border-style: solid;
|
|
38
40
|
box-sizing: border-box;
|
|
39
41
|
}
|
|
40
|
-
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams,
|
|
42
|
+
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams, states]) => {
|
|
43
|
+
const statesCSS = (0, getStatesCSS_1.getStatesCSS)(item.id, 'rectangle', ['angle', 'fillColor', 'strokeWidth', 'radius', 'strokeColor', 'blur', 'backdropBlur'], states);
|
|
41
44
|
return (`
|
|
42
45
|
.rectangle-${item.id} {
|
|
43
46
|
background-color: ${color_1.CntrlColor.parse(layoutParams.fillColor).fmt('rgba')};
|
|
@@ -48,11 +51,9 @@ const RectangleItem = ({ item, sectionId, onResize }) => {
|
|
|
48
51
|
filter: ${layoutParams.blur !== 0 ? `blur(${layoutParams.blur * 100}vw)` : 'unset'};
|
|
49
52
|
backdrop-filter: ${layoutParams.backdropFilter !== 0 ? `blur(${layoutParams.blur * 100}vw)` : 'unset'};
|
|
50
53
|
-webkit-backdrop-filter: ${layoutParams.backdropFilter !== 0 ? `blur(${layoutParams.blur * 100}vw)` : 'unset'};
|
|
51
|
-
transition:
|
|
52
|
-
}
|
|
53
|
-
.rectangle-${item.id}:hover {
|
|
54
|
-
${(0, HoverStyles_1.getHoverStyles)(['angle', 'fillColor', 'strokeWidth', 'radius', 'strokeColor', 'blur', 'backdropBlur'], hoverParams)};
|
|
54
|
+
transition: all 0.2s ease;
|
|
55
55
|
}
|
|
56
|
+
${statesCSS}
|
|
56
57
|
`);
|
|
57
58
|
})}
|
|
58
59
|
` })] }) }));
|
|
@@ -11,12 +11,13 @@ 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");
|
|
15
14
|
const useRichTextItemValues_1 = require("./useRichTextItemValues");
|
|
16
15
|
const useRegisterResize_1 = require("../../common/useRegisterResize");
|
|
17
16
|
const getFontFamilyValue_1 = require("../../utils/getFontFamilyValue");
|
|
18
17
|
const useExemplary_1 = require("../../common/useExemplary");
|
|
19
18
|
const useItemAngle_1 = require("../useItemAngle");
|
|
19
|
+
const useStatesClassNames_1 = require("../useStatesClassNames");
|
|
20
|
+
const getStatesCSS_1 = require("../../utils/getStatesCSS");
|
|
20
21
|
const RichTextItem = ({ item, sectionId, onResize }) => {
|
|
21
22
|
const [content, styles] = (0, useRichTextItem_1.useRichTextItem)(item);
|
|
22
23
|
const id = (0, react_1.useId)();
|
|
@@ -25,11 +26,13 @@ const RichTextItem = ({ item, sectionId, onResize }) => {
|
|
|
25
26
|
const angle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
|
|
26
27
|
const { blur, wordSpacing, letterSpacing, color, fontSize, lineHeight } = (0, useRichTextItemValues_1.useRichTextItemValues)(item, sectionId);
|
|
27
28
|
const textColor = (0, react_1.useMemo)(() => color ? color_1.CntrlColor.parse(color) : undefined, [color]);
|
|
28
|
-
const layoutValues = [item.area, item.layoutParams, item.state
|
|
29
|
+
const layoutValues = [item.area, item.layoutParams, item.state];
|
|
29
30
|
const exemplary = (0, useExemplary_1.useExemplary)();
|
|
31
|
+
const stateClassNames = (0, useStatesClassNames_1.useStatesClassNames)(item.id, item.state, 'rich-text-wrapper');
|
|
30
32
|
(0, useRegisterResize_1.useRegisterResize)(ref, onResize);
|
|
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,
|
|
33
|
+
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]) => {
|
|
32
34
|
const color = color_1.CntrlColor.parse(layoutParams.color);
|
|
35
|
+
const statesCSS = (0, getStatesCSS_1.getStatesCSS)(item.id, 'rich-text-wrapper', ['angle', 'blur', 'letterSpacing', 'wordSpacing', 'color'], states);
|
|
33
36
|
return (`
|
|
34
37
|
.rich-text-wrapper-${item.id} {
|
|
35
38
|
font-size: ${layoutParams.fontSize * 100}vw;
|
|
@@ -45,16 +48,14 @@ const RichTextItem = ({ item, sectionId, onResize }) => {
|
|
|
45
48
|
transform: rotate(${area.angle}deg);
|
|
46
49
|
filter: ${layoutParams.blur !== 0 ? `blur(${layoutParams.blur * 100}vw)` : 'unset'};
|
|
47
50
|
text-transform: ${layoutParams.textTransform};
|
|
48
|
-
transition:
|
|
49
|
-
}
|
|
50
|
-
.rich-text-wrapper-${item.id}:hover {
|
|
51
|
-
${(0, HoverStyles_1.getHoverStyles)(['angle', 'blur', 'letterSpacing', 'wordSpacing', 'color'], hoverParams)};
|
|
51
|
+
transition: all 0.2s ease;
|
|
52
52
|
}
|
|
53
53
|
@supports not (color: oklch(42% 0.3 90 / 1)) {
|
|
54
54
|
.rich-text-wrapper-${item.id} {
|
|
55
55
|
color: ${color.fmt('rgba')};
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
+
${statesCSS}
|
|
58
59
|
`);
|
|
59
60
|
})}`] })] }));
|
|
60
61
|
};
|
|
@@ -13,10 +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 useLayoutContext_1 = require("../useLayoutContext");
|
|
19
18
|
const ScrollPlaybackVideo_1 = require("../ScrollPlaybackVideo");
|
|
19
|
+
const useStatesClassNames_1 = require("../useStatesClassNames");
|
|
20
|
+
const getStatesCSS_1 = require("../../utils/getStatesCSS");
|
|
20
21
|
const VideoItem = ({ item, sectionId, onResize }) => {
|
|
21
22
|
var _a, _b, _c;
|
|
22
23
|
const id = (0, react_1.useId)();
|
|
@@ -28,11 +29,13 @@ const VideoItem = ({ item, sectionId, onResize }) => {
|
|
|
28
29
|
const videoRef = (0, react_1.useRef)(null);
|
|
29
30
|
const layoutId = (0, useLayoutContext_1.useLayoutContext)();
|
|
30
31
|
const scrollPlayback = layoutId ? item.layoutParams[layoutId].scrollPlayback : null;
|
|
31
|
-
const layoutValues = [item.area, item.layoutParams, item.state
|
|
32
|
+
const layoutValues = [item.area, item.layoutParams, item.state];
|
|
33
|
+
const statesWrapperClassNames = (0, useStatesClassNames_1.useStatesClassNames)(item.id, item.state, 'video-wrapper');
|
|
34
|
+
const statesVideoClassNames = (0, useStatesClassNames_1.useStatesClassNames)(item.id, item.state, 'video');
|
|
32
35
|
const hasScrollPlayback = scrollPlayback !== null;
|
|
33
36
|
(0, useRegisterResize_1.useRegisterResize)(ref, onResize);
|
|
34
37
|
const inlineStyles = Object.assign(Object.assign(Object.assign({}, (radius !== undefined ? { borderRadius: `${radius * 100}vw` } : {})), (strokeWidth !== undefined ? { borderWidth: `${strokeWidth * 100}vw` } : {})), (borderColor ? { borderColor: `${borderColor.toCss()}` } : {}));
|
|
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: `
|
|
38
|
+
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} ${statesWrapperClassNames}`, 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} ${statesWrapperClassNames}` })) : ((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} ${statesVideoClassNames}`, style: inlineStyles, children: (0, jsx_runtime_1.jsx)("source", { src: item.commonParams.url }) })) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
36
39
|
.video-wrapper-${item.id} {
|
|
37
40
|
position: absolute;
|
|
38
41
|
overflow: hidden;
|
|
@@ -59,26 +62,24 @@ const VideoItem = ({ item, sectionId, onResize }) => {
|
|
|
59
62
|
display: flex;
|
|
60
63
|
justify-content: center;
|
|
61
64
|
}
|
|
62
|
-
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams,
|
|
65
|
+
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams, stateParams]) => {
|
|
66
|
+
const wrapperStatesCSS = (0, getStatesCSS_1.getStatesCSS)(item.id, 'video-wrapper', ['angle', 'opacity', 'blur'], stateParams);
|
|
67
|
+
const videoStatesCSS = (0, getStatesCSS_1.getStatesCSS)(item.id, 'video', ['strokeWidth', 'radius', 'strokeColor'], stateParams);
|
|
63
68
|
return (`
|
|
64
69
|
.video-wrapper-${item.id} {
|
|
65
70
|
opacity: ${layoutParams.opacity};
|
|
66
71
|
transform: rotate(${area.angle}deg);
|
|
67
72
|
filter: ${layoutParams.blur !== 0 ? `blur(${layoutParams.blur * 100}vw)` : 'unset'};
|
|
68
|
-
transition:
|
|
69
|
-
}
|
|
70
|
-
.video-wrapper-${item.id}:hover {
|
|
71
|
-
${(0, HoverStyles_1.getHoverStyles)(['angle', 'opacity', 'blur'], hoverParams)};
|
|
73
|
+
transition: all 0.2s ease;
|
|
72
74
|
}
|
|
73
75
|
.video-${item.id} {
|
|
74
76
|
border-color: ${color_1.CntrlColor.parse(layoutParams.strokeColor).fmt('rgba')};
|
|
75
77
|
border-radius: ${layoutParams.radius * 100}vw;
|
|
76
78
|
border-width: ${layoutParams.strokeWidth * 100}vw;
|
|
77
|
-
transition:
|
|
78
|
-
}
|
|
79
|
-
.video-wrapper-${item.id}:hover .video {
|
|
80
|
-
${(0, HoverStyles_1.getHoverStyles)(['strokeWidth', 'radius', 'strokeColor'], hoverParams)};
|
|
79
|
+
transition: all 0.2s ease;
|
|
81
80
|
}
|
|
81
|
+
${wrapperStatesCSS}
|
|
82
|
+
${videoStatesCSS}
|
|
82
83
|
`);
|
|
83
84
|
})}
|
|
84
85
|
` })] }));
|