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