@cntrl-site/sdk-nextjs 0.14.2 → 0.14.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cntrl-site-sdk-nextjs-0.14.3.tgz +0 -0
- package/cntrl-site-sdk-nextjs-0.14.4.tgz +0 -0
- package/lib/common/useCurrentLayout.js +1 -6
- package/lib/common/useKeyframeValue.js +2 -2
- package/lib/components/Article.js +5 -4
- package/lib/components/ArticleWrapper.js +35 -0
- package/lib/components/Item.js +6 -4
- package/lib/components/items/ImageItem.js +5 -4
- package/lib/components/items/RectangleItem.js +6 -4
- package/lib/components/items/RichTextItem.js +6 -5
- package/lib/components/items/VideoItem.js +5 -4
- package/lib/components/items/VimeoEmbed.js +5 -4
- package/lib/components/items/YoutubeEmbed.js +5 -4
- package/lib/components/items/useEmbedVideoItem.js +9 -3
- package/lib/components/items/useFileItem.js +9 -3
- package/lib/components/items/useRectangleItem.js +15 -3
- package/lib/components/items/useRichTextItem.js +3 -3
- package/lib/components/items/useRichTextItemValues.js +17 -0
- package/lib/components/items/useStickyItemTop.js +12 -6
- package/lib/components/useItemDimensions.js +2 -2
- package/lib/components/useItemPosition.js +10 -4
- package/lib/components/useItemScale.js +5 -4
- package/lib/components/useLayoutContext.js +10 -0
- package/lib/components/useSectionColor.js +5 -3
- package/lib/provider/LayoutContext.js +5 -0
- package/lib/utils/Animator/Animator.js +33 -1
- package/lib/utils/HoverStyles/HoverStyles.js +5 -1
- package/package.json +2 -2
- package/src/common/useCurrentLayout.ts +2 -9
- package/src/common/useKeyframeValue.ts +3 -3
- package/src/components/Article.tsx +15 -12
- package/src/components/ArticleWrapper.tsx +36 -0
- package/src/components/Item.tsx +5 -4
- package/src/components/items/ImageItem.tsx +5 -4
- package/src/components/items/RectangleItem.tsx +6 -4
- package/src/components/items/RichTextItem.tsx +6 -5
- package/src/components/items/VideoItem.tsx +5 -4
- package/src/components/items/VimeoEmbed.tsx +6 -6
- package/src/components/items/YoutubeEmbed.tsx +5 -4
- package/src/components/items/useEmbedVideoItem.ts +15 -4
- package/src/components/items/useFileItem.ts +14 -3
- package/src/components/items/useRectangleItem.ts +25 -3
- package/src/components/items/useRichTextItem.ts +3 -3
- package/src/components/items/useRichTextItemValues.ts +27 -0
- package/src/components/items/useStickyItemTop.ts +11 -7
- package/src/components/useItemDimensions.ts +2 -2
- package/src/components/useItemPosition.ts +8 -4
- package/src/components/useItemScale.ts +6 -5
- package/src/components/useLayoutContext.ts +7 -0
- package/src/components/useSectionColor.ts +4 -3
- package/src/provider/LayoutContext.ts +3 -0
- package/src/utils/Animator/Animator.ts +39 -1
- package/src/utils/HoverStyles/HoverStyles.ts +5 -1
- package/cntrl-site-sdk-nextjs-0.12.9.tgz +0 -0
- package/cntrl-site-sdk-nextjs-0.14.1.tgz +0 -0
|
Binary file
|
|
Binary file
|
|
@@ -24,12 +24,7 @@ const useCurrentLayout = () => {
|
|
|
24
24
|
const getCurrentLayout = (0, react_1.useCallback)((articleWidth) => {
|
|
25
25
|
return layoutRanges.find(l => articleWidth >= l.start && articleWidth < l.end).layoutId;
|
|
26
26
|
}, [layoutRanges]);
|
|
27
|
-
const [layoutId, setLayoutId] = (0, react_1.useState)(
|
|
28
|
-
(0, react_1.useEffect)(() => {
|
|
29
|
-
if (typeof window !== 'undefined') {
|
|
30
|
-
getCurrentLayout(window.innerWidth);
|
|
31
|
-
}
|
|
32
|
-
}, []);
|
|
27
|
+
const [layoutId, setLayoutId] = (0, react_1.useState)(undefined);
|
|
33
28
|
(0, react_1.useEffect)(() => {
|
|
34
29
|
if (!articleRectObserver)
|
|
35
30
|
return;
|
|
@@ -7,9 +7,9 @@ exports.useKeyframeValue = void 0;
|
|
|
7
7
|
const lodash_isequal_1 = __importDefault(require("lodash.isequal"));
|
|
8
8
|
const react_1 = require("react");
|
|
9
9
|
const ArticleRectContext_1 = require("../provider/ArticleRectContext");
|
|
10
|
-
const useCurrentLayout_1 = require("./useCurrentLayout");
|
|
11
10
|
const KeyframesContext_1 = require("../provider/KeyframesContext");
|
|
12
11
|
const Animator_1 = require("../utils/Animator/Animator");
|
|
12
|
+
const useLayoutContext_1 = require("../components/useLayoutContext");
|
|
13
13
|
const emptyDeps = [];
|
|
14
14
|
const useKeyframeValue = (item, itemParamsGetter, animatorGetter, sectionId, deps = emptyDeps) => {
|
|
15
15
|
const animatorGetterRef = (0, react_1.useRef)(animatorGetter);
|
|
@@ -17,7 +17,7 @@ const useKeyframeValue = (item, itemParamsGetter, animatorGetter, sectionId, dep
|
|
|
17
17
|
animatorGetterRef.current = animatorGetter;
|
|
18
18
|
itemParamsGetterRef.current = itemParamsGetter;
|
|
19
19
|
const articleRectObserver = (0, react_1.useContext)(ArticleRectContext_1.ArticleRectContext);
|
|
20
|
-
const layoutId = (0,
|
|
20
|
+
const layoutId = (0, useLayoutContext_1.useLayoutContext)();
|
|
21
21
|
const keyframesRepo = (0, react_1.useContext)(KeyframesContext_1.KeyframesContext);
|
|
22
22
|
const keyframes = (0, react_1.useMemo)(() => keyframesRepo.getItemKeyframes(item.id), [item.id, keyframesRepo]);
|
|
23
23
|
const paramValue = (0, react_1.useMemo)(() => {
|
|
@@ -11,14 +11,15 @@ const Section_1 = require("./Section");
|
|
|
11
11
|
const Item_1 = require("./Item");
|
|
12
12
|
const useArticleRectObserver_1 = require("../utils/ArticleRectManager/useArticleRectObserver");
|
|
13
13
|
const ArticleRectContext_1 = require("../provider/ArticleRectContext");
|
|
14
|
+
const ArticleWrapper_1 = require("./ArticleWrapper");
|
|
14
15
|
const Article = ({ article, sectionData }) => {
|
|
15
16
|
const articleRef = (0, react_1.useRef)(null);
|
|
16
17
|
const articleRectObserver = (0, useArticleRectObserver_1.useArticleRectObserver)(articleRef.current);
|
|
17
18
|
const id = (0, react_1.useId)();
|
|
18
|
-
return ((0, jsx_runtime_1.jsxs)(ArticleRectContext_1.ArticleRectContext.Provider, { value: articleRectObserver, children: [(0, jsx_runtime_1.jsx)("div", { className: "article", ref: articleRef, children: article.sections.map((section, i) => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
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) => {
|
|
20
|
+
const data = section.name ? sectionData[section.name] : {};
|
|
21
|
+
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 }, item.id))) }, section.id));
|
|
22
|
+
}) }) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
22
23
|
.article {
|
|
23
24
|
position: relative;
|
|
24
25
|
overflow: clip;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ArticleWrapper = void 0;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const style_1 = __importDefault(require("styled-jsx/style"));
|
|
10
|
+
const useCurrentLayout_1 = require("../common/useCurrentLayout");
|
|
11
|
+
const LayoutContext_1 = require("../provider/LayoutContext");
|
|
12
|
+
const ArticleWrapper = ({ children }) => {
|
|
13
|
+
const id = (0, react_1.useId)();
|
|
14
|
+
const [isPageLoaded, setIsPageLoaded] = (0, react_1.useState)(false);
|
|
15
|
+
const layoutId = (0, useCurrentLayout_1.useCurrentLayout)();
|
|
16
|
+
(0, react_1.useEffect)(() => {
|
|
17
|
+
const onPageLoad = () => {
|
|
18
|
+
setIsPageLoaded(true);
|
|
19
|
+
};
|
|
20
|
+
if (document.readyState === 'complete') {
|
|
21
|
+
onPageLoad();
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
window.addEventListener('load', onPageLoad);
|
|
25
|
+
return () => window.removeEventListener('load', onPageLoad);
|
|
26
|
+
}
|
|
27
|
+
}, []);
|
|
28
|
+
return ((0, jsx_runtime_1.jsxs)(LayoutContext_1.LayoutContext.Provider, { value: layoutId, children: [(0, jsx_runtime_1.jsx)("div", { className: "article-wrapper", style: { opacity: layoutId && isPageLoaded ? 1 : 0 }, children: children }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
29
|
+
.article-wrapper {
|
|
30
|
+
opacity: 1;
|
|
31
|
+
transition: opacity 0.2s ease;
|
|
32
|
+
}
|
|
33
|
+
` })] }));
|
|
34
|
+
};
|
|
35
|
+
exports.ArticleWrapper = ArticleWrapper;
|
package/lib/components/Item.js
CHANGED
|
@@ -18,7 +18,6 @@ const CustomItem_1 = require("./items/CustomItem");
|
|
|
18
18
|
const useCntrlContext_1 = require("../provider/useCntrlContext");
|
|
19
19
|
const useItemPosition_1 = require("./useItemPosition");
|
|
20
20
|
const useItemDimensions_1 = require("./useItemDimensions");
|
|
21
|
-
const useCurrentLayout_1 = require("../common/useCurrentLayout");
|
|
22
21
|
const useItemScale_1 = require("./useItemScale");
|
|
23
22
|
const ScaleAnchorMap_1 = require("../utils/ScaleAnchorMap");
|
|
24
23
|
const useSectionHeightMap_1 = require("./useSectionHeightMap");
|
|
@@ -26,6 +25,7 @@ const HoverStyles_1 = require("../utils/HoverStyles/HoverStyles");
|
|
|
26
25
|
const getItemTopStyle_1 = require("../utils/getItemTopStyle");
|
|
27
26
|
const useStickyItemTop_1 = require("./items/useStickyItemTop");
|
|
28
27
|
const getAnchoredItemTop_1 = require("../utils/getAnchoredItemTop");
|
|
28
|
+
const useLayoutContext_1 = require("./useLayoutContext");
|
|
29
29
|
const itemsMap = {
|
|
30
30
|
[sdk_1.ArticleItemType.Rectangle]: RectangleItem_1.RectangleItem,
|
|
31
31
|
[sdk_1.ArticleItemType.Image]: ImageItem_1.ImageItem,
|
|
@@ -39,12 +39,12 @@ const noop = () => null;
|
|
|
39
39
|
const Item = ({ item, sectionId }) => {
|
|
40
40
|
const id = (0, react_1.useId)();
|
|
41
41
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
42
|
+
const layout = (0, useLayoutContext_1.useLayoutContext)();
|
|
42
43
|
const [wrapperHeight, setWrapperHeight] = (0, react_1.useState)(undefined);
|
|
43
44
|
const { scale, scaleAnchor } = (0, useItemScale_1.useItemScale)(item, sectionId);
|
|
44
45
|
const { top, left } = (0, useItemPosition_1.useItemPosition)(item, sectionId);
|
|
45
46
|
const sectionHeight = (0, useSectionHeightMap_1.useSectionHeightData)(sectionId);
|
|
46
47
|
const stickyTop = (0, useStickyItemTop_1.useStickyItemTop)(item, sectionHeight, sectionId);
|
|
47
|
-
const layout = (0, useCurrentLayout_1.useCurrentLayout)();
|
|
48
48
|
const { width, height } = (0, useItemDimensions_1.useItemDimensions)(item, sectionId);
|
|
49
49
|
const layoutValues = [item.area, item.hidden, item.state.hover];
|
|
50
50
|
const isInitialRef = (0, react_1.useRef)(true);
|
|
@@ -53,12 +53,14 @@ const Item = ({ item, sectionId }) => {
|
|
|
53
53
|
if (item.layoutParams) {
|
|
54
54
|
layoutValues.push(item.layoutParams);
|
|
55
55
|
}
|
|
56
|
-
const sizing = isItemType(item, sdk_1.ArticleItemType.RichText)
|
|
56
|
+
const sizing = layout && isItemType(item, sdk_1.ArticleItemType.RichText)
|
|
57
57
|
? item.layoutParams[layout].sizing
|
|
58
58
|
: undefined;
|
|
59
59
|
const sizingAxis = parseSizing(sizing);
|
|
60
60
|
const ItemComponent = itemsMap[item.type] || noop;
|
|
61
61
|
const handleItemResize = (height) => {
|
|
62
|
+
if (!layout)
|
|
63
|
+
return;
|
|
62
64
|
const sticky = item.sticky[layout];
|
|
63
65
|
if (!sticky) {
|
|
64
66
|
setWrapperHeight(undefined);
|
|
@@ -77,7 +79,7 @@ const Item = ({ item, sectionId }) => {
|
|
|
77
79
|
height: `${sizingAxis.y === sdk_1.ArticleItemSizingType.Manual ? `${height * 100}vw` : 'unset'}`,
|
|
78
80
|
top: stickyTop
|
|
79
81
|
};
|
|
80
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: `item-wrapper-${item.id}`, style: { top, left, ...(wrapperHeight ? { height: `${wrapperHeight * 100}vw` } : {}) }, children: [(0, jsx_runtime_1.jsx)("div", { suppressHydrationWarning: true, className: `item-${item.id}`, style: isInitialRef.current ? {} : styles, children: (0, jsx_runtime_1.jsx)(ItemComponent, { item: item, sectionId: sectionId, onResize: handleItemResize }) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
82
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: `item-wrapper-${item.id}`, style: isInitialRef.current ? {} : { top, left, ...(wrapperHeight ? { height: `${wrapperHeight * 100}vw` } : {}) }, children: [(0, jsx_runtime_1.jsx)("div", { suppressHydrationWarning: true, className: `item-${item.id}`, style: isInitialRef.current ? {} : styles, children: (0, jsx_runtime_1.jsx)(ItemComponent, { item: item, sectionId: sectionId, onResize: handleItemResize }) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
81
83
|
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, hidden, hoverParams, sticky, sectionHeight, layoutParams]) => {
|
|
82
84
|
const sizingAxis = parseSizing(layoutParams.sizing);
|
|
83
85
|
return (`
|
|
@@ -16,7 +16,7 @@ const HoverStyles_1 = require("../../utils/HoverStyles/HoverStyles");
|
|
|
16
16
|
const ImageItem = ({ item, sectionId }) => {
|
|
17
17
|
const id = (0, react_1.useId)();
|
|
18
18
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
19
|
-
const { radius, strokeWidth, opacity, strokeColor } = (0, useFileItem_1.useFileItem)(item, sectionId);
|
|
19
|
+
const { radius, strokeWidth, opacity, strokeColor, blur } = (0, useFileItem_1.useFileItem)(item, sectionId);
|
|
20
20
|
const angle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
|
|
21
21
|
const borderColor = (0, react_1.useMemo)(() => sdk_1.CntrlColor.parse(strokeColor), [strokeColor]);
|
|
22
22
|
return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { url: item.link?.url, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `image-wrapper-${item.id}`, style: {
|
|
@@ -24,7 +24,8 @@ const ImageItem = ({ item, sectionId }) => {
|
|
|
24
24
|
borderWidth: `${strokeWidth * 100}vw`,
|
|
25
25
|
opacity: `${opacity}`,
|
|
26
26
|
borderColor: `${borderColor.toCss()}`,
|
|
27
|
-
transform: `rotate(${angle}deg)
|
|
27
|
+
transform: `rotate(${angle}deg)`,
|
|
28
|
+
filter: `blur(${blur * 100}vw)`
|
|
28
29
|
}, children: (0, jsx_runtime_1.jsx)("img", { className: "image", src: item.commonParams.url }) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
29
30
|
@supports not (color: oklch(42% 0.3 90 / 1)) {
|
|
30
31
|
.image-wrapper-${item.id} {
|
|
@@ -50,10 +51,10 @@ const ImageItem = ({ item, sectionId }) => {
|
|
|
50
51
|
${(0, sdk_1.getLayoutStyles)(layouts, [item.state.hover], ([hoverParams]) => {
|
|
51
52
|
return (`
|
|
52
53
|
.image-wrapper-${item.id} {
|
|
53
|
-
transition: ${(0, HoverStyles_1.getTransitions)(['angle', 'strokeWidth', 'radius', 'strokeColor', 'opacity'], hoverParams)};
|
|
54
|
+
transition: ${(0, HoverStyles_1.getTransitions)(['angle', 'strokeWidth', 'radius', 'strokeColor', 'opacity', 'blur'], hoverParams)};
|
|
54
55
|
}
|
|
55
56
|
.image-wrapper-${item.id}:hover {
|
|
56
|
-
${(0, HoverStyles_1.getHoverStyles)(['angle', 'strokeWidth', 'radius', 'strokeColor', 'opacity'], hoverParams)}
|
|
57
|
+
${(0, HoverStyles_1.getHoverStyles)(['angle', 'strokeWidth', 'radius', 'strokeColor', 'opacity', 'blur'], hoverParams)}
|
|
57
58
|
}
|
|
58
59
|
`);
|
|
59
60
|
})}
|
|
@@ -16,7 +16,7 @@ const HoverStyles_1 = require("../../utils/HoverStyles/HoverStyles");
|
|
|
16
16
|
const RectangleItem = ({ item, sectionId }) => {
|
|
17
17
|
const id = (0, react_1.useId)();
|
|
18
18
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
19
|
-
const { fillColor, radius, strokeWidth, strokeColor } = (0, useRectangleItem_1.useRectangleItem)(item, sectionId);
|
|
19
|
+
const { fillColor, radius, strokeWidth, strokeColor, blur, backdropBlur } = (0, useRectangleItem_1.useRectangleItem)(item, sectionId);
|
|
20
20
|
const angle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
|
|
21
21
|
const backgroundColor = (0, react_1.useMemo)(() => sdk_1.CntrlColor.parse(fillColor), [fillColor]);
|
|
22
22
|
const borderColor = (0, react_1.useMemo)(() => sdk_1.CntrlColor.parse(strokeColor), [strokeColor]);
|
|
@@ -25,7 +25,9 @@ const RectangleItem = ({ item, sectionId }) => {
|
|
|
25
25
|
borderRadius: `${radius * 100}vw`,
|
|
26
26
|
borderWidth: `${strokeWidth * 100}vw`,
|
|
27
27
|
borderColor: `${borderColor.toCss()}`,
|
|
28
|
-
transform: `rotate(${angle}deg)
|
|
28
|
+
transform: `rotate(${angle}deg)`,
|
|
29
|
+
filter: blur !== 0 ? `blur(${blur * 100}vw)` : '',
|
|
30
|
+
backdropFilter: backdropBlur !== 0 ? `blur(${backdropBlur * 100}vw)` : ''
|
|
29
31
|
} }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
30
32
|
@supports not (color: oklch(42% 0.3 90 / 1)) {
|
|
31
33
|
.rectangle-${item.id} {
|
|
@@ -43,10 +45,10 @@ const RectangleItem = ({ item, sectionId }) => {
|
|
|
43
45
|
${(0, sdk_1.getLayoutStyles)(layouts, [item.state.hover], ([hoverParams]) => {
|
|
44
46
|
return (`
|
|
45
47
|
.rectangle-${item.id} {
|
|
46
|
-
transition: ${(0, HoverStyles_1.getTransitions)(['angle', 'fillColor', 'strokeWidth', 'radius', 'strokeColor'], hoverParams)};
|
|
48
|
+
transition: ${(0, HoverStyles_1.getTransitions)(['angle', 'fillColor', 'strokeWidth', 'radius', 'strokeColor', 'blur', 'backdropBlur'], hoverParams)};
|
|
47
49
|
}
|
|
48
50
|
.rectangle-${item.id}:hover {
|
|
49
|
-
${(0, HoverStyles_1.getHoverStyles)(['angle', 'fillColor', 'strokeWidth', 'radius', 'strokeColor'], hoverParams)}
|
|
51
|
+
${(0, HoverStyles_1.getHoverStyles)(['angle', 'fillColor', 'strokeWidth', 'radius', 'strokeColor', 'blur', 'backdropBlur'], hoverParams)}
|
|
50
52
|
}
|
|
51
53
|
`);
|
|
52
54
|
})}
|
|
@@ -9,16 +9,16 @@ const react_1 = require("react");
|
|
|
9
9
|
const sdk_1 = require("@cntrl-site/sdk");
|
|
10
10
|
const style_1 = __importDefault(require("styled-jsx/style"));
|
|
11
11
|
const useRichTextItem_1 = require("./useRichTextItem");
|
|
12
|
-
const useItemAngle_1 = require("../useItemAngle");
|
|
13
12
|
const useCntrlContext_1 = require("../../provider/useCntrlContext");
|
|
14
13
|
const HoverStyles_1 = require("../../utils/HoverStyles/HoverStyles");
|
|
14
|
+
const useRichTextItemValues_1 = require("./useRichTextItemValues");
|
|
15
15
|
const RichTextItem = ({ item, sectionId, onResize }) => {
|
|
16
16
|
const [content, styles, preset] = (0, useRichTextItem_1.useRichTextItem)(item);
|
|
17
17
|
const id = (0, react_1.useId)();
|
|
18
18
|
const [ref, setRef] = (0, react_1.useState)(null);
|
|
19
|
-
const angle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
|
|
20
19
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
21
20
|
const className = preset ? `cntrl-preset-${preset.id}` : undefined;
|
|
21
|
+
const { angle, blur } = (0, useRichTextItemValues_1.useRichTextItemValues)(item, sectionId);
|
|
22
22
|
(0, react_1.useEffect)(() => {
|
|
23
23
|
if (!ref || !onResize)
|
|
24
24
|
return;
|
|
@@ -32,14 +32,15 @@ const RichTextItem = ({ item, sectionId, onResize }) => {
|
|
|
32
32
|
};
|
|
33
33
|
}, [ref, onResize]);
|
|
34
34
|
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { ref: setRef, className: `${className} rich-text-wrapper-${item.id}`, style: {
|
|
35
|
-
transform: `rotate(${angle}deg)
|
|
35
|
+
transform: `rotate(${angle}deg)`,
|
|
36
|
+
filter: `blur(${blur * 100}vw)`
|
|
36
37
|
}, children: content }), (0, jsx_runtime_1.jsxs)(style_1.default, { id: id, children: [styles, `${(0, sdk_1.getLayoutStyles)(layouts, [item.state.hover], ([hoverParams]) => {
|
|
37
38
|
return (`
|
|
38
39
|
.rich-text-wrapper-${item.id} {
|
|
39
|
-
transition: ${(0, HoverStyles_1.getTransitions)(['angle'], hoverParams)};
|
|
40
|
+
transition: ${(0, HoverStyles_1.getTransitions)(['angle', 'blur'], hoverParams)};
|
|
40
41
|
}
|
|
41
42
|
.rich-text-wrapper-${item.id}:hover {
|
|
42
|
-
${(0, HoverStyles_1.getHoverStyles)(['angle'], hoverParams)}
|
|
43
|
+
${(0, HoverStyles_1.getHoverStyles)(['angle', 'blur'], hoverParams)}
|
|
43
44
|
}
|
|
44
45
|
`);
|
|
45
46
|
})}`] })] }));
|
|
@@ -16,7 +16,7 @@ const HoverStyles_1 = require("../../utils/HoverStyles/HoverStyles");
|
|
|
16
16
|
const VideoItem = ({ item, sectionId }) => {
|
|
17
17
|
const id = (0, react_1.useId)();
|
|
18
18
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
19
|
-
const { radius, strokeWidth, strokeColor, opacity } = (0, useFileItem_1.useFileItem)(item, sectionId);
|
|
19
|
+
const { radius, strokeWidth, strokeColor, opacity, blur } = (0, useFileItem_1.useFileItem)(item, sectionId);
|
|
20
20
|
const angle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
|
|
21
21
|
const borderColor = (0, react_1.useMemo)(() => sdk_1.CntrlColor.parse(strokeColor), [strokeColor]);
|
|
22
22
|
return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, { url: item.link?.url, children: [(0, jsx_runtime_1.jsx)("div", { className: `video-wrapper-${item.id}`, style: {
|
|
@@ -24,7 +24,8 @@ const VideoItem = ({ item, sectionId }) => {
|
|
|
24
24
|
borderWidth: `${strokeWidth * 100}vw`,
|
|
25
25
|
opacity: `${opacity}`,
|
|
26
26
|
borderColor: `${borderColor.toCss()}`,
|
|
27
|
-
transform: `rotate(${angle}deg)
|
|
27
|
+
transform: `rotate(${angle}deg)`,
|
|
28
|
+
filter: `blur(${blur * 100}vw)`
|
|
28
29
|
}, children: (0, jsx_runtime_1.jsx)("video", { autoPlay: true, muted: true, loop: true, playsInline: true, className: "video", children: (0, jsx_runtime_1.jsx)("source", { src: item.commonParams.url }) }) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
29
30
|
@supports not (color: oklch(42% 0.3 90 / 1)) {
|
|
30
31
|
.video-wrapper-${item.id} {
|
|
@@ -51,10 +52,10 @@ const VideoItem = ({ item, sectionId }) => {
|
|
|
51
52
|
${(0, sdk_1.getLayoutStyles)(layouts, [item.state.hover], ([hoverParams]) => {
|
|
52
53
|
return (`
|
|
53
54
|
.video-wrapper-${item.id} {
|
|
54
|
-
transition: ${(0, HoverStyles_1.getTransitions)(['angle', 'strokeWidth', 'radius', 'strokeColor', 'opacity'], hoverParams)};
|
|
55
|
+
transition: ${(0, HoverStyles_1.getTransitions)(['angle', 'strokeWidth', 'radius', 'strokeColor', 'opacity', 'blur'], hoverParams)};
|
|
55
56
|
}
|
|
56
57
|
.video-wrapper-${item.id}:hover {
|
|
57
|
-
${(0, HoverStyles_1.getHoverStyles)(['angle', 'strokeWidth', 'radius', 'strokeColor', 'opacity'], hoverParams)}
|
|
58
|
+
${(0, HoverStyles_1.getHoverStyles)(['angle', 'strokeWidth', 'radius', 'strokeColor', 'opacity', 'blur'], hoverParams)}
|
|
58
59
|
}
|
|
59
60
|
`);
|
|
60
61
|
})}
|
|
@@ -17,7 +17,7 @@ const HoverStyles_1 = require("../../utils/HoverStyles/HoverStyles");
|
|
|
17
17
|
const VimeoEmbedItem = ({ item, sectionId }) => {
|
|
18
18
|
const id = (0, react_1.useId)();
|
|
19
19
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
20
|
-
const { radius } = (0, useEmbedVideoItem_1.useEmbedVideoItem)(item, sectionId);
|
|
20
|
+
const { radius, blur } = (0, useEmbedVideoItem_1.useEmbedVideoItem)(item, sectionId);
|
|
21
21
|
const [iframeRef, setIframeRef] = (0, react_1.useState)(null);
|
|
22
22
|
const vimeoPlayer = (0, react_1.useMemo)(() => iframeRef ? new player_1.default(iframeRef) : undefined, [iframeRef]);
|
|
23
23
|
const angle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
|
|
@@ -38,7 +38,8 @@ const VimeoEmbedItem = ({ item, sectionId }) => {
|
|
|
38
38
|
const validUrl = getValidVimeoUrl(url);
|
|
39
39
|
return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, { url: item.link?.url, children: [(0, jsx_runtime_1.jsx)("div", { className: `embed-video-wrapper-${item.id}`, style: {
|
|
40
40
|
borderRadius: `${radius * 100}vw`,
|
|
41
|
-
transform: `rotate(${angle}deg)
|
|
41
|
+
transform: `rotate(${angle}deg)`,
|
|
42
|
+
filter: `blur(${blur * 100}vw)`
|
|
42
43
|
}, onMouseEnter: () => {
|
|
43
44
|
if (!vimeoPlayer || play !== 'on-hover')
|
|
44
45
|
return;
|
|
@@ -63,10 +64,10 @@ const VimeoEmbedItem = ({ item, sectionId }) => {
|
|
|
63
64
|
${(0, sdk_1.getLayoutStyles)(layouts, [item.state.hover], ([hoverParams]) => {
|
|
64
65
|
return (`
|
|
65
66
|
.embed-video-wrapper-${item.id} {
|
|
66
|
-
transition: ${(0, HoverStyles_1.getTransitions)(['angle', 'radius'], hoverParams)};
|
|
67
|
+
transition: ${(0, HoverStyles_1.getTransitions)(['angle', 'radius', 'blur'], hoverParams)};
|
|
67
68
|
}
|
|
68
69
|
.embed-video-wrapper-${item.id}:hover {
|
|
69
|
-
${(0, HoverStyles_1.getHoverStyles)(['angle', 'radius'], hoverParams)}
|
|
70
|
+
${(0, HoverStyles_1.getHoverStyles)(['angle', 'radius', 'blur'], hoverParams)}
|
|
70
71
|
}
|
|
71
72
|
`);
|
|
72
73
|
})}
|
|
@@ -19,7 +19,7 @@ const YoutubeEmbedItem = ({ item, sectionId }) => {
|
|
|
19
19
|
const id = (0, react_1.useId)();
|
|
20
20
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
21
21
|
const { play, controls, url } = item.commonParams;
|
|
22
|
-
const { radius } = (0, useEmbedVideoItem_1.useEmbedVideoItem)(item, sectionId);
|
|
22
|
+
const { radius, blur } = (0, useEmbedVideoItem_1.useEmbedVideoItem)(item, sectionId);
|
|
23
23
|
const angle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
|
|
24
24
|
const YT = (0, useYouTubeIframeApi_1.useYouTubeIframeApi)();
|
|
25
25
|
const [div, setDiv] = (0, react_1.useState)(null);
|
|
@@ -63,7 +63,8 @@ const YoutubeEmbedItem = ({ item, sectionId }) => {
|
|
|
63
63
|
player.pauseVideo();
|
|
64
64
|
}, ref: setDiv, style: {
|
|
65
65
|
borderRadius: `${radius * 100}vw`,
|
|
66
|
-
transform: `rotate(${angle}deg)
|
|
66
|
+
transform: `rotate(${angle}deg)`,
|
|
67
|
+
filter: `blur(${blur * 100}vw)`
|
|
67
68
|
} }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
68
69
|
.embed-youtube-video-wrapper-${item.id} {
|
|
69
70
|
position: absolute;
|
|
@@ -80,10 +81,10 @@ const YoutubeEmbedItem = ({ item, sectionId }) => {
|
|
|
80
81
|
${(0, sdk_1.getLayoutStyles)(layouts, [item.state.hover], ([hoverParams]) => {
|
|
81
82
|
return (`
|
|
82
83
|
.embed-youtube-video-wrapper-${item.id} {
|
|
83
|
-
transition: ${(0, HoverStyles_1.getTransitions)(['angle', 'radius'], hoverParams)};
|
|
84
|
+
transition: ${(0, HoverStyles_1.getTransitions)(['angle', 'radius', 'blur'], hoverParams)};
|
|
84
85
|
}
|
|
85
86
|
.embed-youtube-video-wrapper-${item.id}:hover {
|
|
86
|
-
${(0, HoverStyles_1.getHoverStyles)(['angle', 'radius'], hoverParams)}
|
|
87
|
+
${(0, HoverStyles_1.getHoverStyles)(['angle', 'radius', 'blur'], hoverParams)}
|
|
87
88
|
}
|
|
88
89
|
`);
|
|
89
90
|
})}
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useEmbedVideoItem = void 0;
|
|
4
|
-
const useCurrentLayout_1 = require("../../common/useCurrentLayout");
|
|
5
4
|
const useKeyframeValue_1 = require("../../common/useKeyframeValue");
|
|
5
|
+
const useLayoutContext_1 = require("../useLayoutContext");
|
|
6
6
|
const useEmbedVideoItem = (item, sectionId) => {
|
|
7
|
-
const layoutId = (0,
|
|
7
|
+
const layoutId = (0, useLayoutContext_1.useLayoutContext)();
|
|
8
8
|
const radius = (0, useKeyframeValue_1.useKeyframeValue)(item, (item, layoutId) => {
|
|
9
9
|
if (!layoutId)
|
|
10
10
|
return 0;
|
|
11
11
|
const layoutParams = item.layoutParams[layoutId];
|
|
12
12
|
return 'radius' in layoutParams ? layoutParams.radius : 0;
|
|
13
13
|
}, (animator, scroll, value) => animator.getRadius({ radius: value }, scroll).radius, sectionId, [layoutId]);
|
|
14
|
-
|
|
14
|
+
const blur = (0, useKeyframeValue_1.useKeyframeValue)(item, (item, layoutId) => {
|
|
15
|
+
if (!layoutId)
|
|
16
|
+
return 0;
|
|
17
|
+
const layoutParams = item.layoutParams[layoutId];
|
|
18
|
+
return 'blur' in layoutParams ? layoutParams.blur : 0;
|
|
19
|
+
}, (animator, scroll, value) => animator.getBlur({ blur: value }, scroll).blur, sectionId, [layoutId]);
|
|
20
|
+
return { radius, blur };
|
|
15
21
|
};
|
|
16
22
|
exports.useEmbedVideoItem = useEmbedVideoItem;
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useFileItem = void 0;
|
|
4
4
|
const useKeyframeValue_1 = require("../../common/useKeyframeValue");
|
|
5
|
-
const
|
|
5
|
+
const useLayoutContext_1 = require("../useLayoutContext");
|
|
6
6
|
const defaultColor = 'rgba(0, 0, 0, 1)';
|
|
7
7
|
const useFileItem = (item, sectionId) => {
|
|
8
|
-
const layoutId = (0,
|
|
8
|
+
const layoutId = (0, useLayoutContext_1.useLayoutContext)();
|
|
9
9
|
const radius = (0, useKeyframeValue_1.useKeyframeValue)(item, (item, layoutId) => {
|
|
10
10
|
if (!layoutId)
|
|
11
11
|
return 0;
|
|
@@ -30,6 +30,12 @@ const useFileItem = (item, sectionId) => {
|
|
|
30
30
|
const layoutParams = item.layoutParams[layoutId];
|
|
31
31
|
return 'strokeColor' in layoutParams ? layoutParams.strokeColor : defaultColor;
|
|
32
32
|
}, (animator, scroll, value) => animator.getBorderColor({ color: value }, scroll).color, sectionId);
|
|
33
|
-
|
|
33
|
+
const blur = (0, useKeyframeValue_1.useKeyframeValue)(item, (item, layoutId) => {
|
|
34
|
+
if (!layoutId)
|
|
35
|
+
return 0;
|
|
36
|
+
const layoutParams = item.layoutParams[layoutId];
|
|
37
|
+
return 'blur' in layoutParams ? layoutParams.blur : 0;
|
|
38
|
+
}, (animator, scroll, value) => animator.getBlur({ blur: value }, scroll).blur, sectionId);
|
|
39
|
+
return { radius, strokeWidth, opacity, strokeColor, blur };
|
|
34
40
|
};
|
|
35
41
|
exports.useFileItem = useFileItem;
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useRectangleItem = void 0;
|
|
4
4
|
const useKeyframeValue_1 = require("../../common/useKeyframeValue");
|
|
5
|
-
const
|
|
5
|
+
const useLayoutContext_1 = require("../useLayoutContext");
|
|
6
6
|
const defaultColor = 'rgba(0, 0, 0, 1)';
|
|
7
7
|
const useRectangleItem = (item, sectionId) => {
|
|
8
|
-
const layoutId = (0,
|
|
8
|
+
const layoutId = (0, useLayoutContext_1.useLayoutContext)();
|
|
9
9
|
const radius = (0, useKeyframeValue_1.useKeyframeValue)(item, (item, layoutId) => {
|
|
10
10
|
if (!layoutId)
|
|
11
11
|
return 0;
|
|
@@ -30,6 +30,18 @@ const useRectangleItem = (item, sectionId) => {
|
|
|
30
30
|
const layoutParams = item.layoutParams[layoutId];
|
|
31
31
|
return 'strokeColor' in layoutParams ? layoutParams.strokeColor : defaultColor;
|
|
32
32
|
}, (animator, scroll, value) => animator.getBorderColor({ color: value }, scroll).color, sectionId, [layoutId]);
|
|
33
|
-
|
|
33
|
+
const blur = (0, useKeyframeValue_1.useKeyframeValue)(item, (item, layoutId) => {
|
|
34
|
+
if (!layoutId)
|
|
35
|
+
return 0;
|
|
36
|
+
const layoutParams = item.layoutParams[layoutId];
|
|
37
|
+
return 'blur' in layoutParams ? layoutParams.blur : 0;
|
|
38
|
+
}, (animator, scroll, value) => animator.getBlur({ blur: value }, scroll).blur, sectionId, [layoutId]);
|
|
39
|
+
const backdropBlur = (0, useKeyframeValue_1.useKeyframeValue)(item, (item, layoutId) => {
|
|
40
|
+
if (!layoutId)
|
|
41
|
+
return 0;
|
|
42
|
+
const layoutParams = item.layoutParams[layoutId];
|
|
43
|
+
return 'backdropBlur' in layoutParams ? layoutParams.backdropBlur : 0;
|
|
44
|
+
}, (animator, scroll, value) => animator.getBackdropBlur({ backdropBlur: value }, scroll).backdropBlur, sectionId, [layoutId]);
|
|
45
|
+
return { fillColor, strokeWidth, radius, strokeColor, blur, backdropBlur };
|
|
34
46
|
};
|
|
35
47
|
exports.useRectangleItem = useRectangleItem;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useRichTextItem = void 0;
|
|
4
|
-
const useCurrentLayout_1 = require("../../common/useCurrentLayout");
|
|
5
4
|
const RichTextConverter_1 = require("../../utils/RichTextConverter/RichTextConverter");
|
|
6
5
|
const useCntrlContext_1 = require("../../provider/useCntrlContext");
|
|
6
|
+
const useLayoutContext_1 = require("../useLayoutContext");
|
|
7
7
|
const richTextConv = new RichTextConverter_1.RichTextConverter();
|
|
8
8
|
const useRichTextItem = (item) => {
|
|
9
|
-
const layoutId = (0,
|
|
9
|
+
const layoutId = (0, useLayoutContext_1.useLayoutContext)();
|
|
10
10
|
const { layouts, typePresets } = (0, useCntrlContext_1.useCntrlContext)();
|
|
11
|
-
const presetId = item.layoutParams[layoutId].preset;
|
|
11
|
+
const presetId = layoutId ? item.layoutParams[layoutId].preset : null;
|
|
12
12
|
const preset = presetId
|
|
13
13
|
? typePresets?.presets.find(p => p.id === presetId) ?? null
|
|
14
14
|
: null;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useRichTextItemValues = void 0;
|
|
4
|
+
const useKeyframeValue_1 = require("../../common/useKeyframeValue");
|
|
5
|
+
const useLayoutContext_1 = require("../useLayoutContext");
|
|
6
|
+
const useRichTextItemValues = (item, sectionId) => {
|
|
7
|
+
const layoutId = (0, useLayoutContext_1.useLayoutContext)();
|
|
8
|
+
const angle = (0, useKeyframeValue_1.useKeyframeValue)(item, (item, layoutId) => ({ angle: layoutId ? item.area[layoutId].angle : 0 }), (animator, scroll, value) => animator.getRotation(value, scroll), sectionId);
|
|
9
|
+
const blur = (0, useKeyframeValue_1.useKeyframeValue)(item, (item, layoutId) => {
|
|
10
|
+
if (!layoutId)
|
|
11
|
+
return 0;
|
|
12
|
+
const layoutParams = item.layoutParams[layoutId];
|
|
13
|
+
return 'blur' in layoutParams ? layoutParams.blur : 0;
|
|
14
|
+
}, (animator, scroll, value) => animator.getBlur({ blur: value }, scroll).blur, sectionId, [layoutId]);
|
|
15
|
+
return { angle, blur };
|
|
16
|
+
};
|
|
17
|
+
exports.useRichTextItemValues = useRichTextItemValues;
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useStickyItemTop = void 0;
|
|
4
|
-
const
|
|
4
|
+
const sdk_1 = require("@cntrl-site/sdk");
|
|
5
5
|
const useKeyframeValue_1 = require("../../common/useKeyframeValue");
|
|
6
6
|
const getAnchoredItemTop_1 = require("../../utils/getAnchoredItemTop");
|
|
7
|
+
const useLayoutContext_1 = require("../useLayoutContext");
|
|
7
8
|
function useStickyItemTop(item, sectionHeightMap, sectionId) {
|
|
8
|
-
const layoutId = (0,
|
|
9
|
-
const { top } = (0, useKeyframeValue_1.useKeyframeValue)(item, (item, layoutId) =>
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
const layoutId = (0, useLayoutContext_1.useLayoutContext)();
|
|
10
|
+
const { top } = (0, useKeyframeValue_1.useKeyframeValue)(item, (item, layoutId) => {
|
|
11
|
+
if (!layoutId)
|
|
12
|
+
return { top: 0, left: 0 };
|
|
13
|
+
return item.area[layoutId];
|
|
14
|
+
}, (animator, scroll, value) => animator.getPositions(value, scroll), sectionId, [layoutId]);
|
|
15
|
+
const sticky = layoutId ? item.sticky[layoutId] : undefined;
|
|
16
|
+
const sectionHeight = layoutId ? sectionHeightMap[layoutId] : '0vh';
|
|
17
|
+
const anchorSide = layoutId ? item.area[layoutId].anchorSide : sdk_1.AnchorSide.Top;
|
|
18
|
+
return sticky ? `${(0, getAnchoredItemTop_1.getAnchoredItemTop)(top - sticky.from, sectionHeight, anchorSide)}` : 0;
|
|
13
19
|
}
|
|
14
20
|
exports.useStickyItemTop = useStickyItemTop;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useItemDimensions = void 0;
|
|
4
|
-
const useCurrentLayout_1 = require("../common/useCurrentLayout");
|
|
5
4
|
const useKeyframeValue_1 = require("../common/useKeyframeValue");
|
|
5
|
+
const useLayoutContext_1 = require("./useLayoutContext");
|
|
6
6
|
const defaultArea = {
|
|
7
7
|
left: 0,
|
|
8
8
|
top: 0,
|
|
@@ -12,7 +12,7 @@ const defaultArea = {
|
|
|
12
12
|
zIndex: 0
|
|
13
13
|
};
|
|
14
14
|
const useItemDimensions = (item, sectionId) => {
|
|
15
|
-
const layoutId = (0,
|
|
15
|
+
const layoutId = (0, useLayoutContext_1.useLayoutContext)();
|
|
16
16
|
const { width, height } = (0, useKeyframeValue_1.useKeyframeValue)(item, (item, layoutId) => layoutId ? item.area[layoutId] : defaultArea, (animator, scroll, value) => animator.getDimensions(value, scroll), sectionId, [layoutId]);
|
|
17
17
|
return { width, height };
|
|
18
18
|
};
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useItemPosition = void 0;
|
|
4
|
+
const sdk_1 = require("@cntrl-site/sdk");
|
|
4
5
|
const useKeyframeValue_1 = require("../common/useKeyframeValue");
|
|
5
|
-
const useCurrentLayout_1 = require("../common/useCurrentLayout");
|
|
6
6
|
const getItemTopStyle_1 = require("../utils/getItemTopStyle");
|
|
7
|
+
const useLayoutContext_1 = require("./useLayoutContext");
|
|
7
8
|
const useItemPosition = (item, sectionId) => {
|
|
8
|
-
const layoutId = (0,
|
|
9
|
-
const { top, left } = (0, useKeyframeValue_1.useKeyframeValue)(item, (item, layoutId) =>
|
|
9
|
+
const layoutId = (0, useLayoutContext_1.useLayoutContext)();
|
|
10
|
+
const { top, left } = (0, useKeyframeValue_1.useKeyframeValue)(item, (item, layoutId) => {
|
|
11
|
+
if (!layoutId)
|
|
12
|
+
return { top: 0, left: -10 };
|
|
13
|
+
return item.area[layoutId];
|
|
14
|
+
}, (animator, scroll, value) => animator.getPositions(value, scroll), sectionId, [layoutId]);
|
|
15
|
+
const anchorSide = layoutId ? item.area[layoutId].anchorSide : sdk_1.AnchorSide.Top;
|
|
10
16
|
return {
|
|
11
|
-
top: (0, getItemTopStyle_1.getItemTopStyle)(top,
|
|
17
|
+
top: (0, getItemTopStyle_1.getItemTopStyle)(top, anchorSide),
|
|
12
18
|
left: `${left * 100}vw`
|
|
13
19
|
};
|
|
14
20
|
};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useItemScale = void 0;
|
|
4
|
+
const sdk_1 = require("@cntrl-site/sdk");
|
|
4
5
|
const useKeyframeValue_1 = require("../common/useKeyframeValue");
|
|
5
|
-
const
|
|
6
|
+
const useLayoutContext_1 = require("./useLayoutContext");
|
|
6
7
|
const useItemScale = (item, sectionId) => {
|
|
7
|
-
const
|
|
8
|
-
const { scale } = (0, useKeyframeValue_1.useKeyframeValue)(item, (item, layoutId) => ({ scale: layoutId ? item.area[layoutId].scale : 1 }), (animator, scroll, value) => animator.getScale(value, scroll), sectionId);
|
|
9
|
-
const scaleAnchor = item.area[
|
|
8
|
+
const layoutId = (0, useLayoutContext_1.useLayoutContext)();
|
|
9
|
+
const { scale } = (0, useKeyframeValue_1.useKeyframeValue)(item, (item, layoutId) => ({ scale: layoutId ? item.area[layoutId].scale : 1 }), (animator, scroll, value) => animator.getScale(value, scroll), sectionId, [layoutId]);
|
|
10
|
+
const scaleAnchor = layoutId ? item.area[layoutId].scaleAnchor : sdk_1.ScaleAnchor.MiddleCenter;
|
|
10
11
|
return { scale, scaleAnchor };
|
|
11
12
|
};
|
|
12
13
|
exports.useItemScale = useItemScale;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useLayoutContext = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const LayoutContext_1 = require("../provider/LayoutContext");
|
|
6
|
+
function useLayoutContext() {
|
|
7
|
+
const layoutId = (0, react_1.useContext)(LayoutContext_1.LayoutContext);
|
|
8
|
+
return layoutId;
|
|
9
|
+
}
|
|
10
|
+
exports.useLayoutContext = useLayoutContext;
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useSectionColor = void 0;
|
|
4
|
-
const useCurrentLayout_1 = require("../common/useCurrentLayout");
|
|
5
4
|
const react_1 = require("react");
|
|
6
5
|
const sdk_1 = require("@cntrl-site/sdk");
|
|
6
|
+
const useLayoutContext_1 = require("./useLayoutContext");
|
|
7
7
|
const DEFAULT_COLOR = 'rgba(0, 0, 0, 0)';
|
|
8
8
|
const useSectionColor = (colorData) => {
|
|
9
|
-
const layoutId = (0,
|
|
9
|
+
const layoutId = (0, useLayoutContext_1.useLayoutContext)();
|
|
10
10
|
return (0, react_1.useMemo)(() => {
|
|
11
|
+
if (!layoutId)
|
|
12
|
+
return sdk_1.CntrlColor.parse(DEFAULT_COLOR);
|
|
11
13
|
const layoutColor = colorData[layoutId];
|
|
12
14
|
return sdk_1.CntrlColor.parse(!layoutColor
|
|
13
15
|
? DEFAULT_COLOR
|
|
14
16
|
: layoutColor);
|
|
15
|
-
}, []);
|
|
17
|
+
}, [layoutId]);
|
|
16
18
|
};
|
|
17
19
|
exports.useSectionColor = useSectionColor;
|