@cntrl-site/sdk-nextjs 1.9.110 → 1.9.112
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/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/modules.xml +8 -0
- package/.idea/sdk-nextjs.iml +12 -0
- package/.idea/vcs.xml +6 -0
- package/lib/components/Section/Section.js +13 -2
- package/lib/components/Section/SectionImage.js +17 -4
- package/lib/components/Section/SectionVideo.js +3 -3
- package/lib/utils/getFill.js +11 -5
- package/package.json +2 -2
- package/src/components/Section/Section.tsx +10 -1
- package/src/components/Section/SectionImage.tsx +35 -13
- package/src/components/Section/SectionVideo.tsx +4 -3
- package/src/utils/getFill.ts +11 -5
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectModuleManager">
|
|
4
|
+
<modules>
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/sdk-nextjs.iml" filepath="$PROJECT_DIR$/.idea/sdk-nextjs.iml" />
|
|
6
|
+
</modules>
|
|
7
|
+
</component>
|
|
8
|
+
</project>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="WEB_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager">
|
|
4
|
+
<content url="file://$MODULE_DIR$">
|
|
5
|
+
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
|
6
|
+
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
|
7
|
+
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
|
8
|
+
</content>
|
|
9
|
+
<orderEntry type="inheritedJdk" />
|
|
10
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
11
|
+
</component>
|
|
12
|
+
</module>
|
package/.idea/vcs.xml
ADDED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getSectionHeight = exports.Section = void 0;
|
|
6
|
+
exports.getSectionHeight = exports.getSectionHeightFallback = exports.Section = void 0;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const react_1 = require("react");
|
|
9
9
|
const style_1 = __importDefault(require("styled-jsx/style"));
|
|
@@ -71,6 +71,7 @@ const Section = ({ section, data, zIndex, articleHeight }) => {
|
|
|
71
71
|
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: `section-${section.id}`, id: section.name, ref: sectionRef, style: { zIndex }, children: [media && media.size !== 'none' && sectionRef.current && ((0, jsx_runtime_1.jsx)("div", { className: `section-background-overlay-${section.id}`, children: (0, jsx_runtime_1.jsxs)("div", { className: `section-background-wrapper-${section.id}`, style: Object.assign({ transform: media.position === 'fixed' ? 'translateY(-100vh)' : 'unset' }, (sectionHeight && { height: media.position === 'fixed' ? `calc(${sectionHeight}px + 200vh)` : `${sectionHeight}px` })), children: [media.type === 'video' && ((0, jsx_runtime_1.jsx)(SectionVideo_1.SectionVideo, { container: sectionRef.current, sectionId: section.id, media: media })), media.type === 'image' && ((0, jsx_runtime_1.jsx)(SectionImage_1.SectionImage, { media: media, sectionId: section.id }))] }, `section-background-wrapper-${section.id}`) })), children] }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
72
72
|
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([height, color, media]) => (`
|
|
73
73
|
.section-${section.id} {
|
|
74
|
+
min-height: ${getSectionHeightFallback(height)};
|
|
74
75
|
min-height: ${getSectionHeight(height)};
|
|
75
76
|
position: relative;
|
|
76
77
|
background-color: ${color_1.CntrlColor.parse(color !== null && color !== void 0 ? color : DEFAULT_COLOR).fmt('rgba')};
|
|
@@ -84,6 +85,7 @@ const Section = ({ section, data, zIndex, articleHeight }) => {
|
|
|
84
85
|
.section-background-wrapper-${section.id} {
|
|
85
86
|
transform: ${(media === null || media === void 0 ? void 0 : media.position) === 'fixed' ? 'translateY(-100vh)' : 'unset'};
|
|
86
87
|
position: relative;
|
|
88
|
+
height: ${(media === null || media === void 0 ? void 0 : media.position) === 'fixed' ? `calc(${getSectionHeightFallback(height)} + 200vh)` : getSectionHeightFallback(height)};
|
|
87
89
|
height: ${(media === null || media === void 0 ? void 0 : media.position) === 'fixed' ? `calc(${getSectionHeight(height)} + 200vh)` : getSectionHeight(height)};
|
|
88
90
|
width: 100%;
|
|
89
91
|
}
|
|
@@ -92,7 +94,7 @@ const Section = ({ section, data, zIndex, articleHeight }) => {
|
|
|
92
94
|
` })] }));
|
|
93
95
|
};
|
|
94
96
|
exports.Section = Section;
|
|
95
|
-
function
|
|
97
|
+
function getSectionHeightFallback(heightData) {
|
|
96
98
|
const { units, vhUnits, mode } = heightData;
|
|
97
99
|
if (mode === sdk_1.SectionHeightMode.ViewportHeightUnits)
|
|
98
100
|
return `${vhUnits}vh`;
|
|
@@ -100,4 +102,13 @@ function getSectionHeight(heightData) {
|
|
|
100
102
|
return `${units * 100}vw`;
|
|
101
103
|
return '0';
|
|
102
104
|
}
|
|
105
|
+
exports.getSectionHeightFallback = getSectionHeightFallback;
|
|
106
|
+
function getSectionHeight(heightData) {
|
|
107
|
+
const { units, vhUnits, mode } = heightData;
|
|
108
|
+
if (mode === sdk_1.SectionHeightMode.ViewportHeightUnits)
|
|
109
|
+
return `${vhUnits}svh`;
|
|
110
|
+
if (mode === sdk_1.SectionHeightMode.ControlUnits)
|
|
111
|
+
return `${units * 100}vw`;
|
|
112
|
+
return '0';
|
|
113
|
+
}
|
|
103
114
|
exports.getSectionHeight = getSectionHeight;
|
|
@@ -3,8 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SectionImage = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const SectionImage = ({ media, sectionId }) => {
|
|
6
|
-
const { url, size, position, offsetX } = media;
|
|
6
|
+
const { url, size, position, offsetX, opacity, tileSize } = media;
|
|
7
7
|
const isContainHeight = size === 'contain-height';
|
|
8
|
+
const isTile = size === 'tile';
|
|
8
9
|
const hasOffsetX = offsetX !== null && size === 'contain';
|
|
9
10
|
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)("div", { className: `section-image-wrapper-${sectionId}`, style: {
|
|
10
11
|
position: position === 'fixed' ? 'sticky' : 'relative',
|
|
@@ -12,13 +13,25 @@ const SectionImage = ({ media, sectionId }) => {
|
|
|
12
13
|
top: position === 'fixed' ? '100vh' : '0',
|
|
13
14
|
width: '100%',
|
|
14
15
|
overflow: 'hidden'
|
|
15
|
-
}, children: (0, jsx_runtime_1.jsx)("
|
|
16
|
+
}, children: isTile ? ((0, jsx_runtime_1.jsx)("div", { className: `image-background-${sectionId}`, style: {
|
|
17
|
+
position: 'absolute',
|
|
18
|
+
top: 0,
|
|
19
|
+
left: 0,
|
|
20
|
+
width: '100%',
|
|
21
|
+
height: '100%',
|
|
22
|
+
backgroundImage: `url(${url})`,
|
|
23
|
+
backgroundSize: `${tileSize}%`,
|
|
24
|
+
backgroundRepeat: 'repeat',
|
|
25
|
+
backgroundPosition: '0 0',
|
|
26
|
+
opacity
|
|
27
|
+
} })) : ((0, jsx_runtime_1.jsx)("img", { src: url, className: `image-background-${sectionId}`, style: {
|
|
16
28
|
objectFit: isContainHeight ? 'unset' : (size !== null && size !== void 0 ? size : 'cover'),
|
|
17
29
|
width: isContainHeight || hasOffsetX ? 'auto' : '100%',
|
|
18
30
|
transform: isContainHeight ? 'translateX(-50%)' : 'none',
|
|
19
31
|
position: 'relative',
|
|
20
32
|
left: isContainHeight ? '50%' : (hasOffsetX ? `${offsetX * 100}vw` : '0'),
|
|
21
|
-
height: '100%'
|
|
22
|
-
|
|
33
|
+
height: '100%',
|
|
34
|
+
opacity
|
|
35
|
+
} })) }) }));
|
|
23
36
|
};
|
|
24
37
|
exports.SectionImage = SectionImage;
|
|
@@ -7,7 +7,7 @@ const SectionVideo = ({ container, sectionId, media }) => {
|
|
|
7
7
|
const [video, setVideo] = (0, react_1.useState)(null);
|
|
8
8
|
const [videoWrapper, setVideoWrapper] = (0, react_1.useState)(null);
|
|
9
9
|
const [isVideoWidthOverflow, setIsVideoWidthOverflow] = (0, react_1.useState)(false);
|
|
10
|
-
const { url, size, position, offsetX, coverUrl, play } = media;
|
|
10
|
+
const { url, size, position, offsetX, coverUrl, play, opacity } = media;
|
|
11
11
|
const [isPlaying, setIsPlaying] = (0, react_1.useState)(false);
|
|
12
12
|
const [userPaused, setUserPaused] = (0, react_1.useState)(false);
|
|
13
13
|
const [isClickedOnCover, setIsClickedOnCover] = (0, react_1.useState)(false);
|
|
@@ -64,7 +64,7 @@ const SectionVideo = ({ container, sectionId, media }) => {
|
|
|
64
64
|
overflow: 'hidden',
|
|
65
65
|
width: '100%'
|
|
66
66
|
}, children: [(0, jsx_runtime_1.jsx)("video", { ref: setVideo, autoPlay: play === 'auto', loop: true, style: {
|
|
67
|
-
opacity: !isClickedOnCover && play === 'on-click' && coverUrl ? 0 :
|
|
67
|
+
opacity: !isClickedOnCover && play === 'on-click' && coverUrl ? 0 : opacity,
|
|
68
68
|
objectFit: isContainHeight ? 'cover' : (size !== null && size !== void 0 ? size : 'cover'),
|
|
69
69
|
width: isContainHeight && !isVideoWidthOverflow ? 'auto' : '100%',
|
|
70
70
|
transform: isContainHeight ? 'translateX(-50%)' : 'none',
|
|
@@ -78,7 +78,7 @@ const SectionVideo = ({ container, sectionId, media }) => {
|
|
|
78
78
|
height: '100%',
|
|
79
79
|
top: 0
|
|
80
80
|
}, onClick: handleCoverClick, children: coverUrl && play === 'on-click' && ((0, jsx_runtime_1.jsx)("img", { src: coverUrl, alt: "Video cover", className: `video-background-${sectionId}-cover`, style: {
|
|
81
|
-
opacity: isPlaying ? 0 :
|
|
81
|
+
opacity: isPlaying ? 0 : opacity,
|
|
82
82
|
left: isContainHeight ? '50%' : (hasOffsetX ? `${offsetX * 100}vw` : '0'),
|
|
83
83
|
width: isContainHeight ? 'auto' : '100%',
|
|
84
84
|
objectFit: isContainHeight ? 'unset' : (size !== null && size !== void 0 ? size : 'cover'),
|
package/lib/utils/getFill.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getFill = void 0;
|
|
4
|
+
const color_1 = require("@cntrl-site/color");
|
|
4
5
|
function getFill(fill) {
|
|
5
6
|
var _a;
|
|
6
7
|
if (fill.type === 'linear-gradient' && Array.isArray(fill.colors)) {
|
|
7
8
|
return `linear-gradient(${fill.angle}deg, ${fill.colors
|
|
8
|
-
.map(c => `${c.value} ${c.position}%`)
|
|
9
|
+
.map(c => `${getParsedColor(c.value)} ${c.position}%`)
|
|
9
10
|
.join(', ')})`;
|
|
10
11
|
}
|
|
11
12
|
if (fill.type === 'radial-gradient' && Array.isArray(fill.colors)) {
|
|
@@ -14,7 +15,7 @@ function getFill(fill) {
|
|
|
14
15
|
: '50% 50%';
|
|
15
16
|
const diameter = fill.diameter;
|
|
16
17
|
return `radial-gradient(circle ${diameter * 100} at ${center}, ${fill.colors
|
|
17
|
-
.map(c => `${c.value} ${c.position}%`)
|
|
18
|
+
.map(c => `${getParsedColor(c.value)} ${c.position}%`)
|
|
18
19
|
.join(', ')})`;
|
|
19
20
|
}
|
|
20
21
|
if (fill.type === 'conic-gradient' && Array.isArray(fill.colors)) {
|
|
@@ -26,18 +27,23 @@ function getFill(fill) {
|
|
|
26
27
|
const lastStop = fill.colors[fill.colors.length - 1];
|
|
27
28
|
const shouldAppendWrapStop = hasMultipleStops && typeof lastStop.position === 'number' && lastStop.position < 100;
|
|
28
29
|
const colorsWithWrap = shouldAppendWrapStop
|
|
29
|
-
? [...fill.colors, { value: fill.colors[0].value, position: 100 }]
|
|
30
|
+
? [...fill.colors, { value: getParsedColor(fill.colors[0].value), position: 100 }]
|
|
30
31
|
: fill.colors;
|
|
31
32
|
return `conic-gradient(from ${angle + 90}deg at ${center}, ${colorsWithWrap
|
|
32
|
-
.map(c => `${c.value} ${c.position}%`)
|
|
33
|
+
.map(c => `${getParsedColor(c.value)} ${c.position}%`)
|
|
33
34
|
.join(', ')})`;
|
|
34
35
|
}
|
|
35
36
|
if (fill.type === 'image' && fill.src) {
|
|
36
37
|
return `url(${fill.src})`;
|
|
37
38
|
}
|
|
38
39
|
if (fill.type === 'solid') {
|
|
39
|
-
return fill.value;
|
|
40
|
+
return getParsedColor(fill.value);
|
|
40
41
|
}
|
|
41
42
|
return 'transparent';
|
|
42
43
|
}
|
|
43
44
|
exports.getFill = getFill;
|
|
45
|
+
function getParsedColor(color) {
|
|
46
|
+
if (!color)
|
|
47
|
+
return color;
|
|
48
|
+
return color_1.CntrlColor.parse(color).fmt('rgba');
|
|
49
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cntrl-site/sdk-nextjs",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.112",
|
|
4
4
|
"description": "SDK for Next.js",
|
|
5
5
|
"author": "arsen@momdesign.nyc",
|
|
6
6
|
"license": "MIT",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@cntrl-site/color": "^1.0.0",
|
|
34
34
|
"@cntrl-site/components": "^1.0.56",
|
|
35
35
|
"@cntrl-site/effects": "^1.4.2",
|
|
36
|
-
"@cntrl-site/sdk": "^1.28.
|
|
36
|
+
"@cntrl-site/sdk": "^1.28.5",
|
|
37
37
|
"@types/vimeo__player": "^2.18.0",
|
|
38
38
|
"@vimeo/player": "^2.25.0",
|
|
39
39
|
"html-react-parser": "^3.0.1",
|
|
@@ -129,6 +129,7 @@ export const Section: FC<PropsWithChildren<Props>> = ({ section, data, zIndex, a
|
|
|
129
129
|
${
|
|
130
130
|
getLayoutStyles(layouts, layoutValues, ([height, color, media]) => (`
|
|
131
131
|
.section-${section.id} {
|
|
132
|
+
min-height: ${getSectionHeightFallback(height)};
|
|
132
133
|
min-height: ${getSectionHeight(height)};
|
|
133
134
|
position: relative;
|
|
134
135
|
background-color: ${CntrlColor.parse(color ?? DEFAULT_COLOR).fmt('rgba')};
|
|
@@ -142,6 +143,7 @@ export const Section: FC<PropsWithChildren<Props>> = ({ section, data, zIndex, a
|
|
|
142
143
|
.section-background-wrapper-${section.id} {
|
|
143
144
|
transform: ${media?.position === 'fixed' ? 'translateY(-100vh)' : 'unset'};
|
|
144
145
|
position: relative;
|
|
146
|
+
height: ${media?.position === 'fixed' ? `calc(${getSectionHeightFallback(height)} + 200vh)` : getSectionHeightFallback(height)};
|
|
145
147
|
height: ${media?.position === 'fixed' ? `calc(${getSectionHeight(height)} + 200vh)` : getSectionHeight(height)};
|
|
146
148
|
width: 100%;
|
|
147
149
|
}
|
|
@@ -154,9 +156,16 @@ export const Section: FC<PropsWithChildren<Props>> = ({ section, data, zIndex, a
|
|
|
154
156
|
);
|
|
155
157
|
};
|
|
156
158
|
|
|
157
|
-
export function
|
|
159
|
+
export function getSectionHeightFallback(heightData: SectionHeight): string {
|
|
158
160
|
const { units, vhUnits, mode } = heightData;
|
|
159
161
|
if (mode === SectionHeightMode.ViewportHeightUnits) return `${vhUnits}vh`;
|
|
160
162
|
if (mode === SectionHeightMode.ControlUnits) return `${units * 100}vw`;
|
|
161
163
|
return '0';
|
|
162
164
|
}
|
|
165
|
+
|
|
166
|
+
export function getSectionHeight(heightData: SectionHeight): string {
|
|
167
|
+
const { units, vhUnits, mode } = heightData;
|
|
168
|
+
if (mode === SectionHeightMode.ViewportHeightUnits) return `${vhUnits}svh`;
|
|
169
|
+
if (mode === SectionHeightMode.ControlUnits) return `${units * 100}vw`;
|
|
170
|
+
return '0';
|
|
171
|
+
}
|
|
@@ -7,6 +7,8 @@ export type TSectionImage = {
|
|
|
7
7
|
size: string;
|
|
8
8
|
position: string;
|
|
9
9
|
offsetX: number | null;
|
|
10
|
+
opacity?: number;
|
|
11
|
+
tileSize?: number;
|
|
10
12
|
};
|
|
11
13
|
|
|
12
14
|
interface Props {
|
|
@@ -15,8 +17,9 @@ interface Props {
|
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
export const SectionImage: FC<Props> = ({ media, sectionId }) => {
|
|
18
|
-
const { url, size, position, offsetX } = media;
|
|
20
|
+
const { url, size, position, offsetX, opacity, tileSize } = media;
|
|
19
21
|
const isContainHeight = size === 'contain-height';
|
|
22
|
+
const isTile = size === 'tile';
|
|
20
23
|
const hasOffsetX = offsetX !== null && size === 'contain';
|
|
21
24
|
return (
|
|
22
25
|
<>
|
|
@@ -30,18 +33,37 @@ export const SectionImage: FC<Props> = ({ media, sectionId }) => {
|
|
|
30
33
|
overflow: 'hidden'
|
|
31
34
|
}}
|
|
32
35
|
>
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
36
|
+
{isTile ? (
|
|
37
|
+
<div
|
|
38
|
+
className={`image-background-${sectionId}`}
|
|
39
|
+
style={{
|
|
40
|
+
position: 'absolute',
|
|
41
|
+
top: 0,
|
|
42
|
+
left: 0,
|
|
43
|
+
width: '100%',
|
|
44
|
+
height: '100%',
|
|
45
|
+
backgroundImage: `url(${url})`,
|
|
46
|
+
backgroundSize: `${tileSize}%`,
|
|
47
|
+
backgroundRepeat: 'repeat',
|
|
48
|
+
backgroundPosition: '0 0',
|
|
49
|
+
opacity
|
|
50
|
+
}}
|
|
51
|
+
/>
|
|
52
|
+
) : (
|
|
53
|
+
<img
|
|
54
|
+
src={url}
|
|
55
|
+
className={`image-background-${sectionId}`}
|
|
56
|
+
style={{
|
|
57
|
+
objectFit: isContainHeight ? 'unset' : (size ?? 'cover') as CSSProperties['objectFit'],
|
|
58
|
+
width: isContainHeight || hasOffsetX ? 'auto' : '100%',
|
|
59
|
+
transform: isContainHeight ? 'translateX(-50%)' : 'none',
|
|
60
|
+
position: 'relative',
|
|
61
|
+
left: isContainHeight ? '50%' : (hasOffsetX ? `${offsetX * 100}vw` : '0'),
|
|
62
|
+
height: '100%',
|
|
63
|
+
opacity
|
|
64
|
+
}}
|
|
65
|
+
/>
|
|
66
|
+
)}
|
|
45
67
|
</div>
|
|
46
68
|
</>
|
|
47
69
|
);
|
|
@@ -9,6 +9,7 @@ export type TSectionVideo = {
|
|
|
9
9
|
position: string;
|
|
10
10
|
coverUrl: string | null;
|
|
11
11
|
offsetX: number | null;
|
|
12
|
+
opacity?: number;
|
|
12
13
|
};
|
|
13
14
|
|
|
14
15
|
interface Props {
|
|
@@ -21,7 +22,7 @@ export const SectionVideo: FC<Props> = ({ container, sectionId, media }) => {
|
|
|
21
22
|
const [video, setVideo] = useState<HTMLVideoElement | null>(null);
|
|
22
23
|
const [videoWrapper, setVideoWrapper] = useState<HTMLDivElement | null>(null);
|
|
23
24
|
const [isVideoWidthOverflow, setIsVideoWidthOverflow] = useState(false);
|
|
24
|
-
const { url, size, position, offsetX, coverUrl, play } = media;
|
|
25
|
+
const { url, size, position, offsetX, coverUrl, play, opacity } = media;
|
|
25
26
|
const [isPlaying, setIsPlaying] = useState(false);
|
|
26
27
|
const [userPaused, setUserPaused] = useState(false);
|
|
27
28
|
const [isClickedOnCover, setIsClickedOnCover] = useState(false);
|
|
@@ -89,7 +90,7 @@ export const SectionVideo: FC<Props> = ({ container, sectionId, media }) => {
|
|
|
89
90
|
autoPlay={play === 'auto'}
|
|
90
91
|
loop
|
|
91
92
|
style={{
|
|
92
|
-
opacity: !isClickedOnCover && play === 'on-click' && coverUrl ? 0 :
|
|
93
|
+
opacity: !isClickedOnCover && play === 'on-click' && coverUrl ? 0 : opacity,
|
|
93
94
|
objectFit: isContainHeight ? 'cover' : (size ?? 'cover') as CSSProperties['objectFit'],
|
|
94
95
|
width: isContainHeight && !isVideoWidthOverflow ? 'auto' : '100%',
|
|
95
96
|
transform: isContainHeight ? 'translateX(-50%)' : 'none',
|
|
@@ -125,7 +126,7 @@ export const SectionVideo: FC<Props> = ({ container, sectionId, media }) => {
|
|
|
125
126
|
alt="Video cover"
|
|
126
127
|
className={`video-background-${sectionId}-cover`}
|
|
127
128
|
style={{
|
|
128
|
-
opacity: isPlaying ? 0 :
|
|
129
|
+
opacity: isPlaying ? 0 : opacity,
|
|
129
130
|
left: isContainHeight ? '50%' : (hasOffsetX ? `${offsetX * 100}vw` : '0'),
|
|
130
131
|
width: isContainHeight ? 'auto' : '100%',
|
|
131
132
|
objectFit: isContainHeight ? 'unset' : (size ?? 'cover') as CSSProperties['objectFit'],
|
package/src/utils/getFill.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { CntrlColor } from '@cntrl-site/color';
|
|
1
2
|
import { FillLayer } from '@cntrl-site/sdk';
|
|
2
3
|
|
|
3
4
|
export function getFill(fill: FillLayer) {
|
|
4
5
|
if (fill.type === 'linear-gradient' && Array.isArray(fill.colors)) {
|
|
5
6
|
return `linear-gradient(${fill.angle}deg, ${fill.colors
|
|
6
|
-
.map(c => `${c.value} ${c.position}%`)
|
|
7
|
+
.map(c => `${getParsedColor(c.value)} ${c.position}%`)
|
|
7
8
|
.join(', ')})`;
|
|
8
9
|
}
|
|
9
10
|
|
|
@@ -13,7 +14,7 @@ export function getFill(fill: FillLayer) {
|
|
|
13
14
|
: '50% 50%';
|
|
14
15
|
const diameter = fill.diameter;
|
|
15
16
|
return `radial-gradient(circle ${diameter * 100} at ${center}, ${fill.colors
|
|
16
|
-
.map(c => `${c.value} ${c.position}%`)
|
|
17
|
+
.map(c => `${getParsedColor(c.value)} ${c.position}%`)
|
|
17
18
|
.join(', ')})`;
|
|
18
19
|
}
|
|
19
20
|
|
|
@@ -26,11 +27,11 @@ export function getFill(fill: FillLayer) {
|
|
|
26
27
|
const lastStop = fill.colors[fill.colors.length - 1];
|
|
27
28
|
const shouldAppendWrapStop = hasMultipleStops && typeof lastStop.position === 'number' && lastStop.position < 100;
|
|
28
29
|
const colorsWithWrap = shouldAppendWrapStop
|
|
29
|
-
? [...fill.colors, { value: fill.colors[0].value, position: 100 }]
|
|
30
|
+
? [...fill.colors, { value: getParsedColor(fill.colors[0].value), position: 100 }]
|
|
30
31
|
: fill.colors;
|
|
31
32
|
|
|
32
33
|
return `conic-gradient(from ${angle + 90}deg at ${center}, ${colorsWithWrap
|
|
33
|
-
.map(c => `${c.value} ${c.position}%`)
|
|
34
|
+
.map(c => `${getParsedColor(c.value)} ${c.position}%`)
|
|
34
35
|
.join(', ')})`;
|
|
35
36
|
}
|
|
36
37
|
|
|
@@ -39,8 +40,13 @@ export function getFill(fill: FillLayer) {
|
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
if (fill.type === 'solid') {
|
|
42
|
-
return fill.value;
|
|
43
|
+
return getParsedColor(fill.value);
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
return 'transparent';
|
|
46
47
|
}
|
|
48
|
+
|
|
49
|
+
function getParsedColor(color?: string) {
|
|
50
|
+
if (!color) return color;
|
|
51
|
+
return CntrlColor.parse(color).fmt('rgba');
|
|
52
|
+
}
|