@cntrl-site/sdk-nextjs 0.1.8 → 0.2.0

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.
@@ -0,0 +1,5 @@
1
+ <component name="ProjectCodeStyleConfiguration">
2
+ <state>
3
+ <option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
4
+ </state>
5
+ </component>
@@ -7,11 +7,13 @@ const RectangleItem_1 = require("./items/RectangleItem");
7
7
  const ImageItem_1 = require("./items/ImageItem");
8
8
  const VideoItem_1 = require("./items/VideoItem");
9
9
  const RichTextItem_1 = require("./items/RichTextItem");
10
+ const VimeoEmbed_1 = require("./items/VimeoEmbed");
10
11
  const itemsMap = {
11
12
  [sdk_1.ArticleItemType.Rectangle]: RectangleItem_1.RectangleItem,
12
13
  [sdk_1.ArticleItemType.Image]: ImageItem_1.ImageItem,
13
14
  [sdk_1.ArticleItemType.Video]: VideoItem_1.VideoItem,
14
- [sdk_1.ArticleItemType.RichText]: RichTextItem_1.RichTextItem
15
+ [sdk_1.ArticleItemType.RichText]: RichTextItem_1.RichTextItem,
16
+ [sdk_1.ArticleItemType.VimeoEmbed]: VimeoEmbed_1.VimeoEmbed
15
17
  };
16
18
  const noop = () => null;
17
19
  const Item = ({ item, layouts }) => {
@@ -22,12 +24,12 @@ const Item = ({ item, layouts }) => {
22
24
  const sizingAxis = parseSizing(item.commonParams.sizing);
23
25
  const ItemComponent = itemsMap[item.type] || noop;
24
26
  return ((0, jsx_runtime_1.jsxs)("div", { className: `item-${item.id}`, children: [(0, jsx_runtime_1.jsx)(ItemComponent, { item: item, layouts: layouts }), (0, jsx_runtime_1.jsx)("style", { jsx: true, children: `
25
- ${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams]) => (`
27
+ ${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area]) => (`
26
28
  .item-${item.id} {
27
29
  position: absolute;
28
30
  top: ${area.top * 100}vw;
29
- left: ${layoutParams?.fullwidth ? 0 : area.left * 100}vw;
30
- width: ${layoutParams?.fullwidth ? '100vw' : sizingAxis.x === sdk_1.ArticleItemSizingType.Manual ? `${area.width * 100}vw` : 'auto'};
31
+ left: ${area.left * 100}vw;
32
+ width: ${sizingAxis.x === sdk_1.ArticleItemSizingType.Manual ? `${area.width * 100}vw` : 'auto'};
31
33
  height: ${sizingAxis.y === sdk_1.ArticleItemSizingType.Manual ? `${area.height * 100}vw` : 'auto'};
32
34
  z-index: ${area.zIndex};
33
35
  transform: rotate(${area.angle}deg);
@@ -3,10 +3,28 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Section = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const sdk_1 = require("@cntrl-site/sdk");
6
- const Section = ({ section, layouts, children }) => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `section-${section.id}`, children: children }), (0, jsx_runtime_1.jsx)("style", { jsx: true, children: `
6
+ const Section = ({ section, layouts, children }) => {
7
+ const getSectionVisibilityStyles = () => {
8
+ return layouts
9
+ .sort((a, b) => a.startsWith - b.startsWith)
10
+ .reduce((acc, layout) => {
11
+ const isHidden = section.hidden[layout.id];
12
+ return `
13
+ ${acc}
14
+ ${(0, sdk_1.getLayoutMediaQuery)(layout.id, layouts)} {
15
+ .section-${section.id} {
16
+ display: ${isHidden ? 'none' : 'block'};
17
+ }
18
+ }`;
19
+ }, '');
20
+ };
21
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `section-${section.id}`, children: children }), (0, jsx_runtime_1.jsx)("style", { jsx: true, children: `
7
22
  ${(0, sdk_1.getLayoutStyles)(layouts, [section.height], ([height]) => (`
8
23
  .section-${section.id} {
9
24
  height: ${height * 100}vw;
25
+ position: relative;
10
26
  }`))}
27
+ ${getSectionVisibilityStyles()}
11
28
  ` })] }));
29
+ };
12
30
  exports.Section = Section;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VimeoEmbed = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const VimeoEmbed = () => (
6
+ // TODO
7
+ (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}));
8
+ exports.VimeoEmbed = VimeoEmbed;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cntrl-site/sdk-nextjs",
3
- "version": "0.1.8",
3
+ "version": "0.2.0",
4
4
  "description": "SDK for Next.js",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/index.js",
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "homepage": "https://github.com/cntrl-site/sdk-nextjs#readme",
23
23
  "dependencies": {
24
- "@cntrl-site/sdk": "^0.2.6",
24
+ "@cntrl-site/sdk": "^0.2.7",
25
25
  "html-react-parser": "^3.0.1",
26
26
  "styled-jsx": "^5.0.2"
27
27
  },
@@ -10,6 +10,7 @@ import { RectangleItem } from './items/RectangleItem';
10
10
  import { ImageItem } from './items/ImageItem';
11
11
  import { VideoItem } from './items/VideoItem';
12
12
  import { RichTextItem } from './items/RichTextItem';
13
+ import { VimeoEmbed } from './items/VimeoEmbed';
13
14
 
14
15
  export interface ItemProps<I extends TArticleItemAny> {
15
16
  layouts: TLayout[];
@@ -20,7 +21,8 @@ const itemsMap: Record<ArticleItemType, ComponentType<ItemProps<any>>> = {
20
21
  [ArticleItemType.Rectangle]: RectangleItem,
21
22
  [ArticleItemType.Image]: ImageItem,
22
23
  [ArticleItemType.Video]: VideoItem,
23
- [ArticleItemType.RichText]: RichTextItem
24
+ [ArticleItemType.RichText]: RichTextItem,
25
+ [ArticleItemType.VimeoEmbed]: VimeoEmbed
24
26
  };
25
27
 
26
28
  const noop = () => null;
@@ -38,12 +40,12 @@ export const Item: FC<ItemProps<TArticleItemAny>> = ({ item, layouts }) => {
38
40
  <div className={`item-${item.id}`}>
39
41
  <ItemComponent item={item} layouts={layouts} />
40
42
  <style jsx>{`
41
- ${getLayoutStyles(layouts, layoutValues, ([area, layoutParams]) => (`
43
+ ${getLayoutStyles(layouts, layoutValues, ([area]) => (`
42
44
  .item-${item.id} {
43
45
  position: absolute;
44
46
  top: ${area.top * 100}vw;
45
- left: ${layoutParams?.fullwidth ? 0 : area.left * 100}vw;
46
- width: ${layoutParams?.fullwidth ? '100vw' : sizingAxis.x === SizingType.Manual ? `${area.width * 100}vw` : 'auto'};
47
+ left: ${area.left * 100}vw;
48
+ width: ${sizingAxis.x === SizingType.Manual ? `${area.width * 100}vw` : 'auto'};
47
49
  height: ${sizingAxis.y === SizingType.Manual ? `${area.height * 100}vw` : 'auto'};
48
50
  z-index: ${area.zIndex};
49
51
  transform: rotate(${area.angle}deg);
@@ -1,5 +1,5 @@
1
1
  import { FC, ReactElement } from 'react';
2
- import { getLayoutStyles, TLayout, TArticleSection } from '@cntrl-site/sdk';
2
+ import { getLayoutMediaQuery, getLayoutStyles, TArticleSection, TLayout } from '@cntrl-site/sdk';
3
3
 
4
4
  type SectionChild = ReactElement<any, any>;
5
5
 
@@ -9,19 +9,38 @@ interface Props {
9
9
  children: SectionChild[];
10
10
  }
11
11
 
12
- export const Section: FC<Props> = ({ section, layouts, children }) => (
13
- <>
14
- <div className={`section-${section.id}`}>
15
- {children}
16
- </div>
17
- <style jsx>{`
12
+ export const Section: FC<Props> = ({ section, layouts, children }) => {
13
+ const getSectionVisibilityStyles = () => {
14
+ return layouts
15
+ .sort((a, b) => a.startsWith - b.startsWith)
16
+ .reduce((acc, layout) => {
17
+ const isHidden = section.hidden[layout.id];
18
+ return `
19
+ ${acc}
20
+ ${getLayoutMediaQuery(layout.id, layouts)} {
21
+ .section-${section.id} {
22
+ display: ${isHidden ? 'none': 'block'};
23
+ }
24
+ }`;
25
+ }, '');
26
+ };
27
+
28
+ return (
29
+ <>
30
+ <div className={`section-${section.id}`}>
31
+ {children}
32
+ </div>
33
+ <style jsx>{`
18
34
  ${
19
- getLayoutStyles(layouts, [section.height], ([height]) => (`
35
+ getLayoutStyles(layouts, [section.height], ([height]) => (`
20
36
  .section-${section.id} {
21
37
  height: ${height * 100}vw;
38
+ position: relative;
22
39
  }`
23
- ))
24
- }
40
+ ))
41
+ }
42
+ ${getSectionVisibilityStyles()}
25
43
  `}</style>
26
- </>
27
- );
44
+ </>
45
+ );
46
+ };
@@ -0,0 +1,9 @@
1
+ import { FC } from 'react';
2
+ import { ItemProps } from '../Item';
3
+ import { VimeoEmbedItem } from '@cntrl-site/core/src/article/ArticleItems';
4
+
5
+ export const VimeoEmbed:FC<ItemProps<VimeoEmbedItem>> = () => (
6
+ // TODO
7
+ <>
8
+ </>
9
+ )