@cntrl-site/sdk-nextjs 1.9.71-0 → 1.9.71-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.
@@ -27,7 +27,7 @@ const Section = ({ section, data, zIndex, articleHeight }) => {
27
27
  const layout = (0, useLayoutContext_1.useLayoutContext)();
28
28
  const [sectionHeight, setSectionHeight] = (0, react_1.useState)(0);
29
29
  const layoutValues = [
30
- section.type === 'freehand' ? section.height : section.minHeight,
30
+ section.minHeight,
31
31
  section.color,
32
32
  (_a = section.media) !== null && _a !== void 0 ? _a : {}
33
33
  ];
@@ -65,14 +65,13 @@ const Section = ({ section, data, zIndex, articleHeight }) => {
65
65
  observer.observe(sectionRef.current);
66
66
  return () => observer.disconnect();
67
67
  }, []);
68
- const children = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [section.type !== 'freehand' && ((0, jsx_runtime_1.jsx)(StructuredContent_1.StructuredContent, { section: section })), section.items.map(item => ((0, jsx_runtime_1.jsx)(Item_1.Item, { sectionHeight: sectionHeight, item: item, sectionId: section.id, articleHeight: articleHeight }, item.id)))] }));
68
+ const children = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(StructuredContent_1.StructuredContent, { section: section }), section.items.map(item => ((0, jsx_runtime_1.jsx)(Item_1.Item, { sectionHeight: sectionHeight, item: item, sectionId: section.id, articleHeight: articleHeight }, item.id)))] }));
69
69
  if (SectionComponent)
70
70
  return (0, jsx_runtime_1.jsx)("div", { ref: sectionRef, children: (0, jsx_runtime_1.jsx)(SectionComponent, { data: data, children: children }) });
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
- height: ${section.type === 'freehand' ? getSectionHeight(height) : 'auto'};
75
- min-height: ${section.type !== 'freehand' ? getSectionHeight(height) : 'unset'};
74
+ min-height: ${getSectionHeight(height)};
76
75
  position: relative;
77
76
  background-color: ${color_1.CntrlColor.parse(color !== null && color !== void 0 ? color : DEFAULT_COLOR).fmt('rgba')};
78
77
  }
@@ -14,10 +14,10 @@ const StructuredContent = ({ section }) => {
14
14
  const reactId = (0, react_1.useId)();
15
15
  const id = `${reactId}-structured-content-${section.id}`;
16
16
  const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
17
- const paddingBottomRecord = section.type !== 'freehand' ? section.structuredContentSettings.paddingBottom : {};
17
+ const structuredContentLength = section.structuredContent.length;
18
18
  const defaultWidthRecord = section.type === 'content-based' ? section.structuredContentSettings.defaultWidth : {};
19
- const layoutValues = [paddingBottomRecord, defaultWidthRecord];
20
- if (section.type === 'freehand')
19
+ const layoutValues = [section.structuredContentSettings.paddingBottom, defaultWidthRecord];
20
+ if (structuredContentLength === 0)
21
21
  return null;
22
22
  return ((0, jsx_runtime_1.jsxs)("div", { className: `structured-content-${section.id}`, children: [section.structuredContent.map(block => ((0, jsx_runtime_1.jsx)(StructuredBlockItem_1.StructuredBlockItem, { block: block, maxWidthMap: defaultWidthRecord }, block.id))), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
23
23
  ${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([paddingBottom, defaultWidth]) => {
@@ -78,7 +78,7 @@ class CntrlSdkContext {
78
78
  }
79
79
  setSectionsHeight(sections) {
80
80
  for (const section of sections) {
81
- this.sectionHeightMap.set(section.id, section.type === 'freehand' ? section.height : section.minHeight);
81
+ this.sectionHeightMap.set(section.id, section.minHeight);
82
82
  }
83
83
  }
84
84
  getSectionHeightData(sectionId) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cntrl-site/sdk-nextjs",
3
- "version": "1.9.71-0",
3
+ "version": "1.9.71-2",
4
4
  "description": "SDK for Next.js",
5
5
  "author": "arsen@momdesign.nyc",
6
6
  "license": "MIT",
@@ -31,9 +31,9 @@
31
31
  "dependencies": {
32
32
  "@antfu/eslint-config": "^3.8.0",
33
33
  "@cntrl-site/color": "^1.0.0",
34
- "@cntrl-site/components": "^1.0.9",
34
+ "@cntrl-site/components": "^1.0.12-alpha.1",
35
35
  "@cntrl-site/effects": "^1.4.2",
36
- "@cntrl-site/sdk": "^1.28.0-5",
36
+ "@cntrl-site/sdk": "1.28.0-6",
37
37
  "@types/vimeo__player": "^2.18.0",
38
38
  "@vimeo/player": "^2.25.0",
39
39
  "html-react-parser": "^3.0.1",
@@ -34,10 +34,11 @@ export const Section: FC<PropsWithChildren<Props>> = ({ section, data, zIndex, a
34
34
  const layout = useLayoutContext();
35
35
  const [sectionHeight, setSectionHeight] = useState(0);
36
36
  const layoutValues: Record<string, any>[] = [
37
- section.type === 'freehand' ? section.height : section.minHeight,
37
+ section.minHeight,
38
38
  section.color,
39
39
  section.media ?? {}
40
40
  ];
41
+
41
42
  const SectionComponent = section.name ? customSections.getComponent(section.name) : undefined;
42
43
  useSectionRegistry(section.id, sectionRef.current);
43
44
  const layoutMedia = layout && section.media && section.media[layout] ? section.media[layout] : undefined;
@@ -80,9 +81,7 @@ export const Section: FC<PropsWithChildren<Props>> = ({ section, data, zIndex, a
80
81
 
81
82
  const children = (
82
83
  <>
83
- {section.type !== 'freehand' && (
84
- <StructuredContent section={section} />
85
- )}
84
+ <StructuredContent section={section} />
86
85
  {section.items.map(item => (
87
86
  <Item
88
87
  sectionHeight={sectionHeight}
@@ -130,8 +129,7 @@ export const Section: FC<PropsWithChildren<Props>> = ({ section, data, zIndex, a
130
129
  ${
131
130
  getLayoutStyles(layouts, layoutValues, ([height, color, media]) => (`
132
131
  .section-${section.id} {
133
- height: ${section.type === 'freehand' ? getSectionHeight(height) : 'auto'};
134
- min-height: ${section.type !== 'freehand' ? getSectionHeight(height) : 'unset'};
132
+ min-height: ${getSectionHeight(height)};
135
133
  position: relative;
136
134
  background-color: ${CntrlColor.parse(color ?? DEFAULT_COLOR).fmt('rgba')};
137
135
  }
@@ -3,7 +3,6 @@ import { FC, useId } from 'react';
3
3
  import JSXStyle from 'styled-jsx/style';
4
4
  import { useCntrlContext } from '../../provider/useCntrlContext';
5
5
  import { StructuredBlockItem } from '../StructuredBlockItem/StructuredBlockItem';
6
- import { useLayoutContext } from '../useLayoutContext';
7
6
 
8
7
  interface Props {
9
8
  section: Section;
@@ -13,10 +12,10 @@ export const StructuredContent: FC<Props> = ({ section }) => {
13
12
  const reactId = useId();
14
13
  const id = `${reactId}-structured-content-${section.id}`;
15
14
  const { layouts } = useCntrlContext();
16
- const paddingBottomRecord = section.type !== 'freehand' ? section.structuredContentSettings.paddingBottom : {};
15
+ const structuredContentLength = section.structuredContent.length;
17
16
  const defaultWidthRecord = section.type === 'content-based' ? section.structuredContentSettings.defaultWidth : {};
18
- const layoutValues: Record<string, any>[] = [paddingBottomRecord, defaultWidthRecord];
19
- if (section.type === 'freehand') return null;
17
+ const layoutValues: Record<string, any>[] = [section.structuredContentSettings.paddingBottom, defaultWidthRecord];
18
+ if (structuredContentLength === 0) return null;
20
19
  return (
21
20
  <div className={`structured-content-${section.id}`}>
22
21
  {section.structuredContent.map(block => (
@@ -86,7 +86,7 @@ export class CntrlSdkContext {
86
86
 
87
87
  setSectionsHeight(sections: Section[]) {
88
88
  for (const section of sections) {
89
- this.sectionHeightMap.set(section.id, section.type === 'freehand' ? section.height : section.minHeight);
89
+ this.sectionHeightMap.set(section.id, section.minHeight);
90
90
  }
91
91
  }
92
92