@cntrl-site/sdk-nextjs 0.0.13 → 0.1.1

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.
@@ -2,17 +2,16 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Item = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- const core_1 = require("@cntrl-site/core");
6
5
  const sdk_1 = require("@cntrl-site/sdk");
7
6
  const RectangleItem_1 = require("./items/RectangleItem");
8
7
  const ImageItem_1 = require("./items/ImageItem");
9
8
  const VideoItem_1 = require("./items/VideoItem");
10
9
  const RichTextItem_1 = require("./items/RichTextItem");
11
10
  const itemsMap = {
12
- [core_1.ArticleItemType.Rectangle]: RectangleItem_1.RectangleItem,
13
- [core_1.ArticleItemType.Image]: ImageItem_1.ImageItem,
14
- [core_1.ArticleItemType.Video]: VideoItem_1.VideoItem,
15
- [core_1.ArticleItemType.RichText]: RichTextItem_1.RichTextItem
11
+ [sdk_1.ArticleItemType.Rectangle]: RectangleItem_1.RectangleItem,
12
+ [sdk_1.ArticleItemType.Image]: ImageItem_1.ImageItem,
13
+ [sdk_1.ArticleItemType.Video]: VideoItem_1.VideoItem,
14
+ [sdk_1.ArticleItemType.RichText]: RichTextItem_1.RichTextItem
16
15
  };
17
16
  const noop = () => null;
18
17
  const Item = ({ item, layouts }) => {
@@ -28,8 +27,8 @@ const Item = ({ item, layouts }) => {
28
27
  position: absolute;
29
28
  top: ${area.top * 100}vw;
30
29
  left: ${layoutParams?.fullwidth ? 0 : area.left * 100}vw;
31
- width: ${layoutParams?.fullwidth ? '100vw' : sizingAxis.x === core_1.ArticleItemSizingType.Manual ? `${area.width * 100}vw` : 'auto'};
32
- height: ${sizingAxis.y === core_1.ArticleItemSizingType.Manual ? `${area.height * 100}vw` : 'auto'};
30
+ width: ${layoutParams?.fullwidth ? '100vw' : sizingAxis.x === sdk_1.ArticleItemSizingType.Manual ? `${area.width * 100}vw` : 'auto'};
31
+ height: ${sizingAxis.y === sdk_1.ArticleItemSizingType.Manual ? `${area.height * 100}vw` : 'auto'};
33
32
  z-index: ${area.zIndex};
34
33
  transform: rotate(${area.angle}deg);
35
34
  }
@@ -5,13 +5,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.LayoutStyle = void 0;
7
7
  const jsx_runtime_1 = require("react/jsx-runtime");
8
- const core_1 = require("@cntrl-site/core");
8
+ const sdk_1 = require("@cntrl-site/sdk");
9
9
  // @ts-ignore
10
10
  const style_1 = __importDefault(require("styled-jsx/style"));
11
11
  const LayoutStyle = ({ id, layouts, layoutId, children }) => {
12
12
  const layout = layouts.find(l => l.id === layoutId);
13
13
  return ((0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
14
- ${(0, core_1.getLayoutMediaQuery)(layoutId, layouts)} {
14
+ ${(0, sdk_1.getLayoutMediaQuery)(layoutId, layouts)} {
15
15
  ${children?.(layout)}
16
16
  }
17
17
  ` }));
@@ -6,11 +6,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Page = void 0;
7
7
  const jsx_runtime_1 = require("react/jsx-runtime");
8
8
  const html_react_parser_1 = __importDefault(require("html-react-parser"));
9
+ const sdk_1 = require("@cntrl-site/sdk");
9
10
  const head_1 = __importDefault(require("next/head"));
10
11
  const Article_1 = require("./Article");
11
12
  const Page = ({ article, project, meta }) => {
12
13
  const googleFonts = (0, html_react_parser_1.default)(project.fonts.google);
13
14
  const adobeFonts = (0, html_react_parser_1.default)(project.fonts.adobe);
15
+ const getPageMeta = (projectMeta, pageMeta) => {
16
+ return {
17
+ title: pageMeta.title ? pageMeta.title : projectMeta.title,
18
+ description: pageMeta.description ? pageMeta.description : projectMeta.description,
19
+ keywords: pageMeta.keywords ? pageMeta.keywords : projectMeta.keywords,
20
+ opengraphThumbnail: pageMeta.opengraphThumbnail ? pageMeta.opengraphThumbnail : projectMeta.opengraphThumbnail,
21
+ favicon: projectMeta.favicon
22
+ };
23
+ };
24
+ const priorityMeta = getPageMeta(project.meta, meta);
14
25
  const parsedFonts = {
15
26
  ...(typeof googleFonts === 'object' ? googleFonts : {}),
16
27
  ...(typeof adobeFonts === 'object' ? adobeFonts : {})
@@ -19,14 +30,9 @@ const Page = ({ article, project, meta }) => {
19
30
  const htmlHead = (0, html_react_parser_1.default)(project.html.head);
20
31
  const afterBodyOpen = (0, html_react_parser_1.default)(project.html.afterBodyOpen);
21
32
  const beforeBodyClose = (0, html_react_parser_1.default)(project.html.beforeBodyClose);
22
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(head_1.default, { children: [(0, jsx_runtime_1.jsx)("title", { children: meta.title }), (0, jsx_runtime_1.jsx)("meta", { name: "description", content: meta.description }), (0, jsx_runtime_1.jsx)("meta", { name: "keywords", content: meta.keywords }), (0, jsx_runtime_1.jsx)("meta", { property: "og:image", content: meta.opengraphThumbnail }), (0, jsx_runtime_1.jsx)("link", { rel: "icon", href: meta.favicon }), customFonts.length > 0 && ((0, jsx_runtime_1.jsx)("style", { dangerouslySetInnerHTML: {
23
- __html: customFonts.map((font) => (`
24
- @font-face {
25
- font-family: ${font.name};
26
- font-weight: ${font.weight};
27
- src: ${font.files.map(file => `url('${file.url}') format('${file.type}')`).join(', ')};
28
- }
29
- `)).join('\n')
33
+ const ffGenerator = new sdk_1.FontFaceGenerator(customFonts);
34
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(head_1.default, { children: [(0, jsx_runtime_1.jsx)("title", { children: priorityMeta.title }), (0, jsx_runtime_1.jsx)("meta", { name: "description", content: priorityMeta.description }), (0, jsx_runtime_1.jsx)("meta", { name: "keywords", content: priorityMeta.keywords }), (0, jsx_runtime_1.jsx)("meta", { property: "og:image", content: priorityMeta.opengraphThumbnail }), (0, jsx_runtime_1.jsx)("link", { rel: "icon", href: priorityMeta.favicon }), customFonts.length > 0 && ((0, jsx_runtime_1.jsx)("style", { dangerouslySetInnerHTML: {
35
+ __html: ffGenerator.generate()
30
36
  } })), Object.values(parsedFonts).map((value, i) => {
31
37
  if (!value)
32
38
  return undefined;
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RectangleItem = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- const LinkWrapper_1 = require("../LinkWrapper");
6
5
  const sdk_1 = require("@cntrl-site/sdk");
6
+ const LinkWrapper_1 = require("../LinkWrapper");
7
7
  const RectangleItem = ({ item, layouts }) => ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { url: item.link?.url, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `rectangle-${item.id}` }), (0, jsx_runtime_1.jsx)("style", { jsx: true, children: `
8
8
  ${(0, sdk_1.getLayoutStyles)(layouts, [item.layoutParams], ([{ strokeColor, fillColor, radius, strokeWidth }]) => (`
9
9
  .rectangle-${item.id} {
package/lib/index.js CHANGED
@@ -15,7 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.LayoutStyle = exports.VideoItem = exports.RichTextItem = exports.RectangleItem = exports.ImageItem = exports.Item = exports.Section = exports.Article = exports.Page = exports.RichTextConverter = void 0;
18
- __exportStar(require("@cntrl-site/core"), exports);
19
18
  __exportStar(require("@cntrl-site/sdk"), exports);
20
19
  var RichTextConverter_1 = require("./utils/RichTextConverter");
21
20
  Object.defineProperty(exports, "RichTextConverter", { enumerable: true, get: function () { return RichTextConverter_1.RichTextConverter; } });
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RichTextConverter = exports.FontStyles = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- const core_1 = require("@cntrl-site/core");
5
+ const sdk_1 = require("@cntrl-site/sdk");
6
6
  const LinkWrapper_1 = require("../components/LinkWrapper");
7
7
  exports.FontStyles = {
8
8
  'normal': {},
@@ -19,7 +19,7 @@ class RichTextConverter {
19
19
  return rec;
20
20
  }, {});
21
21
  let currentLineHeight = layouts.reduce((rec, layout) => {
22
- const styles = (0, core_1.getClosestLayoutValue)(richText.layoutParams, layouts, layout.id)?.styles;
22
+ const styles = (0, sdk_1.getClosestLayoutValue)(richText.layoutParams, layouts, layout.id)?.styles;
23
23
  rec[layout.id] = styles?.find(s => s.style === 'LINEHEIGHT')?.value ?? '0';
24
24
  return rec;
25
25
  }, {});
@@ -39,7 +39,7 @@ class RichTextConverter {
39
39
  continue;
40
40
  }
41
41
  const newStylesGroup = layouts.map(({ id: layoutId }) => {
42
- const params = (0, core_1.getClosestLayoutValue)(richText.layoutParams, layouts, layoutId);
42
+ const params = (0, sdk_1.getClosestLayoutValue)(richText.layoutParams, layouts, layoutId);
43
43
  const styles = params.styles
44
44
  .filter(s => s.start >= block.start && s.end <= block.end)
45
45
  .map(s => ({ ...s, start: s.start - block.start, end: s.end - block.start }));
@@ -56,7 +56,7 @@ class RichTextConverter {
56
56
  styleRules[l.id].push(`
57
57
  .${blockClass} {
58
58
  display: ${group.some(g => g.layout === l.id) ? 'block' : 'none'};
59
- text-align: ${(0, core_1.getClosestLayoutValue)(richText.layoutParams, layouts, l.id).textAlign};
59
+ text-align: ${(0, sdk_1.getClosestLayoutValue)(richText.layoutParams, layouts, l.id).textAlign};
60
60
  line-height: 0;
61
61
  }
62
62
  `);
@@ -112,7 +112,7 @@ class RichTextConverter {
112
112
  }
113
113
  }
114
114
  const styles = layouts.map(l => `
115
- ${(0, core_1.getLayoutMediaQuery)(l.id, layouts)} {
115
+ ${(0, sdk_1.getLayoutMediaQuery)(l.id, layouts)} {
116
116
  ${styleRules[l.id].join('\n')}
117
117
  }
118
118
  `).join('\n');
@@ -192,8 +192,8 @@ class RichTextConverter {
192
192
  'LINEHEIGHT': { 'line-height': `${parseFloat(value) * 100}vw` },
193
193
  'LETTERSPACING': { 'letter-spacing': `${parseFloat(value) * 100}vw` },
194
194
  'WORDSPACING': { 'word-spacing': `${parseFloat(value) * 100}vw` },
195
- 'TEXTTRANSFORM': value ? { 'text-transform': value } : { 'text-transform': core_1.TextTransform.None },
196
- 'VERTICALALIGN': value ? { 'vertical-align': value } : { 'vertical-align': core_1.VerticalAlign.Unset },
195
+ 'TEXTTRANSFORM': value ? { 'text-transform': value } : { 'text-transform': sdk_1.TextTransform.None },
196
+ 'VERTICALALIGN': value ? { 'vertical-align': value } : { 'vertical-align': sdk_1.VerticalAlign.Unset },
197
197
  'TEXTDECORATION': { 'text-decoration': value }
198
198
  };
199
199
  const css = map[name];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cntrl-site/sdk-nextjs",
3
- "version": "0.0.13",
3
+ "version": "0.1.1",
4
4
  "description": "SDK for Next.js",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/index.js",
@@ -21,8 +21,7 @@
21
21
  },
22
22
  "homepage": "https://github.com/cntrl-site/sdk-nextjs#readme",
23
23
  "dependencies": {
24
- "@cntrl-site/core": "^1.0.9",
25
- "@cntrl-site/sdk": "^0.0.7",
24
+ "@cntrl-site/sdk": "^0.2.0",
26
25
  "html-react-parser": "^3.0.1",
27
26
  "styled-jsx": "^5.0.2"
28
27
  },
@@ -1,5 +1,5 @@
1
1
  import { FC } from 'react';
2
- import { TArticle, TLayout } from '@cntrl-site/core';
2
+ import { TArticle, TLayout } from '@cntrl-site/sdk';
3
3
  import { Section } from './Section';
4
4
  import { Item } from './Item';
5
5
 
@@ -1,11 +1,11 @@
1
1
  import { ComponentType, FC } from 'react';
2
2
  import {
3
+ getLayoutStyles,
3
4
  ArticleItemType,
4
5
  ArticleItemSizingType as SizingType,
5
6
  TArticleItemAny,
6
7
  TLayout
7
- } from '@cntrl-site/core';
8
- import { getLayoutStyles } from '@cntrl-site/sdk';
8
+ } from '@cntrl-site/sdk';
9
9
  import { RectangleItem } from './items/RectangleItem';
10
10
  import { ImageItem } from './items/ImageItem';
11
11
  import { VideoItem } from './items/VideoItem';
@@ -1,5 +1,5 @@
1
1
  import React, { FC } from 'react';
2
- import { getLayoutMediaQuery, TLayout } from '@cntrl-site/core';
2
+ import { getLayoutMediaQuery, TLayout } from '@cntrl-site/sdk';
3
3
  // @ts-ignore
4
4
  import JSXStyle from 'styled-jsx/style';
5
5
 
@@ -1,6 +1,6 @@
1
1
  import React, { FC } from 'react';
2
2
  import HTMLReactParser, { domToReact } from 'html-react-parser';
3
- import { TArticle, TProject, TMeta } from '@cntrl-site/core';
3
+ import { TArticle, TProject, TMeta, FontFaceGenerator, TPageMeta } from '@cntrl-site/sdk';
4
4
  import Head from 'next/head';
5
5
  import { Article } from './Article';
6
6
 
@@ -13,6 +13,17 @@ interface Props {
13
13
  export const Page: FC<Props> = ({ article, project, meta }) => {
14
14
  const googleFonts: ReturnType<typeof domToReact> = HTMLReactParser(project.fonts.google);
15
15
  const adobeFonts: ReturnType<typeof domToReact> = HTMLReactParser(project.fonts.adobe);
16
+
17
+ const getPageMeta = (projectMeta: TMeta, pageMeta: TPageMeta): TMeta => {
18
+ return {
19
+ title: pageMeta.title ? pageMeta.title : projectMeta.title,
20
+ description: pageMeta.description ? pageMeta.description : projectMeta.description,
21
+ keywords: pageMeta.keywords ? pageMeta.keywords : projectMeta.keywords,
22
+ opengraphThumbnail: pageMeta.opengraphThumbnail ? pageMeta.opengraphThumbnail : projectMeta.opengraphThumbnail,
23
+ favicon: projectMeta.favicon
24
+ };
25
+ };
26
+ const priorityMeta = getPageMeta(project.meta, meta);
16
27
  const parsedFonts = {
17
28
  ...(typeof googleFonts === 'object' ? googleFonts : {}),
18
29
  ...(typeof adobeFonts === 'object' ? adobeFonts : {})
@@ -21,26 +32,19 @@ export const Page: FC<Props> = ({ article, project, meta }) => {
21
32
  const htmlHead = HTMLReactParser(project.html.head);
22
33
  const afterBodyOpen = HTMLReactParser(project.html.afterBodyOpen);
23
34
  const beforeBodyClose = HTMLReactParser(project.html.beforeBodyClose);
35
+ const ffGenerator = new FontFaceGenerator(customFonts);
24
36
  return (
25
37
  <>
26
38
  <Head>
27
- <title>{meta.title}</title>
28
- <meta name="description" content={meta.description} />
29
- <meta name="keywords" content={meta.keywords} />
30
- <meta property="og:image" content={meta.opengraphThumbnail} />
31
- <link rel="icon" href={meta.favicon} />
39
+ <title>{priorityMeta.title}</title>
40
+ <meta name="description" content={priorityMeta.description} />
41
+ <meta name="keywords" content={priorityMeta.keywords} />
42
+ <meta property="og:image" content={priorityMeta.opengraphThumbnail} />
43
+ <link rel="icon" href={priorityMeta.favicon} />
32
44
  {customFonts.length > 0 && (
33
45
  <style
34
46
  dangerouslySetInnerHTML={{
35
- __html: customFonts.map((font) => (
36
- `
37
- @font-face {
38
- font-family: ${font.name};
39
- font-weight: ${font.weight};
40
- src: ${font.files.map(file => `url('${file.url}') format('${file.type}')`).join(', ')};
41
- }
42
- `
43
- )).join('\n')
47
+ __html: ffGenerator.generate()
44
48
  }}
45
49
  />
46
50
  )}
@@ -1,6 +1,5 @@
1
1
  import { FC, ReactElement } from 'react';
2
- import { TLayout, TArticleSection } from '@cntrl-site/core';
3
- import { getLayoutStyles } from '@cntrl-site/sdk';
2
+ import { getLayoutStyles, TLayout, TArticleSection } from '@cntrl-site/sdk';
4
3
 
5
4
  type SectionChild = ReactElement<any, any>;
6
5
 
@@ -1,6 +1,5 @@
1
1
  import { FC } from 'react';
2
- import { TImageItem } from '@cntrl-site/core';
3
- import { getLayoutStyles } from '@cntrl-site/sdk';
2
+ import { getLayoutStyles, TImageItem } from '@cntrl-site/sdk';
4
3
  import { ItemProps } from '../Item';
5
4
  import { LinkWrapper } from '../LinkWrapper';
6
5
 
@@ -1,8 +1,7 @@
1
1
  import { FC } from 'react';
2
- import { TRectangleItem } from '@cntrl-site/core';
2
+ import { TRectangleItem, getLayoutStyles } from '@cntrl-site/sdk';
3
3
  import { ItemProps } from '../Item';
4
4
  import { LinkWrapper } from '../LinkWrapper';
5
- import { getLayoutStyles } from '@cntrl-site/sdk';
6
5
 
7
6
  export const RectangleItem: FC<ItemProps<TRectangleItem>> = ({ item, layouts }) => (
8
7
  <LinkWrapper url={item.link?.url}>
@@ -1,5 +1,5 @@
1
1
  import { FC } from 'react';
2
- import { TRichTextItem } from '@cntrl-site/core';
2
+ import { TRichTextItem } from '@cntrl-site/sdk';
3
3
  //@ts-ignore
4
4
  import JSXStyle from 'styled-jsx/style';
5
5
  import { ItemProps } from '../Item';
@@ -1,5 +1,5 @@
1
1
  import { FC } from 'react';
2
- import { TVideoItem } from '@cntrl-site/core';
2
+ import { TVideoItem } from '@cntrl-site/sdk';
3
3
  import { ItemProps } from '../Item';
4
4
  import { LinkWrapper } from '../LinkWrapper';
5
5
  import { getLayoutStyles } from '@cntrl-site/sdk';
package/src/index.ts CHANGED
@@ -1,4 +1,3 @@
1
- export * from '@cntrl-site/core';
2
1
  export * from '@cntrl-site/sdk';
3
2
 
4
3
  export { RichTextConverter } from './utils/RichTextConverter';
@@ -7,7 +7,7 @@ import {
7
7
  VerticalAlign,
8
8
  getClosestLayoutValue,
9
9
  getLayoutMediaQuery
10
- } from '@cntrl-site/core';
10
+ } from '@cntrl-site/sdk';
11
11
  import { LinkWrapper } from '../components/LinkWrapper';
12
12
 
13
13
  interface StyleGroup {
@@ -1,15 +0,0 @@
1
- <component name="InspectionProjectProfileManager">
2
- <profile version="1.0">
3
- <option name="myName" value="Project Default" />
4
- <inspection_tool class="HtmlUnknownAttribute" enabled="true" level="WARNING" enabled_by_default="true">
5
- <option name="myValues">
6
- <value>
7
- <list size="1">
8
- <item index="0" class="java.lang.String" itemvalue="jsx" />
9
- </list>
10
- </value>
11
- </option>
12
- <option name="myCustomValuesEnabled" value="true" />
13
- </inspection_tool>
14
- </profile>
15
- </component>
Binary file