@cntrl-site/sdk-nextjs 0.30.1 → 0.30.2

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.
@@ -0,0 +1,5 @@
1
+ <component name="ProjectCodeStyleConfiguration">
2
+ <state>
3
+ <option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
4
+ </state>
5
+ </component>
Binary file
@@ -36,20 +36,33 @@ const CodeEmbedItem = ({ item, sectionId, onResize }) => {
36
36
  (0, useRegisterResize_1.useRegisterResize)(ref, onResize);
37
37
  const pos = stylesMap[anchor];
38
38
  const layoutValues = [item.area, item.layoutParams, item.state.hover];
39
- 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({ opacity: `${opacity}`, transform: `rotate(${angle}deg)`, filter: `blur(${blur * 100}vw)` }, pos), ref: setRef, children: (0, jsx_runtime_1.jsx)("div", { className: "embed", dangerouslySetInnerHTML: { __html: html } }) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
40
- .embed -wrapper-${item.id} {
39
+ (0, react_1.useEffect)(() => {
40
+ if (!ref)
41
+ return;
42
+ const scripts = ref.querySelectorAll('script');
43
+ for (const script of scripts) {
44
+ const newScript = document.createElement('script');
45
+ for (const attr of script.getAttributeNames()) {
46
+ newScript.setAttribute(attr, script.getAttribute(attr));
47
+ }
48
+ newScript.textContent = script.textContent;
49
+ script.parentNode.removeChild(script);
50
+ ref.appendChild(newScript);
51
+ }
52
+ }, [item.commonParams.html]);
53
+ 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: { opacity: `${opacity}`, transform: `rotate(${angle}deg)`, filter: `blur(${blur * 100}vw)` }, ref: setRef, children: (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: `
54
+ .embed-wrapper-${item.id} {
41
55
  position: absolute;
42
56
  width: 100%;
43
57
  height: 100%;
44
58
  }
45
- .embed {
46
- width: 100%;
47
- height: 100%;
59
+ .embed-${item.id} {
60
+ transform: ${item.commonParams.scale ? 'scale(var(--layout-deviation))' : 'none'};
61
+ transform-origin: top left;
48
62
  z-index: 1;
49
63
  border: none;
50
- overflow: hidden;
51
64
  }
52
- ${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams, hoverParams]) => {
65
+ ${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams, hoverParams], exemplary) => {
53
66
  return (`
54
67
  .embed-wrapper-${item.id} {
55
68
  opacity: ${layoutParams.opacity};
@@ -57,6 +70,10 @@ const CodeEmbedItem = ({ item, sectionId, onResize }) => {
57
70
  filter: ${layoutParams.blur !== 0 ? `blur(${layoutParams.blur * 100}vw)` : 'unset'};
58
71
  transition: ${(0, HoverStyles_1.getTransitions)(['angle', 'blur', 'opacity'], hoverParams)};
59
72
  }
73
+ .embed-${item.id} {
74
+ width: ${item.commonParams.scale ? `${area.width * exemplary}px` : '100%'};
75
+ height: ${item.commonParams.scale ? `${area.height * exemplary}px` : '100%'};
76
+ }
60
77
  .embed-wrapper-${item.id}:hover {
61
78
  ${(0, HoverStyles_1.getHoverStyles)(['angle', 'blur', 'opacity'], hoverParams)}
62
79
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cntrl-site/sdk-nextjs",
3
- "version": "0.30.1",
3
+ "version": "0.30.2",
4
4
  "description": "SDK for Next.js",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/index.ts",
@@ -23,7 +23,7 @@
23
23
  "dependencies": {
24
24
  "@cntrl-site/color": "^1.0.0",
25
25
  "@cntrl-site/effects": "^1.2.0",
26
- "@cntrl-site/sdk": "^1.12.0",
26
+ "@cntrl-site/sdk": "^1.12.1",
27
27
  "@types/vimeo__player": "^2.18.0",
28
28
  "@vimeo/player": "^2.20.1",
29
29
  "html-react-parser": "^3.0.1",
@@ -1,5 +1,5 @@
1
1
  import { ArticleItemType, getLayoutStyles, CodeEmbedItem as TCodeEmbedItem, AreaAnchor } from '@cntrl-site/sdk';
2
- import { FC, useId, useState } from 'react';
2
+ import { FC, useEffect, useId, useState } from 'react';
3
3
  import { useCntrlContext } from '../../provider/useCntrlContext';
4
4
  import { ItemProps } from '../Item';
5
5
  import { getHoverStyles, getTransitions } from '../../utils/HoverStyles/HoverStyles';
@@ -32,29 +32,46 @@ export const CodeEmbedItem: FC<ItemProps<TCodeEmbedItem>> = ({ item, sectionId,
32
32
  const pos = stylesMap[anchor];
33
33
  const layoutValues: Record<string, any>[] = [item.area, item.layoutParams, item.state.hover];
34
34
 
35
+ useEffect(() => {
36
+ if (!ref) return;
37
+ const scripts = ref.querySelectorAll('script');
38
+ for (const script of scripts) {
39
+ const newScript = document.createElement('script');
40
+ for (const attr of script.getAttributeNames()) {
41
+ newScript.setAttribute(attr, script.getAttribute(attr)!);
42
+ }
43
+ newScript.textContent = script.textContent;
44
+ script.parentNode!.removeChild(script);
45
+ ref.appendChild(newScript);
46
+ }
47
+ }, [item.commonParams.html]);
48
+
35
49
  return (
36
50
  <LinkWrapper url={item.link?.url} target={item.link?.target}>
37
51
  <div
38
52
  className={`embed-wrapper-${item.id}`}
39
- style={{ opacity: `${opacity}`, transform: `rotate(${angle}deg)`, filter: `blur(${blur * 100}vw)`, ...pos}}
53
+ style={{ opacity: `${opacity}`, transform: `rotate(${angle}deg)`, filter: `blur(${blur * 100}vw)` }}
40
54
  ref={setRef}
41
55
  >
42
- <div className="embed" dangerouslySetInnerHTML={{ __html: html }}></div>
56
+ <div
57
+ className={`embed-${item.id}`}
58
+ style={{ ...pos }}
59
+ dangerouslySetInnerHTML={{ __html: html }}
60
+ />
43
61
  </div>
44
62
  <JSXStyle id={id}>{`
45
- .embed -wrapper-${item.id} {
63
+ .embed-wrapper-${item.id} {
46
64
  position: absolute;
47
65
  width: 100%;
48
66
  height: 100%;
49
67
  }
50
- .embed {
51
- width: 100%;
52
- height: 100%;
68
+ .embed-${item.id} {
69
+ transform: ${item.commonParams.scale ? 'scale(var(--layout-deviation))' : 'none'};
70
+ transform-origin: top left;
53
71
  z-index: 1;
54
72
  border: none;
55
- overflow: hidden;
56
73
  }
57
- ${getLayoutStyles(layouts, layoutValues, ([area, layoutParams, hoverParams]) => {
74
+ ${getLayoutStyles(layouts, layoutValues, ([area, layoutParams, hoverParams], exemplary) => {
58
75
  return (`
59
76
  .embed-wrapper-${item.id} {
60
77
  opacity: ${layoutParams.opacity};
@@ -62,6 +79,10 @@ export const CodeEmbedItem: FC<ItemProps<TCodeEmbedItem>> = ({ item, sectionId,
62
79
  filter: ${layoutParams.blur !== 0 ? `blur(${layoutParams.blur * 100}vw)` : 'unset'};
63
80
  transition: ${getTransitions<ArticleItemType.CodeEmbed>(['angle', 'blur', 'opacity'], hoverParams)};
64
81
  }
82
+ .embed-${item.id} {
83
+ width: ${item.commonParams.scale ? `${area.width * exemplary}px` : '100%'};
84
+ height: ${item.commonParams.scale ? `${area.height * exemplary}px` : '100%'};
85
+ }
65
86
  .embed-wrapper-${item.id}:hover {
66
87
  ${getHoverStyles<ArticleItemType.CodeEmbed>(['angle', 'blur', 'opacity'], hoverParams)}
67
88
  }
Binary file
Binary file