@kids-reporter/draft-renderer 0.4.7 → 0.4.9
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.
- package/lib/block-render-map.js +30 -54
- package/lib/block-renderer-fn.js +8 -1
- package/lib/block-renderers/dropdown.js +120 -0
- package/lib/block-renderers/image-block.js +10 -49
- package/lib/block-renderers/index.js +2 -0
- package/lib/block-renderers/news-reading.js +55 -0
- package/lib/utils/media-query.js +20 -0
- package/package.json +1 -1
package/lib/block-render-map.js
CHANGED
|
@@ -14,30 +14,26 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
// @ts-ignore pkg does not contain ts header file
|
|
16
16
|
|
|
17
|
-
const
|
|
17
|
+
const Paragraph = _styledComponents.default.div`
|
|
18
18
|
width: 100%;
|
|
19
19
|
max-width: 700px;
|
|
20
|
-
margin: 0 auto 27px auto;
|
|
21
20
|
font-size: 18px;
|
|
22
21
|
font-weight: 500;
|
|
23
22
|
color: #3a4f66;
|
|
24
23
|
letter-spacing: 0.9px;
|
|
25
24
|
line-height: 2;
|
|
25
|
+
margin: 0 auto;
|
|
26
26
|
|
|
27
27
|
${_mediaQuery.default.mobileOnly`
|
|
28
28
|
padding-left: 15px;
|
|
29
29
|
padding-right: 15px;
|
|
30
30
|
`}
|
|
31
|
+
|
|
32
|
+
> div[data-block="true"] {
|
|
33
|
+
margin-bottom: 27px;
|
|
34
|
+
}
|
|
31
35
|
`;
|
|
32
|
-
|
|
33
|
-
className,
|
|
34
|
-
children
|
|
35
|
-
}) {
|
|
36
|
-
return /*#__PURE__*/_react.default.createElement(ParagraphBlock, {
|
|
37
|
-
className: className
|
|
38
|
-
}, children);
|
|
39
|
-
}
|
|
40
|
-
const HeadingBlock = _styledComponents.default.div`
|
|
36
|
+
const Heading = _styledComponents.default.div`
|
|
41
37
|
font-weight: 700;
|
|
42
38
|
line-height: 1.5;
|
|
43
39
|
color: #232323;
|
|
@@ -73,15 +69,7 @@ const HeadingBlock = _styledComponents.default.div`
|
|
|
73
69
|
padding-right: 15px;
|
|
74
70
|
`}
|
|
75
71
|
`;
|
|
76
|
-
|
|
77
|
-
className,
|
|
78
|
-
children
|
|
79
|
-
}) {
|
|
80
|
-
return /*#__PURE__*/_react.default.createElement(HeadingBlock, {
|
|
81
|
-
className: className
|
|
82
|
-
}, children);
|
|
83
|
-
}
|
|
84
|
-
const ListBlock = _styledComponents.default.ol`
|
|
72
|
+
const List = _styledComponents.default.ol`
|
|
85
73
|
width: 100%;
|
|
86
74
|
max-width: 700px;
|
|
87
75
|
margin: 0 auto 27px auto;
|
|
@@ -94,26 +82,16 @@ const ListBlock = _styledComponents.default.ol`
|
|
|
94
82
|
margin-bottom: 6px;
|
|
95
83
|
}
|
|
96
84
|
`;
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}, children);
|
|
104
|
-
}
|
|
105
|
-
function UnorderdedList({
|
|
106
|
-
children,
|
|
107
|
-
className
|
|
108
|
-
}) {
|
|
109
|
-
return /*#__PURE__*/_react.default.createElement(ListBlock, {
|
|
110
|
-
as: "ul",
|
|
111
|
-
className: className
|
|
112
|
-
}, children);
|
|
113
|
-
}
|
|
85
|
+
const Atomic = _styledComponents.default.div`
|
|
86
|
+
/* hide empty block which immediately follows atomic block */
|
|
87
|
+
& + ${Paragraph} {
|
|
88
|
+
display: none;
|
|
89
|
+
}
|
|
90
|
+
`;
|
|
114
91
|
const _blockRenderMap = _immutable.default.Map({
|
|
115
92
|
atomic: {
|
|
116
|
-
element: 'div'
|
|
93
|
+
element: 'div',
|
|
94
|
+
wrapper: /*#__PURE__*/_react.default.createElement(Atomic, null)
|
|
117
95
|
},
|
|
118
96
|
'header-two': {
|
|
119
97
|
element: 'h2',
|
|
@@ -133,11 +111,13 @@ const _blockRenderMap = _immutable.default.Map({
|
|
|
133
111
|
},
|
|
134
112
|
'ordered-list-item': {
|
|
135
113
|
element: 'li',
|
|
136
|
-
wrapper: /*#__PURE__*/_react.default.createElement(
|
|
114
|
+
wrapper: /*#__PURE__*/_react.default.createElement(List, null)
|
|
137
115
|
},
|
|
138
116
|
'unordered-list-item': {
|
|
139
117
|
element: 'li',
|
|
140
|
-
wrapper: /*#__PURE__*/_react.default.createElement(
|
|
118
|
+
wrapper: /*#__PURE__*/_react.default.createElement(List, {
|
|
119
|
+
as: "ul"
|
|
120
|
+
})
|
|
141
121
|
},
|
|
142
122
|
unstyled: {
|
|
143
123
|
element: 'div',
|
|
@@ -149,20 +129,19 @@ exports.blockRenderMap = blockRenderMap;
|
|
|
149
129
|
const ParagraphForIntroduction = (0, _styledComponents.default)(Paragraph)`
|
|
150
130
|
color: #575757;
|
|
151
131
|
`;
|
|
152
|
-
const
|
|
153
|
-
color: #575757;
|
|
154
|
-
`;
|
|
155
|
-
const UnorderdedListForIntroduction = (0, _styledComponents.default)(UnorderdedList)`
|
|
132
|
+
const ListForIntroduction = (0, _styledComponents.default)(List)`
|
|
156
133
|
color: #575757;
|
|
157
134
|
`;
|
|
158
135
|
const blockRenderMapForIntroduction = _draftJs.DefaultDraftBlockRenderMap.merge(_immutable.default.Map({
|
|
159
136
|
'ordered-list-item': {
|
|
160
137
|
element: 'li',
|
|
161
|
-
wrapper: /*#__PURE__*/_react.default.createElement(
|
|
138
|
+
wrapper: /*#__PURE__*/_react.default.createElement(ListForIntroduction, null)
|
|
162
139
|
},
|
|
163
140
|
'unordered-list-item': {
|
|
164
141
|
element: 'li',
|
|
165
|
-
wrapper: /*#__PURE__*/_react.default.createElement(
|
|
142
|
+
wrapper: /*#__PURE__*/_react.default.createElement(ListForIntroduction, {
|
|
143
|
+
as: "ul"
|
|
144
|
+
})
|
|
166
145
|
},
|
|
167
146
|
unstyled: {
|
|
168
147
|
element: 'div',
|
|
@@ -173,12 +152,7 @@ exports.blockRenderMapForIntroduction = blockRenderMapForIntroduction;
|
|
|
173
152
|
const HeadingForAnnotation = (0, _styledComponents.default)(Heading)`
|
|
174
153
|
margin: 0 auto 27px auto;
|
|
175
154
|
`;
|
|
176
|
-
const
|
|
177
|
-
li {
|
|
178
|
-
font-size: 16px;
|
|
179
|
-
}
|
|
180
|
-
`;
|
|
181
|
-
const UnorderdedListForAnnotation = (0, _styledComponents.default)(UnorderdedList)`
|
|
155
|
+
const ListForAnnotation = (0, _styledComponents.default)(List)`
|
|
182
156
|
li {
|
|
183
157
|
font-size: 16px;
|
|
184
158
|
}
|
|
@@ -203,11 +177,13 @@ const _blockRenderMapForAnnotation = _immutable.default.Map({
|
|
|
203
177
|
},
|
|
204
178
|
'ordered-list-item': {
|
|
205
179
|
element: 'li',
|
|
206
|
-
wrapper: /*#__PURE__*/_react.default.createElement(
|
|
180
|
+
wrapper: /*#__PURE__*/_react.default.createElement(ListForAnnotation, null)
|
|
207
181
|
},
|
|
208
182
|
'unordered-list-item': {
|
|
209
183
|
element: 'li',
|
|
210
|
-
wrapper: /*#__PURE__*/_react.default.createElement(
|
|
184
|
+
wrapper: /*#__PURE__*/_react.default.createElement(ListForAnnotation, {
|
|
185
|
+
as: "ul"
|
|
186
|
+
})
|
|
211
187
|
},
|
|
212
188
|
unstyled: {
|
|
213
189
|
element: 'div',
|
package/lib/block-renderer-fn.js
CHANGED
|
@@ -10,7 +10,8 @@ const {
|
|
|
10
10
|
EmbeddedCodeInArticleBody,
|
|
11
11
|
ImageInArticleBody,
|
|
12
12
|
InfoBoxInArticleBody,
|
|
13
|
-
SlideshowInArticleBody
|
|
13
|
+
SlideshowInArticleBody,
|
|
14
|
+
NewsReading
|
|
14
15
|
} = _blockRenderers.blockRenderers;
|
|
15
16
|
const AtomicBlock = props => {
|
|
16
17
|
const entity = props.contentState.getEntity(props.block.getEntityAt(0));
|
|
@@ -47,6 +48,12 @@ const AtomicBlock = props => {
|
|
|
47
48
|
data: entityData
|
|
48
49
|
});
|
|
49
50
|
}
|
|
51
|
+
case 'NEWS_READING':
|
|
52
|
+
{
|
|
53
|
+
return NewsReading({
|
|
54
|
+
data: entityData
|
|
55
|
+
});
|
|
56
|
+
}
|
|
50
57
|
}
|
|
51
58
|
return null;
|
|
52
59
|
};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Dropdown = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
11
|
+
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; }
|
|
12
|
+
const DropdownOptionList = _styledComponents.default.ul`
|
|
13
|
+
margin: 0;
|
|
14
|
+
position: relative;
|
|
15
|
+
padding: 4px 0;
|
|
16
|
+
max-height: 240px;
|
|
17
|
+
background: #ffffff;
|
|
18
|
+
&::before {
|
|
19
|
+
content: '';
|
|
20
|
+
position: absolute;
|
|
21
|
+
top: 0;
|
|
22
|
+
right: 16px;
|
|
23
|
+
left: 16px;
|
|
24
|
+
height: 1px;
|
|
25
|
+
background-color: #e0e0e0;
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
28
|
+
const DropdownOption = _styledComponents.default.li`
|
|
29
|
+
color: #000928;
|
|
30
|
+
padding: 8px 16px;
|
|
31
|
+
&:hover {
|
|
32
|
+
color: #fff;
|
|
33
|
+
background-color: #04295e;
|
|
34
|
+
}
|
|
35
|
+
`;
|
|
36
|
+
const Container = _styledComponents.default.div`
|
|
37
|
+
width: 100%;
|
|
38
|
+
overflow: hidden;
|
|
39
|
+
cursor: pointer;
|
|
40
|
+
|
|
41
|
+
font-size: 18px;
|
|
42
|
+
font-weight: 400;
|
|
43
|
+
line-height: 1.5;
|
|
44
|
+
`;
|
|
45
|
+
const InputBlock = _styledComponents.default.div`
|
|
46
|
+
display: flex;
|
|
47
|
+
justify-content: space-between;
|
|
48
|
+
padding: 8px 16px;
|
|
49
|
+
align-items: center;
|
|
50
|
+
`;
|
|
51
|
+
const Input = _styledComponents.default.input`
|
|
52
|
+
background: #ffffff;
|
|
53
|
+
font-size: 18px;
|
|
54
|
+
padding: 12px 0;
|
|
55
|
+
outline: none;
|
|
56
|
+
border: none;
|
|
57
|
+
cursor: pointer;
|
|
58
|
+
`;
|
|
59
|
+
const More = _styledComponents.default.span`
|
|
60
|
+
margin-left: 10px;
|
|
61
|
+
font-size: 14px;
|
|
62
|
+
`;
|
|
63
|
+
const Arrow = _styledComponents.default.span`
|
|
64
|
+
margin-left: auto;
|
|
65
|
+
|
|
66
|
+
width: 20px;
|
|
67
|
+
height: 20px;
|
|
68
|
+
background-color: #27b5f7;
|
|
69
|
+
border-radius: 50%;
|
|
70
|
+
display: flex;
|
|
71
|
+
|
|
72
|
+
&::after {
|
|
73
|
+
content: '';
|
|
74
|
+
margin-left: auto;
|
|
75
|
+
margin-right: auto;
|
|
76
|
+
margin-top: 7px;
|
|
77
|
+
border-style: solid;
|
|
78
|
+
border-width: 6px;
|
|
79
|
+
border-color: #fff transparent transparent transparent;
|
|
80
|
+
transition: transform 0.1s linear;
|
|
81
|
+
transform: ${({
|
|
82
|
+
$isListOpen
|
|
83
|
+
}) => $isListOpen ? 'rotate(180deg)' : 'rotate(0deg)'};
|
|
84
|
+
transform-origin: center 2.5px;
|
|
85
|
+
}
|
|
86
|
+
`;
|
|
87
|
+
const Dropdown = function ({
|
|
88
|
+
className,
|
|
89
|
+
options,
|
|
90
|
+
onChange,
|
|
91
|
+
labelForMore = ''
|
|
92
|
+
}) {
|
|
93
|
+
const [isListOpen, setIsListOpen] = (0, _react.useState)(false);
|
|
94
|
+
const [selectedOption, setSelectedOption] = (0, _react.useState)(options === null || options === void 0 ? void 0 : options[0]);
|
|
95
|
+
const toggleList = () => {
|
|
96
|
+
setIsListOpen(!isListOpen);
|
|
97
|
+
};
|
|
98
|
+
const selectOption = option => {
|
|
99
|
+
toggleList();
|
|
100
|
+
onChange(option);
|
|
101
|
+
setSelectedOption(option);
|
|
102
|
+
};
|
|
103
|
+
const optionItem = options.map((option, idx) => /*#__PURE__*/_react.default.createElement(DropdownOption, {
|
|
104
|
+
onClick: () => selectOption(option),
|
|
105
|
+
key: `option-${idx}`
|
|
106
|
+
}, option.name));
|
|
107
|
+
return /*#__PURE__*/_react.default.createElement(Container, {
|
|
108
|
+
className: className
|
|
109
|
+
}, /*#__PURE__*/_react.default.createElement(InputBlock, {
|
|
110
|
+
onClick: toggleList
|
|
111
|
+
}, /*#__PURE__*/_react.default.createElement(Input, {
|
|
112
|
+
disabled: true,
|
|
113
|
+
readOnly: true,
|
|
114
|
+
placeholder: "\u8ACB\u9078\u64C7",
|
|
115
|
+
value: selectedOption.name
|
|
116
|
+
}), options.length > 1 && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(Arrow, {
|
|
117
|
+
$isListOpen: isListOpen
|
|
118
|
+
}), labelForMore && /*#__PURE__*/_react.default.createElement(More, null, labelForMore))), isListOpen && /*#__PURE__*/_react.default.createElement(DropdownOptionList, null, optionItem));
|
|
119
|
+
};
|
|
120
|
+
exports.Dropdown = Dropdown;
|
|
@@ -59,12 +59,6 @@ const ArticleBodyContainer = _styledComponents.default.div`
|
|
|
59
59
|
margin: 0;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
&::after {
|
|
63
|
-
content: '';
|
|
64
|
-
display: table;
|
|
65
|
-
clear: both;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
62
|
max-width: 100%;
|
|
69
63
|
margin: 0 auto 27px auto;
|
|
70
64
|
|
|
@@ -81,31 +75,23 @@ const ArticleBodyContainer = _styledComponents.default.div`
|
|
|
81
75
|
case 'paragraph-width':
|
|
82
76
|
return `
|
|
83
77
|
${_index.theme.breakpoint.xl} {
|
|
84
|
-
|
|
85
|
-
width: 700px;
|
|
86
|
-
margin-left: auto;
|
|
87
|
-
margin-right: auto;
|
|
88
|
-
}
|
|
78
|
+
max-width: 700px;
|
|
89
79
|
}
|
|
90
80
|
`;
|
|
91
81
|
case 'right':
|
|
92
82
|
return `
|
|
93
83
|
${_index.theme.breakpoint.xl} {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
margin: 5px 0px 5px 27px;
|
|
98
|
-
}
|
|
84
|
+
width: 361px;
|
|
85
|
+
float: right;
|
|
86
|
+
margin: 5px 0px 5px 27px;
|
|
99
87
|
}
|
|
100
88
|
`;
|
|
101
89
|
case 'left':
|
|
102
90
|
return `
|
|
103
91
|
${_index.theme.breakpoint.xl} {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
margin: 5px 27px 5px 0px;
|
|
108
|
-
}
|
|
92
|
+
width: 361px;
|
|
93
|
+
float: left;
|
|
94
|
+
margin: 5px 27px 5px 0px;
|
|
109
95
|
}
|
|
110
96
|
`;
|
|
111
97
|
}
|
|
@@ -130,40 +116,15 @@ const InfoBoxContainer = _styledComponents.default.div`
|
|
|
130
116
|
margin-bottom: 30px;
|
|
131
117
|
width: fit-content;
|
|
132
118
|
|
|
133
|
-
&::after {
|
|
134
|
-
content: '';
|
|
135
|
-
display: table;
|
|
136
|
-
clear: both;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
119
|
${props => {
|
|
140
120
|
switch (props.$alignment) {
|
|
141
|
-
case '
|
|
142
|
-
{
|
|
143
|
-
return `
|
|
144
|
-
figure {
|
|
145
|
-
margin-left: auto;
|
|
146
|
-
margin-right: auto;
|
|
147
|
-
}
|
|
148
|
-
`;
|
|
149
|
-
}
|
|
150
|
-
case 'left':
|
|
121
|
+
case 'center':
|
|
151
122
|
{
|
|
152
|
-
return `
|
|
153
|
-
figure {
|
|
154
|
-
max-width: 50%;
|
|
155
|
-
margin-right: auto;
|
|
156
|
-
}
|
|
157
|
-
`;
|
|
123
|
+
return `margin-left: auto; margin-right: auto;`;
|
|
158
124
|
}
|
|
159
125
|
case 'right':
|
|
160
126
|
{
|
|
161
|
-
return `
|
|
162
|
-
figure {
|
|
163
|
-
max-width: 50%;
|
|
164
|
-
margin-left: auto;
|
|
165
|
-
}
|
|
166
|
-
`;
|
|
127
|
+
return `margin-left: auto`;
|
|
167
128
|
}
|
|
168
129
|
}
|
|
169
130
|
}}
|
|
@@ -9,6 +9,7 @@ var _embeddedCodeBlock = require("./embedded-code-block");
|
|
|
9
9
|
var _imageBlock = require("./image-block");
|
|
10
10
|
var _infoBoxBlock = require("./info-box-block");
|
|
11
11
|
var _slideshowBlock = require("./slideshow-block");
|
|
12
|
+
var _newsReading = require("./news-reading");
|
|
12
13
|
const blockRenderers = {
|
|
13
14
|
BlockquoteInArticleBody: _blockquote.BlockquoteInArticleBody,
|
|
14
15
|
EmbeddedCodeBlock: _embeddedCodeBlock.EmbeddedCodeBlock,
|
|
@@ -16,6 +17,7 @@ const blockRenderers = {
|
|
|
16
17
|
ImageBlock: _imageBlock.ImageBlock,
|
|
17
18
|
ImageInArticleBody: _imageBlock.ImageInArticleBody,
|
|
18
19
|
InfoBoxInArticleBody: _infoBoxBlock.InfoBoxInArticleBody,
|
|
20
|
+
NewsReading: _newsReading.NewsReading,
|
|
19
21
|
SlideshowBlock: _slideshowBlock.SlideshowBlock,
|
|
20
22
|
SlideshowInArticleBody: _slideshowBlock.SlideshowInArticleBody
|
|
21
23
|
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.NewsReading = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
9
|
+
var _dropdown = require("./dropdown");
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
12
|
+
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; }
|
|
13
|
+
const ArticleBodyContainer = _styledComponents.default.div`
|
|
14
|
+
max-width: 600px;
|
|
15
|
+
width: calc(280 / 320 * 100%);
|
|
16
|
+
border: 1px solid #eaeaea;
|
|
17
|
+
border-radius: 20px;
|
|
18
|
+
margin-left: auto;
|
|
19
|
+
margin-right: auto;
|
|
20
|
+
`;
|
|
21
|
+
const Divider = _styledComponents.default.div`
|
|
22
|
+
border: 1px solid #eaeaea;
|
|
23
|
+
margin-bottom: 20px;
|
|
24
|
+
`;
|
|
25
|
+
const IframeContainer = _styledComponents.default.div`
|
|
26
|
+
padding: 20px;
|
|
27
|
+
`;
|
|
28
|
+
const NewsReading = function ({
|
|
29
|
+
className,
|
|
30
|
+
data
|
|
31
|
+
}) {
|
|
32
|
+
const {
|
|
33
|
+
readings
|
|
34
|
+
} = data;
|
|
35
|
+
const options = (0, _react.useMemo)(() => readings.map(r => {
|
|
36
|
+
return {
|
|
37
|
+
name: r.name,
|
|
38
|
+
value: r.name
|
|
39
|
+
};
|
|
40
|
+
}), [readings]);
|
|
41
|
+
const [selectedOption, setSelectedOption] = (0, _react.useState)(options[0]);
|
|
42
|
+
const selectedReading = readings.find(r => r.name === selectedOption.value);
|
|
43
|
+
return /*#__PURE__*/_react.default.createElement(ArticleBodyContainer, {
|
|
44
|
+
className: className
|
|
45
|
+
}, /*#__PURE__*/_react.default.createElement(_dropdown.Dropdown, {
|
|
46
|
+
options: options,
|
|
47
|
+
onChange: option => setSelectedOption(option),
|
|
48
|
+
labelForMore: "\u66F4\u591A\u8A9E\u8A00"
|
|
49
|
+
}), /*#__PURE__*/_react.default.createElement(Divider, null), (selectedReading === null || selectedReading === void 0 ? void 0 : selectedReading.embedCode) && /*#__PURE__*/_react.default.createElement(IframeContainer, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
50
|
+
dangerouslySetInnerHTML: {
|
|
51
|
+
__html: selectedReading.embedCode
|
|
52
|
+
}
|
|
53
|
+
})));
|
|
54
|
+
};
|
|
55
|
+
exports.NewsReading = NewsReading;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.mediaQuery = exports.breakpoints = void 0;
|
|
7
|
+
const breakpoints = {
|
|
8
|
+
small: 320,
|
|
9
|
+
medium: 760,
|
|
10
|
+
large: 1440
|
|
11
|
+
};
|
|
12
|
+
exports.breakpoints = breakpoints;
|
|
13
|
+
const mediaQuery = {
|
|
14
|
+
smallOnly: `@media (max-width: ${breakpoints.medium - 1}px)`,
|
|
15
|
+
mediumOnly: `@media (min-width: ${breakpoints.medium}px) and (max-width: ${breakpoints.large - 1}px)`,
|
|
16
|
+
mediumAbove: `@media (min-width: ${breakpoints.medium}px)`,
|
|
17
|
+
largeBelow: `@media (max-width: ${breakpoints.large - 1}px)`,
|
|
18
|
+
largeOnly: `@media (min-width: ${breakpoints.large}px)`
|
|
19
|
+
};
|
|
20
|
+
exports.mediaQuery = mediaQuery;
|