@cntrl-site/sdk-nextjs 0.29.0 → 0.29.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.
Binary file
@@ -39,13 +39,17 @@ const itemsMap = {
39
39
  [sdk_1.ArticleItemType.Custom]: CustomItem_1.CustomItem,
40
40
  [sdk_1.ArticleItemType.Group]: GroupItem_1.GroupItem
41
41
  };
42
+ const stickyFix = `
43
+ -webkit-transform: translate3d(0, 0, 0);
44
+ transform: translate3d(0, 0, 0);
45
+ `;
42
46
  const RichTextWrapper = ({ isRichText, children }) => {
43
47
  if (!isRichText)
44
48
  return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children });
45
49
  return ((0, jsx_runtime_1.jsx)("div", { style: { transformOrigin: 'top left', transform: 'scale(var(--layout-deviation))' }, children: children }));
46
50
  };
47
51
  const noop = () => null;
48
- const Item = ({ item, sectionId, articleHeight }) => {
52
+ const Item = ({ item, sectionId, articleHeight, isInGroup = false }) => {
49
53
  const itemWrapperRef = (0, react_1.useRef)(null);
50
54
  const rectObserver = (0, react_1.useContext)(ArticleRectContext_1.ArticleRectContext);
51
55
  const id = (0, react_1.useId)();
@@ -131,8 +135,7 @@ const Item = ({ item, sectionId, articleHeight }) => {
131
135
  .item-wrapper-${item.id} {
132
136
  position: ${area.positionType === sdk_1.PositionType.ScreenBased ? 'fixed' : 'absolute'};
133
137
  z-index: ${area.zIndex};
134
- -webkit-transform: translate3d(0, 0, 0);
135
- transform: translate3d(0, 0, 0);
138
+ ${!isInGroup && stickyFix}
136
139
  pointer-events: none;
137
140
  bottom: ${isScreenBasedBottom ? `${-area.top * 100}vw` : 'unset'};
138
141
  top: ${isScreenBasedBottom ? 'unset' : (0, getItemTopStyle_1.getItemTopStyle)(area.top, area.anchorSide)};
@@ -27,7 +27,7 @@ const GroupItem = ({ item, sectionId, onResize, articleHeight }) => {
27
27
  return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { url: (_a = item.link) === null || _a === void 0 ? void 0 : _a.url, target: (_b = item.link) === null || _b === void 0 ? void 0 : _b.target, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `group-${item.id}`, ref: setRef, style: {
28
28
  opacity,
29
29
  transform: `rotate(${angle}deg)`,
30
- }, children: items && items.map(item => ((0, jsx_runtime_1.jsx)(Item_1.Item, { item: item, sectionId: sectionId, articleHeight: articleHeight }, item.id))) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
30
+ }, 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: `
31
31
  .group-${item.id} {
32
32
  position: absolute;
33
33
  width: 100%;
@@ -19,7 +19,7 @@ const VimeoEmbedItem = ({ item, sectionId, onResize }) => {
19
19
  var _a, _b;
20
20
  const id = (0, react_1.useId)();
21
21
  const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
22
- const { radius, blur } = (0, useEmbedVideoItem_1.useEmbedVideoItem)(item, sectionId);
22
+ const { radius, blur, opacity } = (0, useEmbedVideoItem_1.useEmbedVideoItem)(item, sectionId);
23
23
  const [iframeRef, setIframeRef] = (0, react_1.useState)(null);
24
24
  const vimeoPlayer = (0, react_1.useMemo)(() => iframeRef ? new player_1.default(iframeRef) : undefined, [iframeRef]);
25
25
  const angle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
@@ -41,6 +41,7 @@ const VimeoEmbedItem = ({ item, sectionId, onResize }) => {
41
41
  };
42
42
  const validUrl = getValidVimeoUrl(url);
43
43
  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-video-wrapper-${item.id}`, ref: setRef, style: {
44
+ opacity: `${opacity}`,
44
45
  transform: `rotate(${angle}deg)`,
45
46
  filter: `blur(${blur * 100}vw)`
46
47
  }, onMouseEnter: () => {
@@ -21,7 +21,7 @@ const YoutubeEmbedItem = ({ item, sectionId, onResize }) => {
21
21
  const id = (0, react_1.useId)();
22
22
  const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
23
23
  const { play, controls, url } = item.commonParams;
24
- const { radius, blur } = (0, useEmbedVideoItem_1.useEmbedVideoItem)(item, sectionId);
24
+ const { radius, blur, opacity } = (0, useEmbedVideoItem_1.useEmbedVideoItem)(item, sectionId);
25
25
  const angle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
26
26
  const YT = (0, useYouTubeIframeApi_1.useYouTubeIframeApi)();
27
27
  const [div, setDiv] = (0, react_1.useState)(null);
@@ -65,6 +65,7 @@ const YoutubeEmbedItem = ({ item, sectionId, onResize }) => {
65
65
  return;
66
66
  player.pauseVideo();
67
67
  }, style: {
68
+ opacity: `${opacity}`,
68
69
  transform: `rotate(${angle}deg)`,
69
70
  filter: `blur(${blur * 100}vw)`
70
71
  }, children: (0, jsx_runtime_1.jsx)("div", { className: `embed-${item.id}`, ref: setDiv, style: { borderRadius: `${radius * 100}vw` } }) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
@@ -17,6 +17,12 @@ const useEmbedVideoItem = (item, sectionId) => {
17
17
  const layoutParams = item.layoutParams[layoutId];
18
18
  return 'blur' in layoutParams ? layoutParams.blur : 0;
19
19
  }, (animator, scroll, value) => animator.getBlur({ blur: value }, scroll).blur, sectionId, [layoutId]);
20
- return { radius, blur };
20
+ const opacity = (0, useKeyframeValue_1.useKeyframeValue)(item, (item, layoutId) => {
21
+ if (!layoutId)
22
+ return 1;
23
+ const layoutParams = item.layoutParams[layoutId];
24
+ return 'opacity' in layoutParams ? layoutParams.opacity : 1;
25
+ }, (animator, scroll, value) => animator.getOpacity({ opacity: value }, scroll).opacity, sectionId, [layoutId]);
26
+ return { radius, blur, opacity };
21
27
  };
22
28
  exports.useEmbedVideoItem = useEmbedVideoItem;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cntrl-site/sdk-nextjs",
3
- "version": "0.29.0",
3
+ "version": "0.29.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.10.0",
26
+ "@cntrl-site/sdk": "^1.11.0",
27
27
  "@types/vimeo__player": "^2.18.0",
28
28
  "@vimeo/player": "^2.20.1",
29
29
  "html-react-parser": "^3.0.1",
@@ -39,6 +39,7 @@ export interface ItemProps<I extends ItemAny> {
39
39
 
40
40
  export interface ItemWrapperProps extends ItemProps<ItemAny> {
41
41
  articleHeight: number;
42
+ isInGroup?: boolean;
42
43
  }
43
44
 
44
45
  const itemsMap: Record<ArticleItemType, ComponentType<ItemProps<any>>> = {
@@ -56,6 +57,11 @@ interface RTWrapperProps {
56
57
  isRichText: boolean;
57
58
  }
58
59
 
60
+ const stickyFix = `
61
+ -webkit-transform: translate3d(0, 0, 0);
62
+ transform: translate3d(0, 0, 0);
63
+ `;
64
+
59
65
  const RichTextWrapper: FC<PropsWithChildren<RTWrapperProps>> = ({ isRichText, children }) => {
60
66
  if (!isRichText) return <>{children}</>;
61
67
  return (
@@ -67,7 +73,7 @@ const RichTextWrapper: FC<PropsWithChildren<RTWrapperProps>> = ({ isRichText, ch
67
73
 
68
74
  const noop = () => null;
69
75
 
70
- export const Item: FC<ItemWrapperProps> = ({ item, sectionId, articleHeight }) => {
76
+ export const Item: FC<ItemWrapperProps> = ({ item, sectionId, articleHeight, isInGroup = false }) => {
71
77
  const itemWrapperRef = useRef<HTMLDivElement | null>(null);
72
78
  const rectObserver = useContext(ArticleRectContext);
73
79
  const id = useId();
@@ -177,8 +183,7 @@ export const Item: FC<ItemWrapperProps> = ({ item, sectionId, articleHeight }) =
177
183
  .item-wrapper-${item.id} {
178
184
  position: ${area.positionType === PositionType.ScreenBased ? 'fixed': 'absolute'};
179
185
  z-index: ${area.zIndex};
180
- -webkit-transform: translate3d(0, 0, 0);
181
- transform: translate3d(0, 0, 0);
186
+ ${!isInGroup && stickyFix}
182
187
  pointer-events: none;
183
188
  bottom: ${isScreenBasedBottom ? `${-area.top * 100}vw` : 'unset'};
184
189
  top: ${isScreenBasedBottom ? 'unset' : getItemTopStyle(area.top, area.anchorSide)};
@@ -35,6 +35,7 @@ export const GroupItem: FC<ItemProps<TGroupItem>> = ({ item, sectionId, onResize
35
35
  key={item.id}
36
36
  sectionId={sectionId}
37
37
  articleHeight={articleHeight}
38
+ isInGroup
38
39
  />
39
40
  ))}
40
41
  </div>
@@ -13,7 +13,7 @@ import { useRegisterResize } from "../../common/useRegisterResize";
13
13
  export const VimeoEmbedItem: FC<ItemProps<TVimeoEmbedItem>> = ({ item, sectionId, onResize }) => {
14
14
  const id = useId();
15
15
  const { layouts } = useCntrlContext();
16
- const { radius, blur } = useEmbedVideoItem(item, sectionId);
16
+ const { radius, blur, opacity } = useEmbedVideoItem(item, sectionId);
17
17
  const [iframeRef, setIframeRef] = useState<HTMLIFrameElement | null>(null);
18
18
  const vimeoPlayer = useMemo(() => iframeRef ? new Player(iframeRef) : undefined, [iframeRef]);
19
19
  const angle = useItemAngle(item, sectionId);
@@ -42,6 +42,7 @@ export const VimeoEmbedItem: FC<ItemProps<TVimeoEmbedItem>> = ({ item, sectionId
42
42
  className={`embed-video-wrapper-${item.id}`}
43
43
  ref={setRef}
44
44
  style={{
45
+ opacity: `${opacity}`,
45
46
  transform: `rotate(${angle}deg)`,
46
47
  filter: `blur(${blur * 100}vw)`
47
48
  }}
@@ -16,7 +16,7 @@ export const YoutubeEmbedItem: FC<ItemProps<TYoutubeEmbedItem>> = ({ item, secti
16
16
  const id = useId();
17
17
  const { layouts } = useCntrlContext();
18
18
  const { play, controls, url } = item.commonParams;
19
- const { radius, blur } = useEmbedVideoItem(item, sectionId);
19
+ const { radius, blur, opacity } = useEmbedVideoItem(item, sectionId);
20
20
  const angle = useItemAngle(item, sectionId);
21
21
  const YT = useYouTubeIframeApi();
22
22
  const [div, setDiv] = useState<HTMLDivElement | null>(null);
@@ -64,6 +64,7 @@ export const YoutubeEmbedItem: FC<ItemProps<TYoutubeEmbedItem>> = ({ item, secti
64
64
  player.pauseVideo();
65
65
  }}
66
66
  style={{
67
+ opacity: `${opacity}`,
67
68
  transform: `rotate(${angle}deg)`,
68
69
  filter: `blur(${blur * 100}vw)`
69
70
  }}
@@ -27,5 +27,17 @@ export const useEmbedVideoItem = (item: VimeoEmbedItem | YoutubeEmbedItem, secti
27
27
  [layoutId]
28
28
  );
29
29
 
30
- return { radius, blur };
30
+ const opacity = useKeyframeValue(
31
+ item,
32
+ (item, layoutId) => {
33
+ if (!layoutId) return 1;
34
+ const layoutParams = item.layoutParams[layoutId];
35
+ return 'opacity' in layoutParams ? layoutParams.opacity : 1;
36
+ },
37
+ (animator, scroll, value) => animator.getOpacity({ opacity: value }, scroll).opacity,
38
+ sectionId,
39
+ [layoutId]
40
+ );
41
+
42
+ return { radius, blur, opacity };
31
43
  };