@cntrl-site/sdk-nextjs 1.9.110 → 1.9.111

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.
@@ -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 getSectionHeight(heightData) {
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;
@@ -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.110",
3
+ "version": "1.9.111",
4
4
  "description": "SDK for Next.js",
5
5
  "author": "arsen@momdesign.nyc",
6
6
  "license": "MIT",
@@ -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 getSectionHeight(heightData: SectionHeight): string {
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
+ }
@@ -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
+ }