@kids-reporter/draft-renderer 0.4.21 → 0.4.23

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.
@@ -14,15 +14,22 @@ const HeadingForAnnotation = (0, _styledComponents.default)(_articleContent.Head
14
14
  margin: 0 auto 27px auto;
15
15
  `;
16
16
  const ListForAnnotation = (0, _styledComponents.default)(_articleContent.List)`
17
+ color: #494949;
18
+
17
19
  li {
18
- font-size: 16px;
20
+ font-size: ${({
21
+ theme
22
+ }) => (theme === null || theme === void 0 ? void 0 : theme.fontSizeLevel) === 'normal' ? '16px' : '20px'};
19
23
  }
20
24
  `;
21
25
  const ParagraphForAnnotation = (0, _styledComponents.default)(_articleContent.Paragraph)`
22
26
  /* overwrite css */
23
- font-size: 16px;
27
+ font-size: ${({
28
+ theme
29
+ }) => (theme === null || theme === void 0 ? void 0 : theme.fontSizeLevel) === 'normal' ? '16px' : '20px'};
24
30
  font-weight: 400;
25
31
  margin-bottom: 20px;
32
+ color: #494949;
26
33
  `;
27
34
  const _blockRenderMapForAnnotation = _immutable.default.Map({
28
35
  atomic: {
@@ -11,6 +11,7 @@ var _draftJs = require("draft-js");
11
11
  var _articleContent = require("./article-content");
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
13
  const ParagraphForIntroduction = (0, _styledComponents.default)(_articleContent.Paragraph)`
14
+ font-size: 20px;
14
15
  color: #575757;
15
16
  `;
16
17
  const ListForIntroduction = (0, _styledComponents.default)(_articleContent.List)`
@@ -13,7 +13,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
13
13
  const Paragraph = _styledComponents.default.div`
14
14
  width: 100%;
15
15
  max-width: 700px;
16
- font-size: 18px;
16
+ font-size: ${({
17
+ theme
18
+ }) => (theme === null || theme === void 0 ? void 0 : theme.fontSizeLevel) === 'normal' ? '18px' : '22px'};
17
19
  font-weight: 400;
18
20
  color: #3a4f66;
19
21
  letter-spacing: 0.9px;
@@ -46,19 +48,27 @@ const Heading = _styledComponents.default.div`
46
48
  }
47
49
 
48
50
  h2 {
49
- font-size: 35px;
51
+ font-size: ${({
52
+ theme
53
+ }) => (theme === null || theme === void 0 ? void 0 : theme.fontSizeLevel) === 'normal' ? '35px' : '39px'};
50
54
  }
51
55
 
52
56
  h3 {
53
- font-size: 30px;
57
+ font-size: ${({
58
+ theme
59
+ }) => (theme === null || theme === void 0 ? void 0 : theme.fontSizeLevel) === 'normal' ? '30px' : '34px'};
54
60
  }
55
61
 
56
62
  h4 {
57
- font-size: 25px;
63
+ font-size: ${({
64
+ theme
65
+ }) => (theme === null || theme === void 0 ? void 0 : theme.fontSizeLevel) === 'normal' ? '25px' : '29px'};
58
66
  }
59
67
 
60
68
  h5 {
61
- font-size: 20px;
69
+ font-size: ${({
70
+ theme
71
+ }) => (theme === null || theme === void 0 ? void 0 : theme.fontSizeLevel) === 'normal' ? '20px' : '24px'};
62
72
  }
63
73
 
64
74
  ${_mediaQuery.mediaQuery.smallOnly} {
@@ -71,7 +81,9 @@ const List = _styledComponents.default.ol`
71
81
  width: 100%;
72
82
  max-width: 700px;
73
83
  margin: 0 auto 27px auto;
74
- font-size: 18px;
84
+ font-size: ${({
85
+ theme
86
+ }) => (theme === null || theme === void 0 ? void 0 : theme.fontSizeLevel) === 'normal' ? '18px' : '22px'};
75
87
  line-height: 2;
76
88
  letter-spacing: 0.9px;
77
89
  color: #3a4f66;
@@ -13,19 +13,34 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
13
13
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
15
  const HeadingForInfoBox = (0, _styledComponents.default)(_articleContent.Heading)`
16
- margin-top: 30px;
17
- margin-bottom: 30px;
16
+ margin-top: 0px;
17
+ margin-bottom: 20px;
18
+
19
+ h4 {
20
+ font-size: 24px;
21
+ }
18
22
  `;
19
23
  const ListForInfoBox = (0, _styledComponents.default)(_articleContent.List)`
24
+ padding-left: 2rem;
25
+ margin-bottom: 20px;
26
+
27
+ color: #232323;
20
28
  li {
21
- font-size: 16px;
29
+ font-size: ${({
30
+ theme
31
+ }) => (theme === null || theme === void 0 ? void 0 : theme.fontSizeLevel) === 'normal' ? '16px' : '20px'};
32
+ line-height: 1.5;
22
33
  }
23
34
  `;
24
35
  const ParagraphForInfoBox = (0, _styledComponents.default)(_articleContent.Paragraph)`
25
36
  /* overwrite css */
26
- font-size: 16px;
37
+ font-size: ${({
38
+ theme
39
+ }) => (theme === null || theme === void 0 ? void 0 : theme.fontSizeLevel) === 'normal' ? '16px' : '20px'};
27
40
  font-weight: 400;
28
41
  margin-bottom: 20px;
42
+ line-height: 1.5;
43
+ color: #232323;
29
44
  `;
30
45
  const Atomic = _styledComponents.default.div`
31
46
  /* reset figure default styles */
@@ -29,15 +29,21 @@ const QuoteLeftContainer = _styledComponents.default.blockquote`
29
29
  background-color: #f4f4f4;
30
30
  display: flex;
31
31
  border-radius: 20px;
32
+
33
+ ${_mediaQuery.mediaQuery.smallOnly} {
34
+ padding: 20px;
35
+ }
32
36
  `;
33
37
  const QuoteText = _styledComponents.default.p`
34
38
  margin: 0;
35
39
  word-break: break-word;
36
- font-size: 18px;
40
+ font-size: ${({
41
+ theme
42
+ }) => (theme === null || theme === void 0 ? void 0 : theme.fontSizeLevel) === 'normal' ? '18px' : '22px'};
37
43
  font-weight: 500;
38
44
  letter-spacing: 0.9px;
39
45
  line-height: 2;
40
- color: #3a4f66;
46
+ color: #232323;
41
47
  `;
42
48
  const SvgBlock = _styledComponents.default.div`
43
49
  margin-right: 16px;
@@ -25,7 +25,9 @@ const Block = _styledComponents.default.div`
25
25
  `;
26
26
  exports.Block = Block;
27
27
  const Caption = _styledComponents.default.div`
28
- font-size: 14px;
28
+ font-size: ${({
29
+ theme
30
+ }) => (theme === null || theme === void 0 ? void 0 : theme.fontSizeLevel) === 'normal' ? '14px' : '18px'};
29
31
  line-height: 1.43;
30
32
  letter-spacing: 0.4px;
31
33
  color: #808080;
@@ -16,7 +16,9 @@ const Figure = _styledComponents.default.figure`
16
16
  const FigureCaption = _styledComponents.default.figcaption`
17
17
  width: fit-content;
18
18
  max-width: 100%;
19
- font-size: 14px;
19
+ font-size: ${({
20
+ theme
21
+ }) => (theme === null || theme === void 0 ? void 0 : theme.fontSizeLevel) === 'normal' ? '14px' : '18px'};
20
22
  margin-left: auto;
21
23
  margin-right: auto;
22
24
  margin-top: 0.5em;
@@ -22,12 +22,12 @@ var InfoBoxTypeEnum = /*#__PURE__*/function (InfoBoxTypeEnum) {
22
22
  return InfoBoxTypeEnum;
23
23
  }(InfoBoxTypeEnum || {});
24
24
  const containerStyles = (0, _styledComponents.css)`
25
- padding: 40px;
25
+ padding: 40px 40px 20px 40px;
26
26
  border-radius: 30px;
27
27
  position: relative;
28
28
 
29
29
  ${_mediaQuery.mediaQuery.smallOnly} {
30
- padding: 20px;
30
+ padding: 20px 20px 0px 20px;
31
31
  }
32
32
  `;
33
33
  const NewsChargeStationContainer = _styledComponents.default.div`
@@ -67,7 +67,9 @@ const Caption = _styledComponents.default.figcaption`
67
67
  line-height: 1.36;
68
68
  letter-spacing: 0.5px;
69
69
  font-weight: normal;
70
- font-size: 14px;
70
+ font-size: ${({
71
+ theme
72
+ }) => (theme === null || theme === void 0 ? void 0 : theme.fontSizeLevel) === 'normal' ? '14px' : '18px'};
71
73
  margin-bottom: 30px;
72
74
 
73
75
  /* border-bottom of caption */
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.fontColorPrefix = exports.default = exports.customStyleFn = exports.bgColorPrefix = void 0;
7
+ const bgColorPrefix = 'BACKGROUND_COLOR_';
8
+ exports.bgColorPrefix = bgColorPrefix;
9
+ const fontColorPrefix = 'FONT_COLOR_';
10
+ exports.fontColorPrefix = fontColorPrefix;
11
+ const customStyleFn = style => {
12
+ return style.reduce((cssObject = {}, styleName) => {
13
+ if (styleName !== null && styleName !== void 0 && styleName.startsWith(bgColorPrefix)) {
14
+ cssObject['backgroundColor'] = styleName.split(bgColorPrefix)[1];
15
+ }
16
+ if (styleName !== null && styleName !== void 0 && styleName.startsWith(fontColorPrefix)) {
17
+ cssObject['color'] = styleName.split(fontColorPrefix)[1];
18
+ }
19
+ return cssObject;
20
+ }, {});
21
+ };
22
+ exports.customStyleFn = customStyleFn;
23
+ var _default = customStyleFn;
24
+ exports.default = _default;
@@ -10,29 +10,38 @@ exports.ProjectContentDraftRenderer = ProjectContentDraftRenderer;
10
10
  var _react = _interopRequireDefault(require("react"));
11
11
  var _index = _interopRequireDefault(require("./block-render-maps/index"));
12
12
  var _draftJs = require("draft-js");
13
- var _blockRendererFn = require("./block-renderer-fn");
14
- var _index2 = require("./entity-decorators/index");
15
- var _index3 = require("./utils/index");
13
+ var _index2 = require("./utils/index");
16
14
  var _styledComponents = require("styled-components");
15
+ var _blockRendererFn = require("./block-renderer-fn");
16
+ var _customStyleFn = require("./custom-style-fn");
17
+ var _index3 = require("./entity-decorators/index");
17
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
19
  const blockRendererFn = block => {
19
20
  const atomicBlockObj = (0, _blockRendererFn.atomicBlockRenderer)(block);
20
21
  return atomicBlockObj;
21
22
  };
23
+ var FontSizeLevel = /*#__PURE__*/function (FontSizeLevel) {
24
+ FontSizeLevel["NORMAL"] = "normal";
25
+ FontSizeLevel["LARGE"] = "large";
26
+ return FontSizeLevel;
27
+ }(FontSizeLevel || {});
22
28
  function DraftRenderer({
23
29
  rawContentState,
24
- themeColor = _index3.ThemeColorEnum.RED
30
+ themeColor = _index2.ThemeColorEnum.RED,
31
+ fontSizeLevel = FontSizeLevel.NORMAL
25
32
  }) {
26
33
  const contentState = (0, _draftJs.convertFromRaw)(rawContentState);
27
- const editorState = _draftJs.EditorState.createWithContent(contentState, _index2.decorator);
34
+ const editorState = _draftJs.EditorState.createWithContent(contentState, _index3.decorator);
28
35
  return /*#__PURE__*/_react.default.createElement(_styledComponents.ThemeProvider, {
29
36
  theme: {
30
- themeColor
37
+ themeColor,
38
+ fontSizeLevel
31
39
  }
32
40
  }, /*#__PURE__*/_react.default.createElement(_draftJs.Editor, {
33
41
  editorState: editorState,
34
42
  blockRenderMap: _index.default.content,
35
43
  blockRendererFn: blockRendererFn,
44
+ customStyleFn: _customStyleFn.customStyleFn,
36
45
  readOnly: true
37
46
  // eslint-disable-next-line @typescript-eslint/no-empty-function
38
47
  ,
@@ -43,17 +52,20 @@ const ArticleBodyDraftRenderer = DraftRenderer;
43
52
  exports.ArticleBodyDraftRenderer = ArticleBodyDraftRenderer;
44
53
  function ArticleIntroductionDraftRenderer({
45
54
  rawContentState,
46
- themeColor = _index3.ThemeColorEnum.RED
55
+ themeColor = _index2.ThemeColorEnum.RED,
56
+ fontSizeLevel = FontSizeLevel.NORMAL
47
57
  }) {
48
58
  const contentState = (0, _draftJs.convertFromRaw)(rawContentState);
49
- const editorState = _draftJs.EditorState.createWithContent(contentState, _index2.decorator);
59
+ const editorState = _draftJs.EditorState.createWithContent(contentState, _index3.decorator);
50
60
  return /*#__PURE__*/_react.default.createElement(_styledComponents.ThemeProvider, {
51
61
  theme: {
52
- themeColor
62
+ themeColor,
63
+ fontSizeLevel
53
64
  }
54
65
  }, /*#__PURE__*/_react.default.createElement(_draftJs.Editor, {
55
66
  editorState: editorState,
56
67
  blockRenderMap: _index.default.brief,
68
+ customStyleFn: _customStyleFn.customStyleFn,
57
69
  readOnly: true
58
70
  // eslint-disable-next-line @typescript-eslint/no-empty-function
59
71
  ,
@@ -62,18 +74,21 @@ function ArticleIntroductionDraftRenderer({
62
74
  }
63
75
  function ProjectContentDraftRenderer({
64
76
  rawContentState,
65
- themeColor = _index3.ThemeColorEnum.BLUE
77
+ themeColor = _index2.ThemeColorEnum.BLUE,
78
+ fontSizeLevel = FontSizeLevel.NORMAL
66
79
  }) {
67
80
  const contentState = (0, _draftJs.convertFromRaw)(rawContentState);
68
- const editorState = _draftJs.EditorState.createWithContent(contentState, _index2.decorator);
81
+ const editorState = _draftJs.EditorState.createWithContent(contentState, _index3.decorator);
69
82
  return /*#__PURE__*/_react.default.createElement(_styledComponents.ThemeProvider, {
70
83
  theme: {
71
- themeColor
84
+ themeColor,
85
+ fontSizeLevel
72
86
  }
73
87
  }, /*#__PURE__*/_react.default.createElement(_draftJs.Editor, {
74
88
  editorState: editorState,
75
89
  blockRenderMap: _index.default.projectContent,
76
90
  blockRendererFn: blockRendererFn,
91
+ customStyleFn: _customStyleFn.customStyleFn,
77
92
  readOnly: true
78
93
  // eslint-disable-next-line @typescript-eslint/no-empty-function
79
94
  ,
package/lib/index.js CHANGED
@@ -40,6 +40,12 @@ Object.defineProperty(exports, "blockRenderers", {
40
40
  return _blockRenderers.blockRenderers;
41
41
  }
42
42
  });
43
+ Object.defineProperty(exports, "customStyleFn", {
44
+ enumerable: true,
45
+ get: function () {
46
+ return _customStyleFn.customStyleFn;
47
+ }
48
+ });
43
49
  Object.defineProperty(exports, "decorator", {
44
50
  enumerable: true,
45
51
  get: function () {
@@ -47,11 +53,12 @@ Object.defineProperty(exports, "decorator", {
47
53
  }
48
54
  });
49
55
  exports.default = void 0;
56
+ var _index = _interopRequireDefault(require("./block-render-maps/index"));
50
57
  var _draftRenderer = require("./draft-renderer");
51
58
  var _blockRendererFn = require("./block-renderer-fn");
52
- var _index = _interopRequireDefault(require("./block-render-maps/index"));
53
59
  var _blockRenderers = require("./block-renderers");
54
60
  var _index2 = require("./entity-decorators/index");
61
+ var _customStyleFn = require("./custom-style-fn");
55
62
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
56
63
  const blockRenderMap = _index.default.content;
57
64
  exports.blockRenderMap = blockRenderMap;
@@ -63,6 +70,7 @@ var _default = {
63
70
  atomicBlockRenderer: _blockRendererFn.atomicBlockRenderer,
64
71
  blockRenderMap: _index.default.content,
65
72
  blockRenderers: _blockRenderers.blockRenderers,
73
+ customStyleFn: _customStyleFn.customStyleFn,
66
74
  decorator: _index2.decorator
67
75
  };
68
76
  exports.default = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kids-reporter/draft-renderer",
3
- "version": "0.4.21",
3
+ "version": "0.4.23",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {