@twreporter/react-article-components 2.1.2-rc.1 → 2.2.0-rc.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.
- package/CHANGELOG.md +24 -0
- package/lib/components/article-page.js +42 -107
- package/lib/components/aside/desktop-aside.js +25 -65
- package/lib/components/aside/desktop-tools.js +11 -57
- package/lib/components/aside/metadata.js +22 -89
- package/lib/components/aside/mobile-tool-bar.js +79 -175
- package/lib/components/aside/utils/theme.js +5 -11
- package/lib/components/body/annotation.js +15 -73
- package/lib/components/body/audio/audio-contexts.js +4 -16
- package/lib/components/body/audio/audio-provider.js +13 -48
- package/lib/components/body/audio/control-button.js +4 -28
- package/lib/components/body/audio/index.js +10 -56
- package/lib/components/body/audio/seek-bar.js +6 -23
- package/lib/components/body/audio/time.js +0 -6
- package/lib/components/body/blockquote.js +11 -52
- package/lib/components/body/brief.js +10 -55
- package/lib/components/body/centered-quote.js +10 -52
- package/lib/components/body/embedded-code.js +22 -101
- package/lib/components/body/headings.js +6 -23
- package/lib/components/body/image-diff.js +13 -66
- package/lib/components/body/image.js +11 -46
- package/lib/components/body/index.js +55 -108
- package/lib/components/body/infobox.js +32 -65
- package/lib/components/body/list.js +8 -29
- package/lib/components/body/multimedia.js +10 -29
- package/lib/components/body/paragraph.js +5 -23
- package/lib/components/body/slider/index.js +28 -96
- package/lib/components/body/slideshow/index.js +36 -107
- package/lib/components/body/tracking-section.js +141 -0
- package/lib/components/body/youtube.js +8 -41
- package/lib/components/donation-box.js +10 -44
- package/lib/components/img-with-placeholder/index.js +34 -106
- package/lib/components/leading/extend.js +6 -25
- package/lib/components/leading/fullscreen.js +17 -63
- package/lib/components/leading/index.js +2 -10
- package/lib/components/leading/normal.js +19 -64
- package/lib/components/leading/pink.js +20 -59
- package/lib/components/leading/small.js +6 -25
- package/lib/components/license.js +9 -40
- package/lib/components/link.js +8 -37
- package/lib/components/related/card.js +20 -73
- package/lib/components/related/index.js +25 -71
- package/lib/components/related/list.js +16 -70
- package/lib/components/related/mockup.js +10 -12
- package/lib/components/separation-curve.js +0 -15
- package/lib/components/table-of-contents/index.js +17 -46
- package/lib/components/table-of-contents/styled.js +10 -38
- package/lib/constants/anchor.js +4 -8
- package/lib/constants/css.js +2 -15
- package/lib/constants/element-alignment.js +2 -3
- package/lib/constants/prop-types/article-page.js +2 -7
- package/lib/constants/prop-types/aside.js +2 -8
- package/lib/constants/prop-types/body.js +4 -9
- package/lib/constants/prop-types/img-with-placeholder.js +2 -7
- package/lib/constants/prop-types/leading.js +8 -13
- package/lib/constants/prop-types/related.js +2 -7
- package/lib/constants/theme.js +2 -3
- package/lib/constants/typography.js +2 -5
- package/lib/contexts/dynamic-components-context.js +2 -8
- package/lib/managers/layout-manager.js +13 -28
- package/lib/managers/theme-manager.js +13 -32
- package/lib/managers/ui-manager.js +14 -26
- package/lib/utils/image.js +5 -14
- package/package.json +6 -6
|
@@ -1,97 +1,65 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(
|
|
4
|
-
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports["default"] = void 0;
|
|
9
8
|
exports.renderElement = renderElement;
|
|
10
|
-
|
|
11
9
|
var _elementAlignment = _interopRequireDefault(require("../../constants/element-alignment"));
|
|
12
|
-
|
|
13
10
|
var _annotation = _interopRequireDefault(require("./annotation"));
|
|
14
|
-
|
|
15
11
|
var _audio = _interopRequireDefault(require("./audio"));
|
|
16
|
-
|
|
17
12
|
var _blockquote = _interopRequireDefault(require("./blockquote"));
|
|
18
|
-
|
|
19
13
|
var _brief = _interopRequireDefault(require("./brief"));
|
|
20
|
-
|
|
21
14
|
var _centeredQuote = _interopRequireDefault(require("./centered-quote"));
|
|
22
|
-
|
|
23
15
|
var _embeddedCode = _interopRequireWildcard(require("./embedded-code"));
|
|
24
|
-
|
|
25
16
|
var _headings = _interopRequireDefault(require("./headings"));
|
|
26
|
-
|
|
27
17
|
var _image = _interopRequireDefault(require("./image"));
|
|
28
|
-
|
|
29
18
|
var _imageDiff = _interopRequireDefault(require("./image-diff"));
|
|
30
|
-
|
|
31
19
|
var _infobox = _interopRequireDefault(require("./infobox"));
|
|
32
|
-
|
|
33
20
|
var _list = _interopRequireDefault(require("./list"));
|
|
34
|
-
|
|
35
21
|
var _multimedia = _interopRequireDefault(require("./multimedia"));
|
|
36
|
-
|
|
37
22
|
var _paragraph = _interopRequireDefault(require("./paragraph"));
|
|
38
|
-
|
|
39
23
|
var _body = _interopRequireDefault(require("../../constants/prop-types/body"));
|
|
40
|
-
|
|
41
24
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
42
|
-
|
|
43
25
|
var _react = _interopRequireWildcard(require("react"));
|
|
44
|
-
|
|
45
26
|
var _slideshow = _interopRequireDefault(require("./slideshow"));
|
|
46
|
-
|
|
47
27
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
48
|
-
|
|
49
28
|
var _tableOfContents = _interopRequireDefault(require("../table-of-contents"));
|
|
50
|
-
|
|
51
29
|
var _youtube = _interopRequireDefault(require("./youtube"));
|
|
52
|
-
|
|
30
|
+
var _trackingSection = _interopRequireDefault(require("./tracking-section"));
|
|
53
31
|
var _mediaQuery = _interopRequireDefault(require("@twreporter/core/lib/utils/media-query"));
|
|
54
|
-
|
|
55
32
|
var _get = _interopRequireDefault(require("lodash/get"));
|
|
56
|
-
|
|
57
33
|
var _map = _interopRequireDefault(require("lodash/map"));
|
|
58
|
-
|
|
59
34
|
var _smoothScroll = _interopRequireDefault(require("smooth-scroll/dist/smooth-scroll"));
|
|
60
|
-
|
|
61
35
|
var _anchor = require("../../constants/anchor");
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
function _interopRequireWildcard(
|
|
68
|
-
|
|
36
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19, _templateObject20, _templateObject21, _templateObject22, _templateObject23; // @twreporter
|
|
37
|
+
// lodash
|
|
38
|
+
// Change smooth-scroll import path due to SSR issue:
|
|
39
|
+
// https://github.com/cferdinandi/smooth-scroll/issues/481
|
|
40
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
41
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
69
42
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
70
|
-
|
|
43
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
44
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
45
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
46
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
47
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
48
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
71
49
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
72
|
-
|
|
73
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
74
|
-
|
|
50
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
75
51
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
76
|
-
|
|
77
52
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
78
|
-
|
|
79
53
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
80
|
-
|
|
81
54
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
82
|
-
|
|
83
55
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
84
|
-
|
|
85
56
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
86
|
-
|
|
87
57
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
88
|
-
|
|
89
58
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
90
|
-
|
|
91
|
-
function
|
|
92
|
-
|
|
59
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
60
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
61
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
93
62
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
94
|
-
|
|
95
63
|
var _ = {
|
|
96
64
|
get: _get["default"],
|
|
97
65
|
map: _map["default"]
|
|
@@ -147,17 +115,14 @@ var StyledEmbeddedNormal = /*#__PURE__*/(0, _styledComponents["default"])(_embed
|
|
|
147
115
|
displayName: "body__StyledEmbeddedNormal",
|
|
148
116
|
componentId: "dwuu2m-8"
|
|
149
117
|
})(["", " ", ""], normalWidthCSS, embeddedCSS);
|
|
150
|
-
|
|
151
118
|
var StyledExtendImageBlock = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
152
119
|
displayName: "body__StyledExtendImageBlock",
|
|
153
120
|
componentId: "dwuu2m-9"
|
|
154
121
|
})(["", " ", " margin:", ";"], extendWidthCSS, clearFloatCSS, mockup.margin.extend);
|
|
155
|
-
|
|
156
122
|
var StyledLargeImageBlock = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
157
123
|
displayName: "body__StyledLargeImageBlock",
|
|
158
124
|
componentId: "dwuu2m-10"
|
|
159
125
|
})(["", " ", " ", " margin:", ";", "{margin-bottom:0px;", " ", " ", "}"], largeWidthCSS, clearFloatCSS, _mediaQuery["default"].mobileOnly(_templateObject19 || (_templateObject19 = _taggedTemplateLiteral(["\n width: 100%;\n "]))), mockup.margin.large, _multimedia["default"].Caption, _mediaQuery["default"].desktopAndAbove(_templateObject20 || (_templateObject20 = _taggedTemplateLiteral(["\n position: absolute;\n bottom: 0;\n transform: translateX(100%);\n &:after {\n width: 100%;\n }\n "]))), _mediaQuery["default"].desktopOnly(_templateObject21 || (_templateObject21 = _taggedTemplateLiteral(["\n right: -21px;\n "]))), _mediaQuery["default"].hdOnly(_templateObject22 || (_templateObject22 = _taggedTemplateLiteral(["\n right: -38px;\n "]))));
|
|
160
|
-
|
|
161
126
|
var StyledSlideshow = /*#__PURE__*/(0, _styledComponents["default"])(_slideshow["default"]).withConfig({
|
|
162
127
|
displayName: "body__StyledSlideshow",
|
|
163
128
|
componentId: "dwuu2m-11"
|
|
@@ -182,16 +147,19 @@ var StyledParagraph = /*#__PURE__*/(0, _styledComponents["default"])(_paragraph[
|
|
|
182
147
|
displayName: "body__StyledParagraph",
|
|
183
148
|
componentId: "dwuu2m-16"
|
|
184
149
|
})(["", " margin:", ";"], normalWidthCSS, mockup.margin.normal);
|
|
185
|
-
|
|
186
150
|
var AlignRight = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
187
151
|
displayName: "body__AlignRight",
|
|
188
152
|
componentId: "dwuu2m-17"
|
|
189
153
|
})(["", " ", " ", ",", ",", ",", "{", ";}", "{", "}"], extendWidthCSS, clearFloatCSS, StyledCenteredQuote, StyledBlockquote, StyledEmbedded, StyledInfobox, alignRightCSS, StyledEmbedded, _mediaQuery["default"].desktopAndAbove(_templateObject23 || (_templateObject23 = _taggedTemplateLiteral(["\n margin: 0 0 20px 30px;\n ", " {\n padding: 13px 10px 0 10px;\n }\n "])), _embeddedCode.Caption));
|
|
190
|
-
|
|
191
154
|
var ClearFloat = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
192
155
|
displayName: "body__ClearFloat",
|
|
193
156
|
componentId: "dwuu2m-18"
|
|
194
157
|
})(["", ""], clearFloatCSS);
|
|
158
|
+
var StyledTrackingSection = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
159
|
+
displayName: "body__StyledTrackingSection",
|
|
160
|
+
componentId: "dwuu2m-19"
|
|
161
|
+
})(["", ";margin:40px auto 48px;"], normalWidthCSS);
|
|
162
|
+
|
|
195
163
|
/**
|
|
196
164
|
* Element Data
|
|
197
165
|
* See `elementData` in `src/constants/prop-types/body.js`
|
|
@@ -210,26 +178,21 @@ var ClearFloat = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
|
210
178
|
* @param {boolean} isScrollingToAnchor - state of scrolling to an anchor or not
|
|
211
179
|
* @returns
|
|
212
180
|
*/
|
|
213
|
-
|
|
214
|
-
|
|
215
181
|
function renderElement() {
|
|
216
182
|
var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
217
183
|
var isScrollingToAnchor = arguments.length > 1 ? arguments[1] : undefined;
|
|
218
184
|
var isCenterAligned = data.alignment === _elementAlignment["default"].center || data.alignment === _elementAlignment["default"].centerSmall;
|
|
219
|
-
|
|
220
185
|
switch (data.type) {
|
|
221
186
|
case 'annotation':
|
|
222
187
|
return /*#__PURE__*/_react["default"].createElement(StyledAnnotation, {
|
|
223
188
|
key: data.id,
|
|
224
189
|
data: data
|
|
225
190
|
});
|
|
226
|
-
|
|
227
191
|
case 'audio':
|
|
228
192
|
return /*#__PURE__*/_react["default"].createElement(StyledAudio, {
|
|
229
193
|
key: data.id,
|
|
230
194
|
content: data.content[0]
|
|
231
195
|
});
|
|
232
|
-
|
|
233
196
|
case 'centered-quote':
|
|
234
197
|
case 'quoteby':
|
|
235
198
|
return isCenterAligned ? /*#__PURE__*/_react["default"].createElement(StyledCenteredQuote, {
|
|
@@ -240,7 +203,6 @@ function renderElement() {
|
|
|
240
203
|
}, /*#__PURE__*/_react["default"].createElement(StyledCenteredQuote, {
|
|
241
204
|
data: data
|
|
242
205
|
}));
|
|
243
|
-
|
|
244
206
|
case 'blockquote':
|
|
245
207
|
return isCenterAligned ? /*#__PURE__*/_react["default"].createElement(StyledBlockquote, {
|
|
246
208
|
key: data.id,
|
|
@@ -250,22 +212,18 @@ function renderElement() {
|
|
|
250
212
|
}, /*#__PURE__*/_react["default"].createElement(StyledBlockquote, {
|
|
251
213
|
data: data
|
|
252
214
|
}));
|
|
253
|
-
|
|
254
215
|
case 'header-one':
|
|
255
216
|
return /*#__PURE__*/_react["default"].createElement(StyledHeaderOne, {
|
|
256
217
|
key: data.id,
|
|
257
218
|
data: data
|
|
258
219
|
});
|
|
259
|
-
|
|
260
220
|
case 'header-two':
|
|
261
221
|
return /*#__PURE__*/_react["default"].createElement(StyledHeaderTwo, {
|
|
262
222
|
key: data.id,
|
|
263
223
|
data: data
|
|
264
224
|
});
|
|
265
|
-
|
|
266
225
|
case 'code':
|
|
267
226
|
return null;
|
|
268
|
-
|
|
269
227
|
case 'embedded-code':
|
|
270
228
|
case 'embeddedCode':
|
|
271
229
|
case 'embeddedcode':
|
|
@@ -280,14 +238,12 @@ function renderElement() {
|
|
|
280
238
|
isScrollingToAnchor: isScrollingToAnchor
|
|
281
239
|
}));
|
|
282
240
|
}
|
|
283
|
-
|
|
284
241
|
case _elementAlignment["default"].centerSmall:
|
|
285
242
|
return /*#__PURE__*/_react["default"].createElement(StyledEmbeddedNormal, {
|
|
286
243
|
key: data.id,
|
|
287
244
|
data: data,
|
|
288
245
|
isScrollingToAnchor: isScrollingToAnchor
|
|
289
246
|
});
|
|
290
|
-
|
|
291
247
|
case _elementAlignment["default"].center:
|
|
292
248
|
default:
|
|
293
249
|
{
|
|
@@ -298,7 +254,6 @@ function renderElement() {
|
|
|
298
254
|
});
|
|
299
255
|
}
|
|
300
256
|
}
|
|
301
|
-
|
|
302
257
|
case 'small-image':
|
|
303
258
|
case 'image':
|
|
304
259
|
case 'image-link':
|
|
@@ -316,14 +271,12 @@ function renderElement() {
|
|
|
316
271
|
data: data,
|
|
317
272
|
small: true
|
|
318
273
|
}));
|
|
319
|
-
|
|
320
274
|
case _elementAlignment["default"].centerSmall:
|
|
321
275
|
return /*#__PURE__*/_react["default"].createElement(StyledLargeImageBlock, {
|
|
322
276
|
key: data.id
|
|
323
277
|
}, /*#__PURE__*/_react["default"].createElement(_image["default"], {
|
|
324
278
|
data: data
|
|
325
279
|
}));
|
|
326
|
-
|
|
327
280
|
case _elementAlignment["default"].center:
|
|
328
281
|
default:
|
|
329
282
|
return /*#__PURE__*/_react["default"].createElement(StyledExtendImageBlock, {
|
|
@@ -333,7 +286,6 @@ function renderElement() {
|
|
|
333
286
|
}));
|
|
334
287
|
}
|
|
335
288
|
}
|
|
336
|
-
|
|
337
289
|
case 'imageDiff':
|
|
338
290
|
case 'imagediff':
|
|
339
291
|
return /*#__PURE__*/_react["default"].createElement(StyledExtendImageBlock, {
|
|
@@ -342,7 +294,6 @@ function renderElement() {
|
|
|
342
294
|
key: data.id,
|
|
343
295
|
data: data
|
|
344
296
|
}));
|
|
345
|
-
|
|
346
297
|
case 'infobox':
|
|
347
298
|
return isCenterAligned ? /*#__PURE__*/_react["default"].createElement(StyledInfobox, {
|
|
348
299
|
key: data.id,
|
|
@@ -352,37 +303,37 @@ function renderElement() {
|
|
|
352
303
|
}, /*#__PURE__*/_react["default"].createElement(StyledInfobox, {
|
|
353
304
|
data: data
|
|
354
305
|
}));
|
|
355
|
-
|
|
356
306
|
case 'ordered-list-item':
|
|
357
307
|
return /*#__PURE__*/_react["default"].createElement(StyledOrderedList, {
|
|
358
308
|
key: data.id,
|
|
359
309
|
data: data
|
|
360
310
|
});
|
|
361
|
-
|
|
362
311
|
case 'unordered-list-item':
|
|
363
312
|
return /*#__PURE__*/_react["default"].createElement(StyledUnorderedList, {
|
|
364
313
|
key: data.id,
|
|
365
314
|
data: data
|
|
366
315
|
});
|
|
367
|
-
|
|
368
316
|
case 'unstyled':
|
|
369
317
|
return /*#__PURE__*/_react["default"].createElement(StyledParagraph, {
|
|
370
318
|
key: data.id,
|
|
371
319
|
data: data
|
|
372
320
|
});
|
|
373
|
-
|
|
374
321
|
case 'slideshow':
|
|
375
322
|
return /*#__PURE__*/_react["default"].createElement(StyledSlideshow, {
|
|
376
323
|
key: data.id,
|
|
377
324
|
data: data
|
|
378
325
|
});
|
|
379
|
-
|
|
380
326
|
case 'youtube':
|
|
381
327
|
return /*#__PURE__*/_react["default"].createElement(StyledYoutube, {
|
|
382
328
|
key: data.id,
|
|
383
329
|
data: data
|
|
384
330
|
});
|
|
385
|
-
|
|
331
|
+
case 'tracking-section':
|
|
332
|
+
return /*#__PURE__*/_react["default"].createElement(StyledTrackingSection, {
|
|
333
|
+
key: data.id
|
|
334
|
+
}, /*#__PURE__*/_react["default"].createElement(_trackingSection["default"], {
|
|
335
|
+
data: data
|
|
336
|
+
}));
|
|
386
337
|
default:
|
|
387
338
|
return /*#__PURE__*/_react["default"].createElement(StyledParagraph, {
|
|
388
339
|
key: data.id,
|
|
@@ -390,32 +341,23 @@ function renderElement() {
|
|
|
390
341
|
});
|
|
391
342
|
}
|
|
392
343
|
}
|
|
393
|
-
|
|
394
|
-
var Body = /*#__PURE__*/function (_Component) {
|
|
344
|
+
var Body = exports["default"] = /*#__PURE__*/function (_Component) {
|
|
395
345
|
_inherits(Body, _Component);
|
|
396
|
-
|
|
397
346
|
var _super = _createSuper(Body);
|
|
398
|
-
|
|
399
347
|
function Body(props) {
|
|
400
348
|
var _this;
|
|
401
|
-
|
|
402
349
|
_classCallCheck(this, Body);
|
|
403
|
-
|
|
404
350
|
_this = _super.call(this, props);
|
|
405
|
-
|
|
406
351
|
_defineProperty(_assertThisInitialized(_this), "tocManager", _tableOfContents["default"].createManager());
|
|
407
|
-
|
|
408
352
|
_defineProperty(_assertThisInitialized(_this), "_scrollStartHandler", function () {
|
|
409
353
|
_this._onStartScrollingToAnchor(true);
|
|
410
354
|
});
|
|
411
|
-
|
|
412
355
|
_defineProperty(_assertThisInitialized(_this), "_scrollStopHandler", function () {
|
|
413
356
|
// Wait for a short time to avoid trigger waypoint's onEnter() of infogram embed close to the anchor
|
|
414
357
|
setTimeout(function () {
|
|
415
358
|
return _this._onStartScrollingToAnchor(false);
|
|
416
359
|
}, _anchor.WAIT_AFTER_REACH_ANCHOR);
|
|
417
360
|
});
|
|
418
|
-
|
|
419
361
|
_defineProperty(_assertThisInitialized(_this), "_onStartScrollingToAnchor", function (isScrollingToAnchor, callback) {
|
|
420
362
|
_this.setState({
|
|
421
363
|
isScrollingToAnchor: isScrollingToAnchor
|
|
@@ -425,21 +367,17 @@ var Body = /*#__PURE__*/function (_Component) {
|
|
|
425
367
|
}
|
|
426
368
|
});
|
|
427
369
|
});
|
|
428
|
-
|
|
429
370
|
_defineProperty(_assertThisInitialized(_this), "_buildContentElement", function (data, index) {
|
|
430
371
|
if (!data.id) {
|
|
431
372
|
data.id = "body_element_".concat(index);
|
|
432
373
|
}
|
|
433
|
-
|
|
434
374
|
return renderElement(data, _this.state.isScrollingToAnchor);
|
|
435
375
|
});
|
|
436
|
-
|
|
437
376
|
_this.state = {
|
|
438
377
|
isScrollingToAnchor: false
|
|
439
378
|
};
|
|
440
379
|
return _this;
|
|
441
380
|
}
|
|
442
|
-
|
|
443
381
|
_createClass(Body, [{
|
|
444
382
|
key: "componentDidMount",
|
|
445
383
|
value: function componentDidMount() {
|
|
@@ -465,27 +403,38 @@ var Body = /*#__PURE__*/function (_Component) {
|
|
|
465
403
|
key: "render",
|
|
466
404
|
value: function render() {
|
|
467
405
|
var _this2 = this;
|
|
468
|
-
|
|
469
406
|
var _this$props = this.props,
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
407
|
+
brief = _this$props.brief,
|
|
408
|
+
content = _this$props.content,
|
|
409
|
+
onToggleTabExpanded = _this$props.onToggleTabExpanded,
|
|
410
|
+
scrollStage = _this$props.scrollStage,
|
|
411
|
+
trackingSection = _this$props.trackingSection;
|
|
412
|
+
var trackingSectionHeaderOne = {
|
|
413
|
+
type: 'header-one',
|
|
414
|
+
content: ['後續與迴響']
|
|
415
|
+
};
|
|
474
416
|
var enableTOC = false;
|
|
475
|
-
var
|
|
417
|
+
var renderContent = null;
|
|
418
|
+
if (Array.isArray(content)) {
|
|
419
|
+
if (Array.isArray(trackingSection) && trackingSection.length > 0) {
|
|
420
|
+
renderContent = [].concat(_toConsumableArray(content), [trackingSectionHeaderOne], _toConsumableArray(trackingSection));
|
|
421
|
+
} else {
|
|
422
|
+
renderContent = _toConsumableArray(content);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
var contentJsx = Array.isArray(renderContent) ? _.map(renderContent, function (data, index) {
|
|
476
426
|
var elementJSX = _this2._buildContentElement(data, index);
|
|
477
|
-
|
|
478
427
|
if (data.type === 'header-one') {
|
|
479
428
|
enableTOC = true;
|
|
480
429
|
return /*#__PURE__*/_react["default"].createElement(_tableOfContents["default"].React.Anchor, {
|
|
481
|
-
key: data.id
|
|
430
|
+
key: data.id
|
|
431
|
+
// provide header-one string as anchor id for article
|
|
482
432
|
,
|
|
483
433
|
id: _.get(data, 'content.0', "section-".concat(index)),
|
|
484
434
|
label: _.get(data, 'content.0'),
|
|
485
435
|
manager: _this2.tocManager
|
|
486
436
|
}, elementJSX);
|
|
487
437
|
}
|
|
488
|
-
|
|
489
438
|
return elementJSX;
|
|
490
439
|
}) : null;
|
|
491
440
|
return /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(StyledBrief, {
|
|
@@ -498,22 +447,20 @@ var Body = /*#__PURE__*/function (_Component) {
|
|
|
498
447
|
}) : null);
|
|
499
448
|
}
|
|
500
449
|
}]);
|
|
501
|
-
|
|
502
450
|
return Body;
|
|
503
451
|
}(_react.Component);
|
|
504
|
-
|
|
505
|
-
exports["default"] = Body;
|
|
506
|
-
|
|
507
452
|
_defineProperty(Body, "propTypes", {
|
|
508
453
|
brief: _propTypes["default"].arrayOf(_body["default"].elementData),
|
|
509
454
|
content: _propTypes["default"].arrayOf(_body["default"].elementData),
|
|
510
455
|
onToggleTabExpanded: _propTypes["default"].func,
|
|
511
|
-
scrollStage: _propTypes["default"].number
|
|
456
|
+
scrollStage: _propTypes["default"].number,
|
|
457
|
+
// for tracking section feature toggle
|
|
458
|
+
trackingSection: _propTypes["default"].array
|
|
512
459
|
});
|
|
513
|
-
|
|
514
460
|
_defineProperty(Body, "defaultProps", {
|
|
515
461
|
brief: [],
|
|
516
462
|
content: [],
|
|
517
463
|
onToggleTabExpanded: function onToggleTabExpanded() {},
|
|
518
|
-
scollStage: 1
|
|
464
|
+
scollStage: 1,
|
|
465
|
+
trackingSection: []
|
|
519
466
|
});
|
|
@@ -1,128 +1,94 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(
|
|
4
|
-
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports["default"] = void 0;
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
|
|
12
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
10
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
15
|
-
|
|
16
11
|
var _get = _interopRequireDefault(require("lodash/get"));
|
|
17
|
-
|
|
18
12
|
var _body = _interopRequireDefault(require("../../constants/prop-types/body"));
|
|
19
|
-
|
|
20
13
|
var _css = _interopRequireDefault(require("../../constants/css"));
|
|
21
|
-
|
|
22
14
|
var _theme = _interopRequireDefault(require("../../constants/theme"));
|
|
23
|
-
|
|
24
15
|
var _typography = _interopRequireDefault(require("../../constants/typography"));
|
|
25
|
-
|
|
26
16
|
var _anchor = require("../../constants/anchor");
|
|
27
|
-
|
|
28
17
|
var _mediaQuery = _interopRequireDefault(require("@twreporter/core/lib/utils/media-query"));
|
|
29
|
-
|
|
30
18
|
var _color = require("@twreporter/core/lib/constants/color");
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
19
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9; // constants
|
|
20
|
+
// twreporter
|
|
34
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
35
|
-
|
|
36
|
-
function
|
|
37
|
-
|
|
38
|
-
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; }
|
|
39
|
-
|
|
22
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
23
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
40
24
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
41
|
-
|
|
42
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
43
|
-
|
|
25
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
44
26
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
45
|
-
|
|
46
27
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
47
|
-
|
|
48
28
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
49
|
-
|
|
50
29
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
51
|
-
|
|
52
30
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
53
|
-
|
|
54
31
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
55
|
-
|
|
56
32
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
57
|
-
|
|
58
33
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
59
|
-
|
|
60
|
-
function
|
|
61
|
-
|
|
34
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
35
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
36
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
62
37
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
63
|
-
|
|
64
38
|
var _ = {
|
|
65
39
|
get: _get["default"]
|
|
66
40
|
};
|
|
67
|
-
var
|
|
68
|
-
|
|
41
|
+
var articleBodyWidthCSS = /*#__PURE__*/(0, _styledComponents.css)(["", " ", " ", " ", ""], _mediaQuery["default"].mobileOnly(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n width: calc(248/300*100%);\n "]))), _mediaQuery["default"].tabletOnly(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n width: 445px;\n "]))), _mediaQuery["default"].desktopOnly(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n width: 480px;\n "]))), _mediaQuery["default"].hdOnly(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n width: 580px;\n "]))));
|
|
42
|
+
var trackingSectionWidthCSS = /*#__PURE__*/(0, _styledComponents.css)(["", " ", " ", ""], _mediaQuery["default"].mobileOnly(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n width: 256px;\n "]))), _mediaQuery["default"].tabletOnly(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n width: 386px;\n "]))), _mediaQuery["default"].desktopAndAbove(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n width: 476px;\n "]))));
|
|
69
43
|
var Title = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
70
44
|
displayName: "infobox__Title",
|
|
71
45
|
componentId: "sc-1rp3uhy-0"
|
|
72
|
-
})(["", " color:", ";line-height:1.9;letter-spacing:0.7px;font-weight:", ";font-size:", "px;margin:0 auto 21px auto;"],
|
|
46
|
+
})(["", " color:", ";line-height:1.9;letter-spacing:0.7px;font-weight:", ";font-size:", "px;margin:0 auto 21px auto;"], function (props) {
|
|
47
|
+
return props.$forTrackingSection ? trackingSectionWidthCSS : articleBodyWidthCSS;
|
|
48
|
+
}, _color.colorGrayscale.gray700, _typography["default"].font.weight.bold, function (props) {
|
|
73
49
|
return props.theme.fontSizeOffset + 20;
|
|
74
50
|
});
|
|
75
|
-
|
|
76
51
|
var Content = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
77
52
|
displayName: "infobox__Content",
|
|
78
53
|
componentId: "sc-1rp3uhy-1"
|
|
79
|
-
})(["", " color:", ";line-height:1.75;letter-spacing:0.5px;font-weight:", ";font-size:", "px;margin:0 auto;"],
|
|
54
|
+
})(["", " color:", ";line-height:1.75;letter-spacing:0.5px;font-weight:", ";font-size:", "px;margin:0 auto;"], function (props) {
|
|
55
|
+
return props.$forTrackingSection ? trackingSectionWidthCSS : articleBodyWidthCSS;
|
|
56
|
+
}, _color.colorGrayscale.gray700, _typography["default"].font.weight.normal, function (props) {
|
|
80
57
|
return props.theme.fontSizeOffset + 16;
|
|
81
58
|
});
|
|
82
|
-
|
|
83
59
|
function getContainerStyles(themeName) {
|
|
84
60
|
switch (themeName) {
|
|
85
61
|
case _theme["default"].article.v2.photo:
|
|
86
62
|
return (0, _styledComponents.css)(["&::before,&::after{background:", ";}"], _color.colorSupportive.heavy);
|
|
87
|
-
|
|
88
63
|
case _theme["default"].article.v2.pink:
|
|
89
64
|
return (0, _styledComponents.css)(["&::before,&::after{background:", ";}"], _color.COLOR_PINK_ARTICLE.pink);
|
|
90
|
-
|
|
91
65
|
case _theme["default"].article.v2["default"]:
|
|
92
66
|
default:
|
|
93
67
|
return (0, _styledComponents.css)(["&::before,&::after{background:", ";}"], _color.colorSupportive.main);
|
|
94
68
|
}
|
|
95
69
|
}
|
|
96
|
-
|
|
97
70
|
var Container = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
98
71
|
displayName: "infobox__Container",
|
|
99
72
|
componentId: "sc-1rp3uhy-2"
|
|
100
73
|
})(["", " ", " white-space:pre-wrap;background:", ";position:relative;margin:60px auto 0 auto;", " ", " &::before{content:'';display:block;width:58px;height:1px;transform:rotate(34.51deg);transform-origin:right center;position:absolute;right:-15px;top:28px;}&::after{content:'';display:block;width:58px;height:1px;transform:rotate(34.51deg);transform-origin:left center;position:absolute;left:-6px;bottom:22px;}"], function (props) {
|
|
101
74
|
return getContainerStyles(props.theme.name);
|
|
102
|
-
}, _css["default"].linkChildren, _color.colorGrayscale.white, _mediaQuery["default"].tabletAndBelow(
|
|
103
|
-
|
|
104
|
-
var Infobox = /*#__PURE__*/function (_PureComponent) {
|
|
75
|
+
}, _css["default"].linkChildren, _color.colorGrayscale.white, _mediaQuery["default"].tabletAndBelow(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n padding-top: 30px;\n padding-bottom: 30px;\n "]))), _mediaQuery["default"].desktopAndAbove(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n padding-top: 40px;\n padding-bottom: 40px;\n "]))));
|
|
76
|
+
var Infobox = exports["default"] = /*#__PURE__*/function (_PureComponent) {
|
|
105
77
|
_inherits(Infobox, _PureComponent);
|
|
106
|
-
|
|
107
78
|
var _super = _createSuper(Infobox);
|
|
108
|
-
|
|
109
79
|
function Infobox() {
|
|
110
80
|
_classCallCheck(this, Infobox);
|
|
111
|
-
|
|
112
81
|
return _super.apply(this, arguments);
|
|
113
82
|
}
|
|
114
|
-
|
|
115
83
|
_createClass(Infobox, [{
|
|
116
84
|
key: "render",
|
|
117
85
|
value: function render() {
|
|
118
86
|
var _this$props = this.props,
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
87
|
+
className = _this$props.className,
|
|
88
|
+
data = _this$props.data,
|
|
89
|
+
forTrackingSection = _this$props.forTrackingSection;
|
|
122
90
|
var contentHtmlString = _.get(data, ['content', 0, 'body'], '');
|
|
123
|
-
|
|
124
91
|
var title = _.get(data, ['content', 0, 'title'], '');
|
|
125
|
-
|
|
126
92
|
var anchorRegex = /<a([^>]*)>/g;
|
|
127
93
|
var hashRegex = /href={?["']#/;
|
|
128
94
|
var mutatedContentHtmlString = contentHtmlString === null || contentHtmlString === void 0 ? void 0 : contentHtmlString.replace(anchorRegex, function (anchorString, attrs) {
|
|
@@ -131,25 +97,26 @@ var Infobox = /*#__PURE__*/function (_PureComponent) {
|
|
|
131
97
|
return hashRegex.exec(anchorString) ? "<a ".concat(_anchor.ARTICLE_ANCHOR_SCROLL, "=\"true\" ").concat(attrs, ">") : anchorString;
|
|
132
98
|
});
|
|
133
99
|
return mutatedContentHtmlString ? /*#__PURE__*/_react["default"].createElement(Container, {
|
|
134
|
-
className: className
|
|
135
|
-
|
|
100
|
+
className: className,
|
|
101
|
+
$forTrackingSection: forTrackingSection
|
|
102
|
+
}, title ? /*#__PURE__*/_react["default"].createElement(Title, {
|
|
103
|
+
$forTrackingSection: forTrackingSection
|
|
104
|
+
}, title) : null, /*#__PURE__*/_react["default"].createElement(Content, {
|
|
105
|
+
$forTrackingSection: forTrackingSection,
|
|
136
106
|
dangerouslySetInnerHTML: {
|
|
137
107
|
__html: mutatedContentHtmlString
|
|
138
108
|
}
|
|
139
109
|
})) : null;
|
|
140
110
|
}
|
|
141
111
|
}]);
|
|
142
|
-
|
|
143
112
|
return Infobox;
|
|
144
113
|
}(_react.PureComponent);
|
|
145
|
-
|
|
146
|
-
exports["default"] = Infobox;
|
|
147
|
-
|
|
148
114
|
_defineProperty(Infobox, "propTypes", {
|
|
149
115
|
className: _propTypes["default"].string,
|
|
150
|
-
data: _body["default"].elementData.isRequired
|
|
116
|
+
data: _body["default"].elementData.isRequired,
|
|
117
|
+
forTrackingSection: _propTypes["default"].bool
|
|
151
118
|
});
|
|
152
|
-
|
|
153
119
|
_defineProperty(Infobox, "defaultProps", {
|
|
154
|
-
className: ''
|
|
120
|
+
className: '',
|
|
121
|
+
forTrackingSection: false
|
|
155
122
|
});
|