@kids-reporter/draft-renderer 0.2.1 → 0.3.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.
@@ -8,6 +8,7 @@ exports.atomicBlockRenderer = atomicBlockRenderer;
8
8
  var _blockRenderers = require("./block-renderers");
9
9
 
10
10
  const {
11
+ BlockquoteInArticleBody,
11
12
  EmbeddedCodeInArticleBody,
12
13
  ImageInArticleBody,
13
14
  InfoBoxBlock,
@@ -20,14 +21,21 @@ const AtomicBlock = props => {
20
21
  const entityData = entity.getData();
21
22
 
22
23
  switch (entityType) {
23
- case 'image':
24
+ case 'BLOCKQUOTE':
25
+ {
26
+ return BlockquoteInArticleBody({
27
+ data: entityData
28
+ });
29
+ }
30
+
31
+ case 'IMAGE':
24
32
  {
25
33
  return ImageInArticleBody({
26
34
  data: entityData
27
35
  });
28
36
  }
29
37
 
30
- case 'slideshow':
38
+ case 'SLIDESHOW':
31
39
  {
32
40
  return SlideshowInArticleBody({
33
41
  data: entityData
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.BlockquoteInArticleBody = BlockquoteInArticleBody;
7
+ exports.BorderLeftBlockquote = BorderLeftBlockquote;
8
+ exports.QuoteLeftBlockquote = QuoteLeftBlockquote;
9
+
10
+ var _react = _interopRequireDefault(require("react"));
11
+
12
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
16
+ const BorderLeftContainer = _styledComponents.default.blockquote`
17
+ margin: 0;
18
+ padding-left: 30px;
19
+ border-left: 4px solid #27b5f7;
20
+ `;
21
+
22
+ function BorderLeftBlockquote({
23
+ text
24
+ }) {
25
+ return /*#__PURE__*/_react.default.createElement(BorderLeftContainer, null, /*#__PURE__*/_react.default.createElement(QuoteText, null, text));
26
+ }
27
+
28
+ const QuoteLeftContainer = _styledComponents.default.blockquote`
29
+ margin: 0;
30
+ padding: 40px;
31
+ background-color: #f4f4f4;
32
+ display: flex;
33
+ border-radius: 20px;
34
+ `;
35
+ const QuoteText = _styledComponents.default.p`
36
+ margin: 0;
37
+ word-break: break-word;
38
+ font-size: 18px;
39
+ font-weight: 500;
40
+ letter-spacing: 0.9px;
41
+ line-height: 2;
42
+ color: #3a4f66;
43
+ `;
44
+ const SvgBlock = _styledComponents.default.div`
45
+ margin-right: 16px;
46
+
47
+ svg {
48
+ width: 36px;
49
+ }
50
+ `;
51
+
52
+ function QuoteSvg() {
53
+ return /*#__PURE__*/_react.default.createElement(SvgBlock, null, /*#__PURE__*/_react.default.createElement("svg", {
54
+ fill: "#27B5F7",
55
+ xmlns: "http://www.w3.org/2000/svg",
56
+ viewBox: "0 0 50 50",
57
+ "aria-hidden": "true"
58
+ }, /*#__PURE__*/_react.default.createElement("path", {
59
+ d: "M9.4 14.6c-2.4 2.9-3.6 5.9-3.6 8.9 0 1.3.2 2.4.5 3.3 1.8-1.4 3.8-2.1 6-2.1 2.9 0 5.3.9 7.3 2.7 2 1.8 3 4.2 3 7.3 0 1.9-.5 3.6-1.4 5.1-.9 1.5-2.2 2.7-3.8 3.6s-3.3 1.3-5.1 1.3c-4.1 0-7.3-1.6-9.5-4.9C.9 36.9 0 33.5 0 29.4c0-5.2 1.4-9.9 4.1-14 2.8-4.1 6.9-7.5 12.5-10l1.5 2.8c-3.3 1.3-6.2 3.5-8.7 6.4zm27.5 0c-2.4 2.9-3.6 5.9-3.6 8.9 0 1.3.2 2.4.5 3.3 1.8-1.4 3.8-2.1 6-2.1 2.9 0 5.4.9 7.4 2.7 2 1.8 3 4.2 3 7.3 0 2.8-1 5.2-3 7.1-2 1.9-4.4 2.9-7.3 2.9-4.1 0-7.3-1.6-9.5-4.9-1.8-2.7-2.8-6.2-2.8-10.3 0-5.2 1.4-9.9 4.1-14 2.8-4.1 6.9-7.5 12.5-10l1.5 2.8c-3.5 1.2-6.4 3.4-8.8 6.3z"
60
+ })));
61
+ }
62
+
63
+ function QuoteLeftBlockquote({
64
+ text
65
+ }) {
66
+ return /*#__PURE__*/_react.default.createElement(QuoteLeftContainer, null, /*#__PURE__*/_react.default.createElement(QuoteSvg, null), /*#__PURE__*/_react.default.createElement(QuoteText, null, text));
67
+ }
68
+
69
+ const ArticleBodyContainer = _styledComponents.default.div`
70
+ max-width: 700px;
71
+ margin: 0 auto 27px auto;
72
+ `;
73
+ var BlockquoteType;
74
+
75
+ (function (BlockquoteType) {
76
+ BlockquoteType["borderLeft"] = "border_left";
77
+ BlockquoteType["quoteLeft"] = "quote_left";
78
+ })(BlockquoteType || (BlockquoteType = {}));
79
+
80
+ function BlockquoteInArticleBody({
81
+ className = '',
82
+ data = {
83
+ type: BlockquoteType.borderLeft,
84
+ text: ''
85
+ }
86
+ }) {
87
+ const {
88
+ type,
89
+ text
90
+ } = data;
91
+ const BlockQuote = type === BlockquoteType.quoteLeft ? QuoteLeftBlockquote : BorderLeftBlockquote;
92
+ return /*#__PURE__*/_react.default.createElement(ArticleBodyContainer, {
93
+ className: className
94
+ }, /*#__PURE__*/_react.default.createElement(BlockQuote, {
95
+ text: text
96
+ }));
97
+ }
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.blockRenderers = void 0;
7
7
 
8
+ var _blockquote = require("./blockquote");
9
+
8
10
  var _embeddedCodeBlock = require("./embedded-code-block");
9
11
 
10
12
  var _imageBlock = require("./image-block");
@@ -14,11 +16,12 @@ var _infoBoxBlock = require("./info-box-block");
14
16
  var _slideshowBlock = require("./slideshow-block");
15
17
 
16
18
  const blockRenderers = {
19
+ BlockquoteInArticleBody: _blockquote.BlockquoteInArticleBody,
17
20
  EmbeddedCodeBlock: _embeddedCodeBlock.EmbeddedCodeBlock,
18
21
  EmbeddedCodeInArticleBody: _embeddedCodeBlock.EmbeddedCodeInArticleBody,
19
22
  ImageBlock: _imageBlock.ImageBlock,
20
23
  ImageInArticleBody: _imageBlock.ImageInArticleBody,
21
- InfoBoxBlock: _infoBoxBlock.InfoBoxBlock,
24
+ InfoBoxInArticleBody: _infoBoxBlock.InfoBoxInArticleBody,
22
25
  SlideshowBlock: _slideshowBlock.SlideshowBlock,
23
26
  SlideshowInArticleBody: _slideshowBlock.SlideshowInArticleBody
24
27
  };
@@ -3,9 +3,105 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.InfoBoxBlock = InfoBoxBlock;
6
+ exports.InfoBoxInArticleBody = InfoBoxInArticleBody;
7
7
 
8
- /* eslint-disable */
9
- function InfoBoxBlock(props) {
8
+ var _draftJs = require("draft-js");
9
+
10
+ var _react = _interopRequireDefault(require("react"));
11
+
12
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
13
+
14
+ var _index = require("../entity-decorators/index");
15
+
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+
18
+ var InfoBoxType;
19
+
20
+ (function (InfoBoxType) {
21
+ InfoBoxType["newsChargeStation"] = "news-charge-station";
22
+ InfoBoxType["headerBorder"] = "with-header-border";
23
+ InfoBoxType["boxBorder"] = "with-box-border";
24
+ })(InfoBoxType || (InfoBoxType = {}));
25
+
26
+ var InfoBoxLabel;
27
+
28
+ (function (InfoBoxLabel) {
29
+ InfoBoxLabel["newsChargeStation"] = "\u65B0\u805E\u5145\u96FB\u5668";
30
+ InfoBoxLabel["headerBorder"] = "\u7121\u908A\u6846\u677F";
31
+ InfoBoxLabel["boxBorder"] = "\u6709\u908A\u6846\u677F";
32
+ })(InfoBoxLabel || (InfoBoxLabel = {}));
33
+
34
+ const NewsChargeStationContainer = _styledComponents.default.div`
35
+ padding: 40px;
36
+ background-color: #fffcf4;
37
+ position: relative;
38
+ border-radius: 30px;
39
+
40
+ &::before {
41
+ content: '';
42
+ width: 300px;
43
+ height: 80px;
44
+ background-image: url(https://kids.twreporter.org/wp-content/themes/blocksy-child/assets/js/components/rpjr-box/newsChargeStation.svg);
45
+ position: absolute;
46
+ top: -40px;
47
+ left: 50%;
48
+ transform: translateX(-50%);
49
+ }
50
+ `;
51
+
52
+ function NewsChargeStation({
53
+ children
54
+ }) {
55
+ return /*#__PURE__*/_react.default.createElement(NewsChargeStationContainer, null, children);
56
+ }
57
+
58
+ function HeaderBorder() {
59
+ return null;
60
+ }
61
+
62
+ function BoxBorder() {
10
63
  return null;
64
+ }
65
+
66
+ const ArticleBodyContainer = _styledComponents.default.div`
67
+ max-width: 700px;
68
+ padding: 40px;
69
+ `;
70
+
71
+ function InfoBoxInArticleBody({
72
+ className,
73
+ data
74
+ }) {
75
+ const {
76
+ type,
77
+ rawContentState
78
+ } = data;
79
+ const contentState = (0, _draftJs.convertFromRaw)(rawContentState);
80
+
81
+ const editorState = _draftJs.EditorState.createWithContent(contentState, _index.decorators);
82
+
83
+ let Component;
84
+
85
+ switch (type) {
86
+ case InfoBoxType.boxBorder:
87
+ {
88
+ Component = BoxBorder;
89
+ break;
90
+ }
91
+
92
+ case InfoBoxType.headerBorder:
93
+ {
94
+ Component = HeaderBorder;
95
+ break;
96
+ }
97
+
98
+ case InfoBoxType.newsChargeStation:
99
+ default:
100
+ {
101
+ Component = NewsChargeStation;
102
+ break;
103
+ }
104
+ }
105
+
106
+ return /*#__PURE__*/_react.default.createElement(Component, null, "test");
11
107
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kids-reporter/draft-renderer",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {