@cntrl-site/sdk-nextjs 0.8.10 → 0.8.11
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/inspectionProfiles/Project_Default.xml +15 -0
- package/cntrl-site-sdk-nextjs-0.8.11.tgz +0 -0
- package/lib/components/Article.js +6 -1
- package/lib/components/Item.js +6 -1
- package/lib/components/LayoutStyle.js +0 -1
- package/lib/components/Section.js +7 -1
- package/lib/components/items/ImageItem.js +6 -1
- package/lib/components/items/RectangleItem.js +6 -1
- package/lib/components/items/RichTextItem.js +0 -1
- package/lib/components/items/VideoItem.js +6 -1
- package/lib/components/items/VimeoEmbed.js +7 -1
- package/lib/components/items/YoutubeEmbed.js +7 -1
- package/package.json +2 -2
- package/src/components/Article.tsx +5 -3
- package/src/components/Item.tsx +5 -3
- package/src/components/LayoutStyle.tsx +0 -1
- package/src/components/Section.tsx +5 -3
- package/src/components/items/ImageItem.tsx +5 -3
- package/src/components/items/RectangleItem.tsx +5 -3
- package/src/components/items/RichTextItem.tsx +0 -1
- package/src/components/items/VideoItem.tsx +5 -3
- package/src/components/items/VimeoEmbed.tsx +5 -3
- package/src/components/items/YoutubeEmbed.tsx +5 -3
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/cntrl-site-sdk-nextjs-0.8.10.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>
|
|
Binary file
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.Article = void 0;
|
|
4
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
8
|
const react_1 = require("react");
|
|
9
|
+
const style_1 = __importDefault(require("styled-jsx/style"));
|
|
6
10
|
const Section_1 = require("./Section");
|
|
7
11
|
const Item_1 = require("./Item");
|
|
8
12
|
const useArticleRectObserver_1 = require("../utils/ArticleRectManager/useArticleRectObserver");
|
|
@@ -10,7 +14,8 @@ const ArticleRectContext_1 = require("../provider/ArticleRectContext");
|
|
|
10
14
|
const Article = ({ article }) => {
|
|
11
15
|
const articleRef = (0, react_1.useRef)(null);
|
|
12
16
|
const articleRectObserver = (0, useArticleRectObserver_1.useArticleRectObserver)(articleRef.current);
|
|
13
|
-
|
|
17
|
+
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) => ((0, jsx_runtime_1.jsx)(Section_1.Section, { section: section, children: article.sections[i].items.map(item => ((0, jsx_runtime_1.jsx)(Item_1.Item, { item: item }, item.id))) }, section.id))) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
14
19
|
.article {
|
|
15
20
|
position: relative;
|
|
16
21
|
overflow: clip;
|
package/lib/components/Item.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.isItemType = exports.Item = void 0;
|
|
4
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
8
|
const react_1 = require("react");
|
|
9
|
+
const style_1 = __importDefault(require("styled-jsx/style"));
|
|
6
10
|
const sdk_1 = require("@cntrl-site/sdk");
|
|
7
11
|
const RectangleItem_1 = require("./items/RectangleItem");
|
|
8
12
|
const ImageItem_1 = require("./items/ImageItem");
|
|
@@ -30,6 +34,7 @@ const itemsMap = {
|
|
|
30
34
|
};
|
|
31
35
|
const noop = () => null;
|
|
32
36
|
const Item = ({ item }) => {
|
|
37
|
+
const id = (0, react_1.useId)();
|
|
33
38
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
34
39
|
const { scale, scaleAnchor } = (0, useItemScale_1.useItemScale)(item);
|
|
35
40
|
const position = (0, useItemPosition_1.useItemPosition)(item);
|
|
@@ -65,7 +70,7 @@ const Item = ({ item }) => {
|
|
|
65
70
|
height: `${sizingAxis.y === sdk_1.ArticleItemSizingType.Manual ? `${height * 100}vw` : 'unset'}`,
|
|
66
71
|
top
|
|
67
72
|
};
|
|
68
|
-
return ((0, jsx_runtime_1.jsxs)("div", { suppressHydrationWarning: true, className: `item-${item.id}`, ref: setRef, style: isInitialRef.current ? {} : { ...styles, position: isFixed ? 'fixed' : 'absolute' }, children: [(0, jsx_runtime_1.jsx)(ItemComponent, { item: item }), (0, jsx_runtime_1.jsx)(
|
|
73
|
+
return ((0, jsx_runtime_1.jsxs)("div", { suppressHydrationWarning: true, className: `item-${item.id}`, ref: setRef, style: isInitialRef.current ? {} : { ...styles, position: isFixed ? 'fixed' : 'absolute' }, children: [(0, jsx_runtime_1.jsx)(ItemComponent, { item: item }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
69
74
|
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams]) => {
|
|
70
75
|
const sizingAxis = parseSizing(layoutParams.sizing);
|
|
71
76
|
return (`
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.LayoutStyle = void 0;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const sdk_1 = require("@cntrl-site/sdk");
|
|
9
|
-
// @ts-ignore
|
|
10
9
|
const style_1 = __importDefault(require("styled-jsx/style"));
|
|
11
10
|
const LayoutStyle = ({ id, layouts, layoutId, children }) => {
|
|
12
11
|
const layout = layouts.find(l => l.id === layoutId);
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.Section = void 0;
|
|
4
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const style_1 = __importDefault(require("styled-jsx/style"));
|
|
5
10
|
const sdk_1 = require("@cntrl-site/sdk");
|
|
6
11
|
const useCntrlContext_1 = require("../provider/useCntrlContext");
|
|
7
12
|
const useSectionColor_1 = require("./useSectionColor");
|
|
8
13
|
const Section = ({ section, children }) => {
|
|
14
|
+
const id = (0, react_1.useId)();
|
|
9
15
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
10
16
|
const backgroundColor = (0, useSectionColor_1.useSectionColor)(section.color);
|
|
11
17
|
const getSectionVisibilityStyles = () => {
|
|
@@ -24,7 +30,7 @@ const Section = ({ section, children }) => {
|
|
|
24
30
|
};
|
|
25
31
|
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `section-${section.id}`, id: section.name, style: {
|
|
26
32
|
backgroundColor: backgroundColor
|
|
27
|
-
}, children: children }), (0, jsx_runtime_1.jsx)(
|
|
33
|
+
}, children: children }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
28
34
|
${(0, sdk_1.getLayoutStyles)(layouts, [section.height], ([height]) => (`
|
|
29
35
|
.section-${section.id} {
|
|
30
36
|
height: ${getSectionHeight(height)};
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.ImageItem = void 0;
|
|
4
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
8
|
const react_1 = require("react");
|
|
9
|
+
const style_1 = __importDefault(require("styled-jsx/style"));
|
|
6
10
|
const sdk_1 = require("@cntrl-site/sdk");
|
|
7
11
|
const LinkWrapper_1 = require("../LinkWrapper");
|
|
8
12
|
const useFileItem_1 = require("./useFileItem");
|
|
9
13
|
const useItemAngle_1 = require("../useItemAngle");
|
|
10
14
|
const ImageItem = ({ item }) => {
|
|
15
|
+
const id = (0, react_1.useId)();
|
|
11
16
|
const { radius, strokeWidth, opacity, strokeColor } = (0, useFileItem_1.useFileItem)(item);
|
|
12
17
|
const angle = (0, useItemAngle_1.useItemAngle)(item);
|
|
13
18
|
const borderColor = (0, react_1.useMemo)(() => sdk_1.CntrlColor.parse(strokeColor).toCss(), [strokeColor]);
|
|
@@ -17,7 +22,7 @@ const ImageItem = ({ item }) => {
|
|
|
17
22
|
opacity: `${opacity}`,
|
|
18
23
|
borderColor: `${borderColor}`,
|
|
19
24
|
transform: `rotate(${angle}deg)`
|
|
20
|
-
}, children: (0, jsx_runtime_1.jsx)("img", { className: "image", src: item.commonParams.url }) }), (0, jsx_runtime_1.jsx)(
|
|
25
|
+
}, children: (0, jsx_runtime_1.jsx)("img", { className: "image", src: item.commonParams.url }) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
21
26
|
.image-wrapper-${item.id} {
|
|
22
27
|
position: absolute;
|
|
23
28
|
overflow: hidden;
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.RectangleItem = void 0;
|
|
4
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
8
|
const react_1 = require("react");
|
|
9
|
+
const style_1 = __importDefault(require("styled-jsx/style"));
|
|
6
10
|
const sdk_1 = require("@cntrl-site/sdk");
|
|
7
11
|
const LinkWrapper_1 = require("../LinkWrapper");
|
|
8
12
|
const useRectangleItem_1 = require("./useRectangleItem");
|
|
9
13
|
const useItemAngle_1 = require("../useItemAngle");
|
|
10
14
|
const RectangleItem = ({ item }) => {
|
|
15
|
+
const id = (0, react_1.useId)();
|
|
11
16
|
const { fillColor, radius, strokeWidth, strokeColor } = (0, useRectangleItem_1.useRectangleItem)(item);
|
|
12
17
|
const angle = (0, useItemAngle_1.useItemAngle)(item);
|
|
13
18
|
const backgroundColor = (0, react_1.useMemo)(() => sdk_1.CntrlColor.parse(fillColor).toCss(), [fillColor]);
|
|
@@ -18,7 +23,7 @@ const RectangleItem = ({ item }) => {
|
|
|
18
23
|
borderWidth: `${strokeWidth * 100}vw`,
|
|
19
24
|
borderColor: `${borderColor}`,
|
|
20
25
|
transform: `rotate(${angle}deg)`
|
|
21
|
-
} }), (0, jsx_runtime_1.jsx)(
|
|
26
|
+
} }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
22
27
|
.rectangle-${item.id} {
|
|
23
28
|
position: absolute;
|
|
24
29
|
width: 100%;
|
|
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.RichTextItem = void 0;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
-
//@ts-ignore
|
|
9
8
|
const style_1 = __importDefault(require("styled-jsx/style"));
|
|
10
9
|
const useRichTextItem_1 = require("./useRichTextItem");
|
|
11
10
|
const useItemAngle_1 = require("../useItemAngle");
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.VideoItem = void 0;
|
|
4
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
8
|
const react_1 = require("react");
|
|
9
|
+
const style_1 = __importDefault(require("styled-jsx/style"));
|
|
6
10
|
const sdk_1 = require("@cntrl-site/sdk");
|
|
7
11
|
const LinkWrapper_1 = require("../LinkWrapper");
|
|
8
12
|
const useFileItem_1 = require("./useFileItem");
|
|
9
13
|
const useItemAngle_1 = require("../useItemAngle");
|
|
10
14
|
const VideoItem = ({ item }) => {
|
|
15
|
+
const id = (0, react_1.useId)();
|
|
11
16
|
const { radius, strokeWidth, strokeColor, opacity } = (0, useFileItem_1.useFileItem)(item);
|
|
12
17
|
const angle = (0, useItemAngle_1.useItemAngle)(item);
|
|
13
18
|
const borderColor = (0, react_1.useMemo)(() => sdk_1.CntrlColor.parse(strokeColor).toCss(), [strokeColor]);
|
|
@@ -17,7 +22,7 @@ const VideoItem = ({ item }) => {
|
|
|
17
22
|
opacity: `${opacity}`,
|
|
18
23
|
borderColor: `${borderColor}`,
|
|
19
24
|
transform: `rotate(${angle}deg)`
|
|
20
|
-
}, 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)(
|
|
25
|
+
}, 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: `
|
|
21
26
|
.video-wrapper-${item.id} {
|
|
22
27
|
position: absolute;
|
|
23
28
|
overflow: hidden;
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.VimeoEmbedItem = void 0;
|
|
4
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const style_1 = __importDefault(require("styled-jsx/style"));
|
|
5
10
|
const LinkWrapper_1 = require("../LinkWrapper");
|
|
6
11
|
const useEmbedVideoItem_1 = require("./useEmbedVideoItem");
|
|
7
12
|
const useItemAngle_1 = require("../useItemAngle");
|
|
8
13
|
const VimeoEmbedItem = ({ item }) => {
|
|
14
|
+
const id = (0, react_1.useId)();
|
|
9
15
|
const { radius } = (0, useEmbedVideoItem_1.useEmbedVideoItem)(item);
|
|
10
16
|
const angle = (0, useItemAngle_1.useItemAngle)(item);
|
|
11
17
|
const { autoplay, controls, loop, muted, pictureInPicture, url } = item.commonParams;
|
|
@@ -26,7 +32,7 @@ const VimeoEmbedItem = ({ item }) => {
|
|
|
26
32
|
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: {
|
|
27
33
|
borderRadius: `${radius * 100}vw`,
|
|
28
34
|
transform: `rotate(${angle}deg)`
|
|
29
|
-
}, children: (0, jsx_runtime_1.jsx)("iframe", { className: "embedVideo", src: validUrl || '', allow: "autoplay; fullscreen; picture-in-picture;", allowFullScreen: true }) }), (0, jsx_runtime_1.jsx)(
|
|
35
|
+
}, children: (0, jsx_runtime_1.jsx)("iframe", { className: "embedVideo", src: validUrl || '', allow: "autoplay; fullscreen; picture-in-picture;", allowFullScreen: true }) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
30
36
|
.embed-video-wrapper-${item.id} {
|
|
31
37
|
position: absolute;
|
|
32
38
|
overflow: hidden;
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.YoutubeEmbedItem = void 0;
|
|
4
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const style_1 = __importDefault(require("styled-jsx/style"));
|
|
5
10
|
const LinkWrapper_1 = require("../LinkWrapper");
|
|
6
11
|
const getValidYoutubeUrl_1 = require("../../utils/getValidYoutubeUrl");
|
|
7
12
|
const useEmbedVideoItem_1 = require("./useEmbedVideoItem");
|
|
8
13
|
const useItemAngle_1 = require("../useItemAngle");
|
|
9
14
|
const YoutubeEmbedItem = ({ item }) => {
|
|
15
|
+
const id = (0, react_1.useId)();
|
|
10
16
|
const { autoplay, controls, url } = item.commonParams;
|
|
11
17
|
const { radius } = (0, useEmbedVideoItem_1.useEmbedVideoItem)(item);
|
|
12
18
|
const angle = (0, useItemAngle_1.useItemAngle)(item);
|
|
@@ -23,7 +29,7 @@ const YoutubeEmbedItem = ({ item }) => {
|
|
|
23
29
|
return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, { url: item.link?.url, children: [(0, jsx_runtime_1.jsx)("div", { className: `embed-youtube-video-wrapper-${item.id}`, style: {
|
|
24
30
|
borderRadius: `${radius * 100}vw`,
|
|
25
31
|
transform: `rotate(${angle}deg)`
|
|
26
|
-
}, children: (0, jsx_runtime_1.jsx)("iframe", { className: "embedYoutubeVideo", src: validUrl || '', allow: "accelerometer; autoplay; allowfullscreen;", allowFullScreen: true }) }), (0, jsx_runtime_1.jsx)(
|
|
32
|
+
}, children: (0, jsx_runtime_1.jsx)("iframe", { className: "embedYoutubeVideo", src: validUrl || '', allow: "accelerometer; autoplay; allowfullscreen;", allowFullScreen: true }) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
27
33
|
.embed-youtube-video-wrapper-${item.id} {
|
|
28
34
|
position: absolute;
|
|
29
35
|
overflow: hidden;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cntrl-site/sdk-nextjs",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.11",
|
|
4
4
|
"description": "SDK for Next.js",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/index.js",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"@types/lodash.isequal": "^4.5.6",
|
|
30
30
|
"lodash.isequal": "^4.5.0",
|
|
31
|
-
"next": "^
|
|
31
|
+
"next": "^13.4.2",
|
|
32
32
|
"react": "^18.2.0",
|
|
33
33
|
"react-dom": "^18.2.0"
|
|
34
34
|
},
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { FC, useRef } from 'react';
|
|
1
|
+
import { FC, useId, useRef } from 'react';
|
|
2
|
+
import JSXStyle from 'styled-jsx/style';
|
|
2
3
|
import { TArticle } from '@cntrl-site/sdk';
|
|
3
4
|
import { Section } from './Section';
|
|
4
5
|
import { Item } from './Item';
|
|
@@ -12,6 +13,7 @@ interface Props {
|
|
|
12
13
|
export const Article: FC<Props> = ({ article }) => {
|
|
13
14
|
const articleRef = useRef<HTMLDivElement | null>(null);
|
|
14
15
|
const articleRectObserver = useArticleRectObserver(articleRef.current);
|
|
16
|
+
const id = useId();
|
|
15
17
|
|
|
16
18
|
return (
|
|
17
19
|
<ArticleRectContext.Provider value={articleRectObserver}>
|
|
@@ -24,12 +26,12 @@ export const Article: FC<Props> = ({ article }) => {
|
|
|
24
26
|
</Section>
|
|
25
27
|
))}
|
|
26
28
|
</div>
|
|
27
|
-
<
|
|
29
|
+
<JSXStyle id={id}>{`
|
|
28
30
|
.article {
|
|
29
31
|
position: relative;
|
|
30
32
|
overflow: clip;
|
|
31
33
|
}
|
|
32
|
-
`}</
|
|
34
|
+
`}</JSXStyle>
|
|
33
35
|
</ArticleRectContext.Provider>
|
|
34
36
|
);
|
|
35
37
|
};
|
package/src/components/Item.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ComponentType, FC, useEffect, useRef, useState } from 'react';
|
|
1
|
+
import { ComponentType, FC, useEffect, useId, useRef, useState } from 'react';
|
|
2
|
+
import JSXStyle from 'styled-jsx/style';
|
|
2
3
|
import {
|
|
3
4
|
ArticleItemSizingType as SizingType,
|
|
4
5
|
ArticleItemType,
|
|
@@ -39,6 +40,7 @@ const itemsMap: Record<ArticleItemType, ComponentType<ItemProps<any>>> = {
|
|
|
39
40
|
const noop = () => null;
|
|
40
41
|
|
|
41
42
|
export const Item: FC<ItemProps<TArticleItemAny>> = ({ item }) => {
|
|
43
|
+
const id = useId();
|
|
42
44
|
const { layouts } = useCntrlContext();
|
|
43
45
|
const { scale, scaleAnchor } = useItemScale(item);
|
|
44
46
|
const position = useItemPosition(item);
|
|
@@ -86,7 +88,7 @@ export const Item: FC<ItemProps<TArticleItemAny>> = ({ item }) => {
|
|
|
86
88
|
style={isInitialRef.current ? {} : { ...styles, position: isFixed ? 'fixed': 'absolute' } }
|
|
87
89
|
>
|
|
88
90
|
<ItemComponent item={item} />
|
|
89
|
-
<
|
|
91
|
+
<JSXStyle id={id}>{`
|
|
90
92
|
${getLayoutStyles(layouts, layoutValues, ([area, layoutParams]) => {
|
|
91
93
|
const sizingAxis = parseSizing(layoutParams.sizing);
|
|
92
94
|
return (`
|
|
@@ -103,7 +105,7 @@ export const Item: FC<ItemProps<TArticleItemAny>> = ({ item }) => {
|
|
|
103
105
|
}
|
|
104
106
|
`);
|
|
105
107
|
})}
|
|
106
|
-
`}</
|
|
108
|
+
`}</JSXStyle>
|
|
107
109
|
</div>
|
|
108
110
|
);
|
|
109
111
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { FC, ReactElement } from 'react';
|
|
1
|
+
import { FC, ReactElement, useId } from 'react';
|
|
2
|
+
import JSXStyle from 'styled-jsx/style';
|
|
2
3
|
import {
|
|
3
4
|
getLayoutMediaQuery,
|
|
4
5
|
getLayoutStyles,
|
|
@@ -17,6 +18,7 @@ interface Props {
|
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
export const Section: FC<Props> = ({ section, children }) => {
|
|
21
|
+
const id = useId();
|
|
20
22
|
const { layouts } = useCntrlContext();
|
|
21
23
|
const backgroundColor = useSectionColor(section.color);
|
|
22
24
|
const getSectionVisibilityStyles = () => {
|
|
@@ -45,7 +47,7 @@ export const Section: FC<Props> = ({ section, children }) => {
|
|
|
45
47
|
>
|
|
46
48
|
{children}
|
|
47
49
|
</div>
|
|
48
|
-
<
|
|
50
|
+
<JSXStyle id={id}>{`
|
|
49
51
|
${
|
|
50
52
|
getLayoutStyles(layouts, [section.height], ([height]) => (`
|
|
51
53
|
.section-${section.id} {
|
|
@@ -55,7 +57,7 @@ export const Section: FC<Props> = ({ section, children }) => {
|
|
|
55
57
|
))
|
|
56
58
|
}
|
|
57
59
|
${getSectionVisibilityStyles()}
|
|
58
|
-
`}</
|
|
60
|
+
`}</JSXStyle>
|
|
59
61
|
</>
|
|
60
62
|
);
|
|
61
63
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { FC, useMemo } from 'react';
|
|
1
|
+
import { FC, useId, useMemo } from 'react';
|
|
2
|
+
import JSXStyle from 'styled-jsx/style';
|
|
2
3
|
import { CntrlColor, TImageItem } from '@cntrl-site/sdk';
|
|
3
4
|
import { ItemProps } from '../Item';
|
|
4
5
|
import { LinkWrapper } from '../LinkWrapper';
|
|
@@ -6,6 +7,7 @@ import { useFileItem } from './useFileItem';
|
|
|
6
7
|
import { useItemAngle } from '../useItemAngle';
|
|
7
8
|
|
|
8
9
|
export const ImageItem: FC<ItemProps<TImageItem>> = ({ item }) => {
|
|
10
|
+
const id = useId();
|
|
9
11
|
const { radius, strokeWidth, opacity, strokeColor } = useFileItem(item);
|
|
10
12
|
const angle = useItemAngle(item);
|
|
11
13
|
const borderColor = useMemo(() => CntrlColor.parse(strokeColor).toCss(), [strokeColor]);
|
|
@@ -23,7 +25,7 @@ export const ImageItem: FC<ItemProps<TImageItem>> = ({ item }) => {
|
|
|
23
25
|
>
|
|
24
26
|
<img className="image" src={item.commonParams.url} />
|
|
25
27
|
</div>
|
|
26
|
-
<
|
|
28
|
+
<JSXStyle id={id}>{`
|
|
27
29
|
.image-wrapper-${item.id} {
|
|
28
30
|
position: absolute;
|
|
29
31
|
overflow: hidden;
|
|
@@ -39,7 +41,7 @@ export const ImageItem: FC<ItemProps<TImageItem>> = ({ item }) => {
|
|
|
39
41
|
object-fit: cover;
|
|
40
42
|
pointer-events: none;
|
|
41
43
|
}
|
|
42
|
-
`}</
|
|
44
|
+
`}</JSXStyle>
|
|
43
45
|
</>
|
|
44
46
|
</LinkWrapper>
|
|
45
47
|
);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { FC, useMemo } from 'react';
|
|
1
|
+
import { FC, useId, useMemo } from 'react';
|
|
2
|
+
import JSXStyle from 'styled-jsx/style';
|
|
2
3
|
import { TRectangleItem, CntrlColor } from '@cntrl-site/sdk';
|
|
3
4
|
import { ItemProps } from '../Item';
|
|
4
5
|
import { LinkWrapper } from '../LinkWrapper';
|
|
@@ -6,6 +7,7 @@ import { useRectangleItem } from './useRectangleItem';
|
|
|
6
7
|
import { useItemAngle } from '../useItemAngle';
|
|
7
8
|
|
|
8
9
|
export const RectangleItem: FC<ItemProps<TRectangleItem>> = ({ item }) => {
|
|
10
|
+
const id = useId();
|
|
9
11
|
const { fillColor, radius, strokeWidth, strokeColor } = useRectangleItem(item);
|
|
10
12
|
const angle = useItemAngle(item);
|
|
11
13
|
const backgroundColor = useMemo(() => CntrlColor.parse(fillColor).toCss(), [fillColor]);
|
|
@@ -23,7 +25,7 @@ export const RectangleItem: FC<ItemProps<TRectangleItem>> = ({ item }) => {
|
|
|
23
25
|
transform: `rotate(${angle}deg)`
|
|
24
26
|
}}
|
|
25
27
|
/>
|
|
26
|
-
<
|
|
28
|
+
<JSXStyle id={id}>{`
|
|
27
29
|
.rectangle-${item.id} {
|
|
28
30
|
position: absolute;
|
|
29
31
|
width: 100%;
|
|
@@ -31,7 +33,7 @@ export const RectangleItem: FC<ItemProps<TRectangleItem>> = ({ item }) => {
|
|
|
31
33
|
border-style: solid;
|
|
32
34
|
box-sizing: border-box;
|
|
33
35
|
}
|
|
34
|
-
`}</
|
|
36
|
+
`}</JSXStyle>
|
|
35
37
|
</>
|
|
36
38
|
</LinkWrapper>
|
|
37
39
|
);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { FC, useMemo } from 'react';
|
|
1
|
+
import { FC, useId, useMemo } from 'react';
|
|
2
|
+
import JSXStyle from 'styled-jsx/style';
|
|
2
3
|
import { CntrlColor, TVideoItem } from '@cntrl-site/sdk';
|
|
3
4
|
import { ItemProps } from '../Item';
|
|
4
5
|
import { LinkWrapper } from '../LinkWrapper';
|
|
@@ -6,6 +7,7 @@ import { useFileItem } from './useFileItem';
|
|
|
6
7
|
import { useItemAngle } from '../useItemAngle';
|
|
7
8
|
|
|
8
9
|
export const VideoItem: FC<ItemProps<TVideoItem>> = ({ item }) => {
|
|
10
|
+
const id = useId();
|
|
9
11
|
const { radius, strokeWidth, strokeColor, opacity } = useFileItem(item);
|
|
10
12
|
const angle = useItemAngle(item);
|
|
11
13
|
const borderColor = useMemo(() => CntrlColor.parse(strokeColor).toCss(), [strokeColor]);
|
|
@@ -24,7 +26,7 @@ export const VideoItem: FC<ItemProps<TVideoItem>> = ({ item }) => {
|
|
|
24
26
|
<source src={item.commonParams.url} />
|
|
25
27
|
</video>
|
|
26
28
|
</div>
|
|
27
|
-
<
|
|
29
|
+
<JSXStyle id={id}>{`
|
|
28
30
|
.video-wrapper-${item.id} {
|
|
29
31
|
position: absolute;
|
|
30
32
|
overflow: hidden;
|
|
@@ -42,7 +44,7 @@ export const VideoItem: FC<ItemProps<TVideoItem>> = ({ item }) => {
|
|
|
42
44
|
object-fit: cover;
|
|
43
45
|
pointer-events: none;
|
|
44
46
|
}
|
|
45
|
-
`}</
|
|
47
|
+
`}</JSXStyle>
|
|
46
48
|
</LinkWrapper>
|
|
47
49
|
);
|
|
48
50
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
1
|
+
import { FC, useId } from 'react';
|
|
2
|
+
import JSXStyle from 'styled-jsx/style';
|
|
2
3
|
import { TVimeoEmbedItem } from '@cntrl-site/core';
|
|
3
4
|
import { ItemProps } from '../Item';
|
|
4
5
|
import { LinkWrapper } from '../LinkWrapper';
|
|
@@ -6,6 +7,7 @@ import { useEmbedVideoItem } from './useEmbedVideoItem';
|
|
|
6
7
|
import { useItemAngle } from '../useItemAngle';
|
|
7
8
|
|
|
8
9
|
export const VimeoEmbedItem: FC<ItemProps<TVimeoEmbedItem>> = ({ item }) => {
|
|
10
|
+
const id = useId();
|
|
9
11
|
const { radius } = useEmbedVideoItem(item);
|
|
10
12
|
const angle = useItemAngle(item);
|
|
11
13
|
const { autoplay, controls, loop, muted, pictureInPicture, url } = item.commonParams;
|
|
@@ -40,7 +42,7 @@ export const VimeoEmbedItem: FC<ItemProps<TVimeoEmbedItem>> = ({ item }) => {
|
|
|
40
42
|
allowFullScreen
|
|
41
43
|
/>
|
|
42
44
|
</div>
|
|
43
|
-
<
|
|
45
|
+
<JSXStyle id={id}>{`
|
|
44
46
|
.embed-video-wrapper-${item.id} {
|
|
45
47
|
position: absolute;
|
|
46
48
|
overflow: hidden;
|
|
@@ -53,7 +55,7 @@ export const VimeoEmbedItem: FC<ItemProps<TVimeoEmbedItem>> = ({ item }) => {
|
|
|
53
55
|
z-index: 1;
|
|
54
56
|
border: none;
|
|
55
57
|
}
|
|
56
|
-
`}</
|
|
58
|
+
`}</JSXStyle>
|
|
57
59
|
</LinkWrapper>
|
|
58
60
|
);
|
|
59
61
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
1
|
+
import { FC, useId } from 'react';
|
|
2
|
+
import JSXStyle from 'styled-jsx/style';
|
|
2
3
|
import { TYoutubeEmbedItem } from '@cntrl-site/core';
|
|
3
4
|
import { ItemProps } from '../Item';
|
|
4
5
|
import { LinkWrapper } from '../LinkWrapper';
|
|
@@ -7,6 +8,7 @@ import { useEmbedVideoItem } from './useEmbedVideoItem';
|
|
|
7
8
|
import { useItemAngle } from '../useItemAngle';
|
|
8
9
|
|
|
9
10
|
export const YoutubeEmbedItem: FC<ItemProps<TYoutubeEmbedItem>> = ({ item }) => {
|
|
11
|
+
const id = useId();
|
|
10
12
|
const { autoplay, controls, url } = item.commonParams;
|
|
11
13
|
const { radius } = useEmbedVideoItem(item);
|
|
12
14
|
const angle = useItemAngle(item);
|
|
@@ -38,7 +40,7 @@ export const YoutubeEmbedItem: FC<ItemProps<TYoutubeEmbedItem>> = ({ item }) =>
|
|
|
38
40
|
allowFullScreen
|
|
39
41
|
/>
|
|
40
42
|
</div>
|
|
41
|
-
<
|
|
43
|
+
<JSXStyle id={id}>{`
|
|
42
44
|
.embed-youtube-video-wrapper-${item.id} {
|
|
43
45
|
position: absolute;
|
|
44
46
|
overflow: hidden;
|
|
@@ -51,7 +53,7 @@ export const YoutubeEmbedItem: FC<ItemProps<TYoutubeEmbedItem>> = ({ item }) =>
|
|
|
51
53
|
z-index: 1;
|
|
52
54
|
border: none;
|
|
53
55
|
}
|
|
54
|
-
`}</
|
|
56
|
+
`}</JSXStyle>
|
|
55
57
|
</LinkWrapper>
|
|
56
58
|
)
|
|
57
59
|
};
|
|
Binary file
|