@cntrl-site/sdk-nextjs 1.8.19-alpha.0 → 1.8.19-alpha.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
@@ -42,38 +42,36 @@ const SectionVideo = ({ container, sectionId, media }) => {
42
42
  observer.observe(container);
43
43
  return () => observer.disconnect();
44
44
  }, [container, play]);
45
- (0, react_1.useEffect)(() => {
46
- if (!video || play !== 'on-click')
47
- return;
48
- video.currentTime = 0.01;
49
- video.pause();
50
- }, [play]);
51
45
  const isContainHeight = size === 'contain-height';
52
46
  const hasOffsetX = offsetX !== null && size === 'contain';
53
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("video", { ref: setVideo, autoPlay: play === 'auto', loop: true, controls: false, muted: play === 'auto', playsInline: true, preload: "auto", className: `video-background-${sectionId}`, onPlay: () => setIsPlaying(true), onPause: () => setIsPlaying(false), children: (0, jsx_runtime_1.jsx)("source", { src: `${url}#t=0.001` }) }), (0, jsx_runtime_1.jsx)("div", { className: `video-background-${sectionId}-cover-container`, onClick: handleCoverClick, children: coverUrl && play === 'on-click' && ((0, jsx_runtime_1.jsx)("img", { src: coverUrl, alt: "Video cover", className: `video-background-${sectionId}-cover`, style: { opacity: isPlaying ? 0 : 1 } })) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
47
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("video", { ref: setVideo, autoPlay: play === 'auto', loop: true, style: { opacity: !isPlaying && play === 'on-click' && coverUrl ? 0 : 1 }, controls: false, muted: play === 'auto', playsInline: true, preload: "auto", className: `video-background-${sectionId}`, onPlay: () => setIsPlaying(true), onPause: () => setIsPlaying(false), children: (0, jsx_runtime_1.jsx)("source", { src: `${url}#t=0.001` }) }), (0, jsx_runtime_1.jsx)("div", { className: `video-background-${sectionId}-cover-container`, onClick: handleCoverClick, children: coverUrl && play === 'on-click' && ((0, jsx_runtime_1.jsx)("img", { src: coverUrl, alt: "Video cover", className: `video-background-${sectionId}-cover`, style: { opacity: isPlaying ? 0 : 1 } })) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
54
48
  .video-background-${sectionId}-cover-container {
55
- position: ${position === 'fixed' ? 'sticky' : 'absolute'};
49
+ position: absolute;
56
50
  pointer-events: ${play === 'on-click' ? 'auto' : 'none'};
57
51
  left: 0;
58
- width: 100vw;
59
- height: 100vh;
60
- top: ${position === 'fixed' ? '100vh' : '0'};
52
+ width: 100%;
53
+ height: 100%;
54
+ top: 0;
61
55
  }
62
56
  .video-background-${sectionId}-cover {
63
- width: 100%;
57
+ position: ${position === 'fixed' ? 'sticky' : 'relative'};
58
+ margin-left: ${isContainHeight ? '50%' : (hasOffsetX ? `${offsetX * 100}vw` : '0')};
59
+ width: ${isContainHeight ? 'auto' : '100%'};
60
+ height: ${position === 'fixed' ? '100vh' : '100%'};
61
+ object-fit: ${isContainHeight ? 'unset' : size !== null && size !== void 0 ? size : 'cover'};
64
62
  transition: opacity 0.1s ease-in-out;
65
- height: 100%;
66
- object-fit: cover;
63
+ top: ${position === 'fixed' ? '100vh' : '0'};
64
+ transform: ${isContainHeight ? 'translateX(-50%)' : 'none'};
65
+ ${hasOffsetX ? 'max-width: 100vw;' : ''}
67
66
  }
68
67
  .video-background-${sectionId} {
69
68
  object-fit: ${isContainHeight ? 'unset' : size !== null && size !== void 0 ? size : 'cover'};
70
- width: ${isContainHeight || hasOffsetX ? 'auto' : '100%'};
69
+ width: ${isContainHeight ? 'auto' : '100%'};
71
70
  height: ${position === 'fixed' ? '100vh' : '100%'};
72
71
  transform: ${isContainHeight ? 'translateX(-50%)' : 'none'};
73
72
  position: ${position === 'fixed' ? 'sticky' : 'relative'};
74
73
  top: ${position === 'fixed' ? '100vh' : 'unset'};
75
74
  margin-left: ${isContainHeight ? '50%' : (hasOffsetX ? `${offsetX * 100}vw` : '0')};
76
- ${offsetX ? 'max-width: 100vw;' : ''}
77
75
  }
78
76
  ` })] }));
79
77
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cntrl-site/sdk-nextjs",
3
- "version": "1.8.19-alpha.0",
3
+ "version": "1.8.19-alpha.2",
4
4
  "description": "SDK for Next.js",
5
5
  "author": "arsen@momdesign.nyc",
6
6
  "license": "MIT",
@@ -54,12 +54,6 @@ export const SectionVideo: FC<Props> = ({ container, sectionId, media }) => {
54
54
  return () => observer.disconnect();
55
55
  }, [container, play]);
56
56
 
57
- useEffect(() => {
58
- if (!video || play !== 'on-click') return;
59
- video.currentTime = 0.01;
60
- video.pause();
61
- }, [play]);
62
-
63
57
  const isContainHeight = size === 'contain-height';
64
58
  const hasOffsetX = offsetX !== null && size === 'contain';
65
59
 
@@ -69,6 +63,7 @@ export const SectionVideo: FC<Props> = ({ container, sectionId, media }) => {
69
63
  ref={setVideo}
70
64
  autoPlay={play === 'auto'}
71
65
  loop
66
+ style={{ opacity: !isPlaying && play === 'on-click' && coverUrl ? 0 : 1 }}
72
67
  controls={false}
73
68
  muted={play === 'auto'}
74
69
  playsInline
@@ -86,28 +81,32 @@ export const SectionVideo: FC<Props> = ({ container, sectionId, media }) => {
86
81
  </div>
87
82
  <JSXStyle id={id}>{`
88
83
  .video-background-${sectionId}-cover-container {
89
- position: ${position === 'fixed' ? 'sticky' : 'absolute'};
84
+ position: absolute;
90
85
  pointer-events: ${play === 'on-click' ? 'auto' : 'none'};
91
86
  left: 0;
92
- width: 100vw;
93
- height: 100vh;
94
- top: ${position === 'fixed' ? '100vh' : '0'};
87
+ width: 100%;
88
+ height: 100%;
89
+ top: 0;
95
90
  }
96
91
  .video-background-${sectionId}-cover {
97
- width: 100%;
92
+ position: ${position === 'fixed' ? 'sticky' : 'relative'};
93
+ margin-left: ${isContainHeight ? '50%' : (hasOffsetX ? `${offsetX * 100}vw` : '0')};
94
+ width: ${isContainHeight ? 'auto' : '100%'};
95
+ height: ${position === 'fixed' ? '100vh' : '100%'};
96
+ object-fit: ${isContainHeight ? 'unset' : size ?? 'cover'};
98
97
  transition: opacity 0.1s ease-in-out;
99
- height: 100%;
100
- object-fit: cover;
98
+ top: ${position === 'fixed' ? '100vh' : '0'};
99
+ transform: ${isContainHeight ? 'translateX(-50%)' : 'none'};
100
+ ${hasOffsetX ? 'max-width: 100vw;' : ''}
101
101
  }
102
102
  .video-background-${sectionId} {
103
103
  object-fit: ${isContainHeight ? 'unset' : size ?? 'cover'};
104
- width: ${isContainHeight || hasOffsetX ? 'auto' : '100%'};
104
+ width: ${isContainHeight ? 'auto' : '100%'};
105
105
  height: ${position === 'fixed' ? '100vh' : '100%'};
106
106
  transform: ${isContainHeight ? 'translateX(-50%)' : 'none'};
107
107
  position: ${position === 'fixed' ? 'sticky' : 'relative'};
108
108
  top: ${position === 'fixed' ? '100vh' : 'unset'};
109
109
  margin-left: ${isContainHeight ? '50%' : (hasOffsetX ? `${offsetX * 100}vw` : '0')};
110
- ${offsetX ? 'max-width: 100vw;' : ''}
111
110
  }
112
111
  `}
113
112
  </JSXStyle>