@cntrl-site/sdk-nextjs 1.8.20 → 1.8.22

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.
@@ -1,34 +1,24 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.SectionImage = void 0;
7
4
  const jsx_runtime_1 = require("react/jsx-runtime");
8
- const react_1 = require("react");
9
- const style_1 = __importDefault(require("styled-jsx/style"));
10
5
  const SectionImage = ({ media, sectionId }) => {
11
- const id = (0, react_1.useId)();
12
6
  const { url, size, position, offsetX } = media;
13
7
  const isContainHeight = size === 'contain-height';
14
8
  const hasOffsetX = offsetX !== null && size === 'contain';
15
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `section-image-wrapper-${sectionId}`, children: (0, jsx_runtime_1.jsx)("img", { src: url, className: `image-background-${sectionId}` }) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
16
- .section-image-wrapper-${sectionId} {
17
- position: ${position === 'fixed' ? 'sticky' : 'relative'};
18
- height: ${position === 'fixed' ? '100vh' : '100%'};
19
- top: ${position === 'fixed' ? '100vh' : '0'};
20
- width: 100%;
21
- overflow: hidden;
22
- }
23
- .image-background-${sectionId} {
24
- object-fit: ${isContainHeight ? 'unset' : size !== null && size !== void 0 ? size : 'cover'};
25
- width: ${isContainHeight || hasOffsetX ? 'auto' : '100%'};
26
- transform: ${isContainHeight ? 'translateX(-50%)' : 'none'};
27
- position: relative;
28
- left: ${isContainHeight ? '50%' : (hasOffsetX ? `${offsetX * 100}vw` : '0')};
29
- height: 100%;
30
- ${offsetX ? 'max-width: 100vw;' : ''}
31
- }
32
- ` })] }));
9
+ return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)("div", { className: `section-image-wrapper-${sectionId}`, style: {
10
+ position: position === 'fixed' ? 'sticky' : 'relative',
11
+ height: position === 'fixed' ? '100vh' : '100%',
12
+ top: position === 'fixed' ? '100vh' : '0',
13
+ width: '100%',
14
+ overflow: 'hidden'
15
+ }, children: (0, jsx_runtime_1.jsx)("img", { src: url, className: `image-background-${sectionId}`, style: {
16
+ objectFit: isContainHeight ? 'unset' : (size !== null && size !== void 0 ? size : 'cover'),
17
+ width: isContainHeight || hasOffsetX ? 'auto' : '100%',
18
+ transform: isContainHeight ? 'translateX(-50%)' : 'none',
19
+ position: 'relative',
20
+ left: isContainHeight ? '50%' : (hasOffsetX ? `${offsetX * 100}vw` : '0'),
21
+ height: '100%'
22
+ } }) }) }));
33
23
  };
34
24
  exports.SectionImage = SectionImage;
@@ -1,16 +1,11 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.SectionVideo = void 0;
7
4
  const jsx_runtime_1 = require("react/jsx-runtime");
8
5
  const react_1 = require("react");
9
- const style_1 = __importDefault(require("styled-jsx/style"));
10
6
  const SectionVideo = ({ container, sectionId, media }) => {
11
7
  const [video, setVideo] = (0, react_1.useState)(null);
12
8
  const { url, size, position, offsetX, coverUrl, play } = media;
13
- const id = (0, react_1.useId)();
14
9
  const [isPlaying, setIsPlaying] = (0, react_1.useState)(false);
15
10
  const [userPaused, setUserPaused] = (0, react_1.useState)(false);
16
11
  const [isClickedOnCover, setIsClickedOnCover] = (0, react_1.useState)(false);
@@ -45,40 +40,36 @@ const SectionVideo = ({ container, sectionId, media }) => {
45
40
  }, [container, play, userPaused, isClickedOnCover]);
46
41
  const isContainHeight = size === 'contain-height';
47
42
  const hasOffsetX = offsetX !== null && size === 'contain';
48
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: `section-video-wrapper-${sectionId}`, 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: `
49
- .section-video-wrapper-${sectionId} {
50
- position: ${position === 'fixed' ? 'sticky' : 'relative'};
51
- height: ${position === 'fixed' ? '100vh' : '100%'};
52
- top: ${position === 'fixed' ? '100vh' : '0'};
53
- width: 100%;
54
- overflow: hidden;
55
- }
56
- .video-background-${sectionId}-cover-container {
57
- position: absolute;
58
- pointer-events: ${play === 'on-click' ? 'auto' : 'none'};
59
- left: 0;
60
- width: 100%;
61
- height: 100%;
62
- top: 0;
63
- }
64
- .video-background-${sectionId}-cover {
65
- position: relative;
66
- left: ${isContainHeight ? '50%' : (hasOffsetX ? `${offsetX * 100}vw` : '0')};
67
- width: ${isContainHeight ? 'auto' : '100%'};
68
- height: 100%;
69
- object-fit: ${isContainHeight ? 'unset' : size !== null && size !== void 0 ? size : 'cover'};
70
- transition: opacity 0.1s ease-in-out;
71
- transform: ${isContainHeight ? 'translateX(-50%)' : 'none'};
72
- ${hasOffsetX ? 'max-width: 100vw;' : ''}
73
- }
74
- .video-background-${sectionId} {
75
- object-fit: ${isContainHeight ? 'unset' : size !== null && size !== void 0 ? size : 'cover'};
76
- width: ${isContainHeight ? 'auto' : '100%'};
77
- height: 100%;
78
- position: relative;
79
- transform: ${isContainHeight ? 'translateX(-50%)' : 'none'};
80
- left: ${isContainHeight ? '50%' : (hasOffsetX ? `${offsetX * 100}vw` : '0')};
81
- }
82
- ` })] }));
43
+ return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)("div", { className: `section-video-wrapper-${sectionId}`, style: {
44
+ position: position === 'fixed' ? 'sticky' : 'relative',
45
+ height: position === 'fixed' ? '100vh' : '100%',
46
+ top: position === 'fixed' ? '100vh' : '0',
47
+ overflow: 'hidden',
48
+ width: '100%'
49
+ }, children: [(0, jsx_runtime_1.jsx)("video", { ref: setVideo, autoPlay: play === 'auto', loop: true, style: {
50
+ opacity: !isPlaying && play === 'on-click' && coverUrl ? 0 : 1,
51
+ objectFit: isContainHeight ? 'unset' : (size !== null && size !== void 0 ? size : 'cover'),
52
+ width: isContainHeight ? 'auto' : '100%',
53
+ transform: isContainHeight ? 'translateX(-50%)' : 'none',
54
+ left: isContainHeight ? '50%' : (hasOffsetX ? `${offsetX * 100}vw` : '0'),
55
+ height: '100%',
56
+ position: 'relative'
57
+ }, 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`, style: {
58
+ pointerEvents: play === 'on-click' ? 'auto' : 'none',
59
+ position: 'absolute',
60
+ left: 0,
61
+ width: '100%',
62
+ height: '100%',
63
+ top: 0
64
+ }, onClick: handleCoverClick, children: coverUrl && play === 'on-click' && ((0, jsx_runtime_1.jsx)("img", { src: coverUrl, alt: "Video cover", className: `video-background-${sectionId}-cover`, style: {
65
+ opacity: isPlaying ? 0 : 1,
66
+ left: isContainHeight ? '50%' : (hasOffsetX ? `${offsetX * 100}vw` : '0'),
67
+ width: isContainHeight ? 'auto' : '100%',
68
+ objectFit: isContainHeight ? 'unset' : (size !== null && size !== void 0 ? size : 'cover'),
69
+ transform: isContainHeight ? 'translateX(-50%)' : 'none',
70
+ position: 'relative',
71
+ height: '100%',
72
+ transition: 'opacity 0.1s ease-in-out'
73
+ } })) })] }) }));
83
74
  };
84
75
  exports.SectionVideo = SectionVideo;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cntrl-site/sdk-nextjs",
3
- "version": "1.8.20",
3
+ "version": "1.8.22",
4
4
  "description": "SDK for Next.js",
5
5
  "author": "arsen@momdesign.nyc",
6
6
  "license": "MIT",
@@ -1,4 +1,4 @@
1
- import { FC, useId } from 'react';
1
+ import { CSSProperties, FC, useId } from 'react';
2
2
  import JSXStyle from 'styled-jsx/style';
3
3
 
4
4
  export type TSectionImage = {
@@ -15,34 +15,34 @@ interface Props {
15
15
  }
16
16
 
17
17
  export const SectionImage: FC<Props> = ({ media, sectionId }) => {
18
- const id = useId();
19
18
  const { url, size, position, offsetX } = media;
20
19
  const isContainHeight = size === 'contain-height';
21
20
  const hasOffsetX = offsetX !== null && size === 'contain';
22
21
  return (
23
22
  <>
24
- <div className={`section-image-wrapper-${sectionId}`}>
25
- <img src={url} className={`image-background-${sectionId}`} />
23
+ <div
24
+ className={`section-image-wrapper-${sectionId}`}
25
+ style={{
26
+ position: position === 'fixed' ? 'sticky' : 'relative',
27
+ height: position === 'fixed' ? '100vh' : '100%',
28
+ top: position === 'fixed' ? '100vh' : '0',
29
+ width: '100%',
30
+ overflow: 'hidden'
31
+ }}
32
+ >
33
+ <img
34
+ src={url}
35
+ className={`image-background-${sectionId}`}
36
+ style={{
37
+ objectFit: isContainHeight ? 'unset' : (size ?? 'cover') as CSSProperties['objectFit'],
38
+ width: isContainHeight || hasOffsetX ? 'auto' : '100%',
39
+ transform: isContainHeight ? 'translateX(-50%)' : 'none',
40
+ position: 'relative',
41
+ left: isContainHeight ? '50%' : (hasOffsetX ? `${offsetX * 100}vw` : '0'),
42
+ height: '100%'
43
+ }}
44
+ />
26
45
  </div>
27
- <JSXStyle id={id}>{`
28
- .section-image-wrapper-${sectionId} {
29
- position: ${position === 'fixed' ? 'sticky' : 'relative'};
30
- height: ${position === 'fixed' ? '100vh' : '100%'};
31
- top: ${position === 'fixed' ? '100vh' : '0'};
32
- width: 100%;
33
- overflow: hidden;
34
- }
35
- .image-background-${sectionId} {
36
- object-fit: ${isContainHeight ? 'unset' : size ?? 'cover'};
37
- width: ${isContainHeight || hasOffsetX ? 'auto' : '100%'};
38
- transform: ${isContainHeight ? 'translateX(-50%)' : 'none'};
39
- position: relative;
40
- left: ${isContainHeight ? '50%' : (hasOffsetX ? `${offsetX * 100}vw` : '0')};
41
- height: 100%;
42
- ${offsetX ? 'max-width: 100vw;' : ''}
43
- }
44
- `}
45
- </JSXStyle>
46
46
  </>
47
47
  );
48
48
  };
@@ -1,4 +1,4 @@
1
- import { FC, useEffect, useId, useRef, useState } from 'react';
1
+ import { CSSProperties, FC, useEffect, useId, useRef, useState } from 'react';
2
2
  import JSXStyle from 'styled-jsx/style';
3
3
 
4
4
  export type TSectionVideo = {
@@ -20,7 +20,6 @@ interface Props {
20
20
  export const SectionVideo: FC<Props> = ({ container, sectionId, media }) => {
21
21
  const [video, setVideo] = useState<HTMLVideoElement | null>(null);
22
22
  const { url, size, position, offsetX, coverUrl, play } = media;
23
- const id = useId();
24
23
  const [isPlaying, setIsPlaying] = useState(false);
25
24
  const [userPaused, setUserPaused] = useState(false);
26
25
  const [isClickedOnCover, setIsClickedOnCover] = useState(false);
@@ -58,12 +57,29 @@ export const SectionVideo: FC<Props> = ({ container, sectionId, media }) => {
58
57
 
59
58
  return (
60
59
  <>
61
- <div className={`section-video-wrapper-${sectionId}`}>
60
+ <div
61
+ className={`section-video-wrapper-${sectionId}`}
62
+ style={{
63
+ position: position === 'fixed' ? 'sticky' : 'relative',
64
+ height: position === 'fixed' ? '100vh' : '100%',
65
+ top: position === 'fixed' ? '100vh' : '0',
66
+ overflow: 'hidden',
67
+ width: '100%'
68
+ }}
69
+ >
62
70
  <video
63
71
  ref={setVideo}
64
72
  autoPlay={play === 'auto'}
65
73
  loop
66
- style={{ opacity: !isPlaying && play === 'on-click' && coverUrl ? 0 : 1 }}
74
+ style={{
75
+ opacity: !isPlaying && play === 'on-click' && coverUrl ? 0 : 1,
76
+ objectFit: isContainHeight ? 'unset' : (size ?? 'cover') as CSSProperties['objectFit'],
77
+ width: isContainHeight ? 'auto' : '100%',
78
+ transform: isContainHeight ? 'translateX(-50%)' : 'none',
79
+ left: isContainHeight ? '50%' : (hasOffsetX ? `${offsetX * 100}vw` : '0'),
80
+ height: '100%',
81
+ position: 'relative'
82
+ }}
67
83
  controls={false}
68
84
  muted={play === 'auto'}
69
85
  playsInline
@@ -74,48 +90,37 @@ export const SectionVideo: FC<Props> = ({ container, sectionId, media }) => {
74
90
  >
75
91
  <source src={`${url}#t=0.001`} />
76
92
  </video>
77
- <div className={`video-background-${sectionId}-cover-container`} onClick={handleCoverClick}>
93
+ <div
94
+ className={`video-background-${sectionId}-cover-container`}
95
+ style={{
96
+ pointerEvents: play === 'on-click' ? 'auto' : 'none',
97
+ position: 'absolute',
98
+ left: 0,
99
+ width: '100%',
100
+ height: '100%',
101
+ top: 0
102
+ }}
103
+ onClick={handleCoverClick}
104
+ >
78
105
  {coverUrl && play === 'on-click' && (
79
- <img src={coverUrl} alt="Video cover" className={`video-background-${sectionId}-cover`} style={{ opacity: isPlaying ? 0 : 1 }} />
106
+ <img
107
+ src={coverUrl}
108
+ alt="Video cover"
109
+ className={`video-background-${sectionId}-cover`}
110
+ style={{
111
+ opacity: isPlaying ? 0 : 1,
112
+ left: isContainHeight ? '50%' : (hasOffsetX ? `${offsetX * 100}vw` : '0'),
113
+ width: isContainHeight ? 'auto' : '100%',
114
+ objectFit: isContainHeight ? 'unset' : (size ?? 'cover') as CSSProperties['objectFit'],
115
+ transform: isContainHeight ? 'translateX(-50%)' : 'none',
116
+ position: 'relative',
117
+ height: '100%',
118
+ transition: 'opacity 0.1s ease-in-out'
119
+ }}
120
+ />
80
121
  )}
81
122
  </div>
82
123
  </div>
83
- <JSXStyle id={id}>{`
84
- .section-video-wrapper-${sectionId} {
85
- position: ${position === 'fixed' ? 'sticky' : 'relative'};
86
- height: ${position === 'fixed' ? '100vh' : '100%'};
87
- top: ${position === 'fixed' ? '100vh' : '0'};
88
- width: 100%;
89
- overflow: hidden;
90
- }
91
- .video-background-${sectionId}-cover-container {
92
- position: absolute;
93
- pointer-events: ${play === 'on-click' ? 'auto' : 'none'};
94
- left: 0;
95
- width: 100%;
96
- height: 100%;
97
- top: 0;
98
- }
99
- .video-background-${sectionId}-cover {
100
- position: relative;
101
- left: ${isContainHeight ? '50%' : (hasOffsetX ? `${offsetX * 100}vw` : '0')};
102
- width: ${isContainHeight ? 'auto' : '100%'};
103
- height: 100%;
104
- object-fit: ${isContainHeight ? 'unset' : size ?? 'cover'};
105
- transition: opacity 0.1s ease-in-out;
106
- transform: ${isContainHeight ? 'translateX(-50%)' : 'none'};
107
- ${hasOffsetX ? 'max-width: 100vw;' : ''}
108
- }
109
- .video-background-${sectionId} {
110
- object-fit: ${isContainHeight ? 'unset' : size ?? 'cover'};
111
- width: ${isContainHeight ? 'auto' : '100%'};
112
- height: 100%;
113
- position: relative;
114
- transform: ${isContainHeight ? 'translateX(-50%)' : 'none'};
115
- left: ${isContainHeight ? '50%' : (hasOffsetX ? `${offsetX * 100}vw` : '0')};
116
- }
117
- `}
118
- </JSXStyle>
119
124
  </>
120
125
  );
121
126
  };
Binary file
Binary file