@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.
Files changed (64) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/lib/components/article-page.js +42 -107
  3. package/lib/components/aside/desktop-aside.js +25 -65
  4. package/lib/components/aside/desktop-tools.js +11 -57
  5. package/lib/components/aside/metadata.js +22 -89
  6. package/lib/components/aside/mobile-tool-bar.js +79 -175
  7. package/lib/components/aside/utils/theme.js +5 -11
  8. package/lib/components/body/annotation.js +15 -73
  9. package/lib/components/body/audio/audio-contexts.js +4 -16
  10. package/lib/components/body/audio/audio-provider.js +13 -48
  11. package/lib/components/body/audio/control-button.js +4 -28
  12. package/lib/components/body/audio/index.js +10 -56
  13. package/lib/components/body/audio/seek-bar.js +6 -23
  14. package/lib/components/body/audio/time.js +0 -6
  15. package/lib/components/body/blockquote.js +11 -52
  16. package/lib/components/body/brief.js +10 -55
  17. package/lib/components/body/centered-quote.js +10 -52
  18. package/lib/components/body/embedded-code.js +22 -101
  19. package/lib/components/body/headings.js +6 -23
  20. package/lib/components/body/image-diff.js +13 -66
  21. package/lib/components/body/image.js +11 -46
  22. package/lib/components/body/index.js +55 -108
  23. package/lib/components/body/infobox.js +32 -65
  24. package/lib/components/body/list.js +8 -29
  25. package/lib/components/body/multimedia.js +10 -29
  26. package/lib/components/body/paragraph.js +5 -23
  27. package/lib/components/body/slider/index.js +28 -96
  28. package/lib/components/body/slideshow/index.js +36 -107
  29. package/lib/components/body/tracking-section.js +141 -0
  30. package/lib/components/body/youtube.js +8 -41
  31. package/lib/components/donation-box.js +10 -44
  32. package/lib/components/img-with-placeholder/index.js +34 -106
  33. package/lib/components/leading/extend.js +6 -25
  34. package/lib/components/leading/fullscreen.js +17 -63
  35. package/lib/components/leading/index.js +2 -10
  36. package/lib/components/leading/normal.js +19 -64
  37. package/lib/components/leading/pink.js +20 -59
  38. package/lib/components/leading/small.js +6 -25
  39. package/lib/components/license.js +9 -40
  40. package/lib/components/link.js +8 -37
  41. package/lib/components/related/card.js +20 -73
  42. package/lib/components/related/index.js +25 -71
  43. package/lib/components/related/list.js +16 -70
  44. package/lib/components/related/mockup.js +10 -12
  45. package/lib/components/separation-curve.js +0 -15
  46. package/lib/components/table-of-contents/index.js +17 -46
  47. package/lib/components/table-of-contents/styled.js +10 -38
  48. package/lib/constants/anchor.js +4 -8
  49. package/lib/constants/css.js +2 -15
  50. package/lib/constants/element-alignment.js +2 -3
  51. package/lib/constants/prop-types/article-page.js +2 -7
  52. package/lib/constants/prop-types/aside.js +2 -8
  53. package/lib/constants/prop-types/body.js +4 -9
  54. package/lib/constants/prop-types/img-with-placeholder.js +2 -7
  55. package/lib/constants/prop-types/leading.js +8 -13
  56. package/lib/constants/prop-types/related.js +2 -7
  57. package/lib/constants/theme.js +2 -3
  58. package/lib/constants/typography.js +2 -5
  59. package/lib/contexts/dynamic-components-context.js +2 -8
  60. package/lib/managers/layout-manager.js +13 -28
  61. package/lib/managers/theme-manager.js +13 -32
  62. package/lib/managers/ui-manager.js +14 -26
  63. package/lib/utils/image.js +5 -14
  64. package/package.json +6 -6
@@ -1,89 +1,58 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
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 _imgWithPlaceholder = _interopRequireDefault(require("../../img-with-placeholder"));
11
-
12
9
  var _multimedia = _interopRequireDefault(require("../multimedia"));
13
-
14
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
15
-
16
11
  var _react = _interopRequireWildcard(require("react"));
17
-
18
12
  var _get = _interopRequireDefault(require("lodash/get"));
19
-
20
13
  var _map = _interopRequireDefault(require("lodash/map"));
21
-
22
14
  var _memoizeOne = _interopRequireDefault(require("memoize-one"));
23
-
24
15
  var _mediaQuery = _interopRequireDefault(require("@twreporter/core/lib/utils/media-query"));
25
-
26
16
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
27
-
28
17
  var _theme = _interopRequireDefault(require("../../../constants/theme"));
29
-
30
18
  var _typography = _interopRequireDefault(require("../../../constants/typography"));
31
-
32
19
  var _color = require("@twreporter/core/lib/constants/color");
33
-
34
20
  var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19, _templateObject20, _templateObject21, _templateObject22, _templateObject23, _templateObject24;
35
-
36
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
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
-
21
+ 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); }
22
+ 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
23
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
41
-
42
24
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
43
-
44
- 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); } }
45
-
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); } }
46
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; }
47
-
48
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); }
49
-
50
28
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
51
-
52
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); }; }
53
-
54
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); }
55
-
56
31
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
57
-
58
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; } }
59
-
60
33
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
61
-
62
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
63
-
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); }
64
37
  function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
65
-
66
38
  var NextArrowSvg = function NextArrowSvg(props) {
67
39
  return /*#__PURE__*/_react["default"].createElement("svg", props, /*#__PURE__*/_react["default"].createElement("path", {
68
40
  d: "M29.33 7.854H0v1h29.256l-7.11 7.148.708.705 8-8.042-.001-.707-8-7.958-.706.709 7.183 7.145z",
69
41
  fill: "gray"
70
42
  }));
71
43
  };
72
-
73
44
  NextArrowSvg.defaultProps = {
74
45
  viewBox: "0 0 31 17",
75
46
  width: "31",
76
47
  height: "17",
77
48
  xmlns: "http://www.w3.org/2000/svg"
78
49
  };
79
-
80
50
  var PreArrowSvg = function PreArrowSvg(props) {
81
51
  return /*#__PURE__*/_react["default"].createElement("svg", props, /*#__PURE__*/_react["default"].createElement("path", {
82
52
  d: "M2.17 8.5H31.5v1H2.244l7.11 7.147-.708.706-8-8.042.001-.707 8-7.958.706.708L2.17 8.5z",
83
53
  fill: "gray"
84
54
  }));
85
55
  };
86
-
87
56
  PreArrowSvg.defaultProps = {
88
57
  viewBox: "0 0 31 17",
89
58
  width: "31",
@@ -98,76 +67,77 @@ var mockup = {
98
67
  mobile: {
99
68
  container: {
100
69
  width: 375 // px
101
-
102
70
  },
71
+
103
72
  slide: {
104
73
  width: 339,
105
74
  // px
106
75
  height: 189,
107
76
  // px
108
77
  paddingRight: 2 // px
109
-
110
78
  },
79
+
111
80
  offset: {
112
81
  left: 18 // px
113
-
114
82
  }
115
83
  },
84
+
116
85
  tablet: {
117
86
  container: {
118
87
  width: 768 // px
119
-
120
88
  },
89
+
121
90
  slide: {
122
91
  width: 687,
123
92
  // px
124
93
  height: 387,
125
94
  // px
126
95
  paddingRight: 4 // px
127
-
128
96
  },
97
+
129
98
  offset: {
130
99
  left: 41 // px
131
-
132
100
  }
133
101
  },
102
+
134
103
  desktop: {
135
104
  container: {
136
105
  width: 752 // px
137
-
138
106
  },
107
+
139
108
  slide: {
140
109
  width: 688,
141
110
  // px
142
111
  height: 387,
143
112
  // px
144
113
  paddingRight: 4 // px
145
-
146
114
  },
115
+
147
116
  offset: {
148
117
  left: 32 // px
149
-
150
118
  }
151
119
  },
120
+
152
121
  hd: {
153
122
  container: {
154
123
  width: 1034 // px
155
-
156
124
  },
125
+
157
126
  slide: {
158
127
  width: 944,
159
128
  // px
160
129
  height: 531,
161
130
  // px
162
131
  paddingRight: 4 // px
163
-
164
132
  },
133
+
165
134
  offset: {
166
135
  left: 45 // px
167
-
168
136
  }
169
137
  }
170
- }; // Assuming there are three images [ A, B, C ] for slideshow.
138
+ };
139
+
140
+ // Assuming there are three images [ A, B, C ] for slideshow.
171
141
  // If image B is rendered in the center,
172
142
  // users can see part of image A(left side) and image C(right side) with masks.
173
143
  // When users click right button to see image C, which means, C is in the center,
@@ -178,43 +148,37 @@ var mockup = {
178
148
  //
179
149
  // `slidesOffset` indicates how many slides rendered before/after image B, which is, 2 (A and C).
180
150
  //
151
+ var slidesOffset = 2;
181
152
 
182
- var slidesOffset = 2; // duration of transition of transform(translateX(?px))
183
-
184
- var duration = 300; // current index to indicate which image should be rendered in the center
153
+ // duration of transition of transform(translateX(?px))
154
+ var duration = 300;
185
155
 
156
+ // current index to indicate which image should be rendered in the center
186
157
  var defaultCurIndex = 0;
187
-
188
158
  var SlidesSection = /*#__PURE__*/_styledComponents["default"].div.withConfig({
189
159
  displayName: "slideshow__SlidesSection",
190
160
  componentId: "sc-1skir21-0"
191
161
  })(["flex-shrink:0;flex-basis:100%;overflow:hidden;position:relative;width:100%;aspect-ratio:3 / 2;", ""], _mediaQuery["default"].tabletAndBelow(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n order: 2;\n "]))));
192
-
193
162
  var PrevNextSection = /*#__PURE__*/_styledComponents["default"].div.withConfig({
194
163
  displayName: "slideshow__PrevNextSection",
195
164
  componentId: "sc-1skir21-1"
196
165
  })(["margin-top:20px;", " ", " ", ""], _mediaQuery["default"].tabletAndBelow(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n order: 3;\n "]))), _mediaQuery["default"].mobileOnly(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n margin-left: 25px;\n "]))), _mediaQuery["default"].tabletOnly(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n margin-left: 47px;\n "]))));
197
-
198
166
  var PrevButton = /*#__PURE__*/_styledComponents["default"].div.withConfig({
199
167
  displayName: "slideshow__PrevButton",
200
168
  componentId: "sc-1skir21-2"
201
169
  })(["cursor:pointer;width:59px;height:59px;display:inline-flex;border:solid 1px;> svg{margin:auto;width:21px;}", " &:hover{> svg{transform:translateX(-5px);transition:transform 0.3s ease;}}"], _mediaQuery["default"].hdOnly(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n width: 83px;\n height: 83px;\n\n > svg {\n width: 31px;\n }\n "]))));
202
-
203
170
  var NextButton = /*#__PURE__*/(0, _styledComponents["default"])(PrevButton).withConfig({
204
171
  displayName: "slideshow__NextButton",
205
172
  componentId: "sc-1skir21-3"
206
173
  })(["border-left:none;&:hover{> svg{transform:translateX(5px);}}"]);
207
-
208
174
  var ImageNumberCircle = /*#__PURE__*/_styledComponents["default"].div.withConfig({
209
175
  displayName: "slideshow__ImageNumberCircle",
210
176
  componentId: "sc-1skir21-4"
211
177
  })(["display:inline-block;width:80px;height:80px;border-radius:50%;vertical-align:top;position:relative;&::after{content:'';position:absolute;width:62px;border-top:solid 1px;transform:rotate(-45deg);transform-origin:bottom left;top:67px;left:7px;}", " ", " ", ""], _mediaQuery["default"].tabletAndBelow(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n order: 1;\n\n /* align right */\n margin-left: auto;\n /* 10px is the border-right width of body */\n margin-right: 10px;\n "]))), _mediaQuery["default"].desktopAndAbove(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n margin-top: 6px;\n\n /* align right */\n margin-left: auto;\n "]))), _mediaQuery["default"].hdOnly(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n margin-right: -18px;\n width: 110px;\n height: 110px;\n\n &::after {\n width: 89px;\n top: 93px;\n left: 10px;\n }\n "]))));
212
-
213
178
  var ImageNumber = /*#__PURE__*/_styledComponents["default"].span.withConfig({
214
179
  displayName: "slideshow__ImageNumber",
215
180
  componentId: "sc-1skir21-5"
216
181
  })(["position:absolute;top:25px;left:9px;font-size:24px;font-weight:", ";line-height:0.79;", ""], _typography["default"].font.weight.bold, _mediaQuery["default"].hdOnly(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n top: 35px;\n left: 10px;\n "]))));
217
-
218
182
  var ImageTotal = /*#__PURE__*/(0, _styledComponents["default"])(ImageNumber).withConfig({
219
183
  displayName: "slideshow__ImageTotal",
220
184
  componentId: "sc-1skir21-6"
@@ -227,7 +191,6 @@ var EmptyDesc = /*#__PURE__*/(0, _styledComponents["default"])(Desc).withConfig(
227
191
  displayName: "slideshow__EmptyDesc",
228
192
  componentId: "sc-1skir21-8"
229
193
  })(["&::after{border-bottom:none;}"]);
230
-
231
194
  var SlidesFlexBox = /*#__PURE__*/_styledComponents["default"].div.withConfig({
232
195
  displayName: "slideshow__SlidesFlexBox",
233
196
  componentId: "sc-1skir21-9"
@@ -244,32 +207,28 @@ var SlidesFlexBox = /*#__PURE__*/_styledComponents["default"].div.withConfig({
244
207
  }), _mediaQuery["default"].hdOnly(_templateObject17 || (_templateObject17 = _taggedTemplateLiteral(["\n transform: translateX(", "px);\n "])), function (props) {
245
208
  return getTranslateX(mockup.hd, props.$translateXUint);
246
209
  }));
247
-
248
210
  var SlideFlexItem = /*#__PURE__*/_styledComponents["default"].div.withConfig({
249
211
  displayName: "slideshow__SlideFlexItem",
250
212
  componentId: "sc-1skir21-10"
251
213
  })(["height:100%;flex-shrink:0;", " ", " ", " ", ""], _mediaQuery["default"].mobileOnly(_templateObject18 || (_templateObject18 = _taggedTemplateLiteral(["\n flex-basis: calc(", "/", "*100%);\n padding-right: calc(", "/", "*100%);\n "])), getSlideWidth(mockup.mobile), getContainerWidth(mockup.mobile), mockup.mobile.slide.paddingRight, getContainerWidth(mockup.mobile)), _mediaQuery["default"].tabletOnly(_templateObject19 || (_templateObject19 = _taggedTemplateLiteral(["\n flex-basis: calc(", "/", "*100%);\n padding-right: calc(", "/", "*100%);\n "])), getSlideWidth(mockup.tablet), getContainerWidth(mockup.tablet), mockup.tablet.slide.paddingRight, getContainerWidth(mockup.tablet)), _mediaQuery["default"].desktopOnly(_templateObject20 || (_templateObject20 = _taggedTemplateLiteral(["\n flex-basis: ", "px;\n padding-right: ", "px;\n "])), getSlideWidth(mockup.desktop), mockup.desktop.slide.paddingRight), _mediaQuery["default"].hdOnly(_templateObject21 || (_templateObject21 = _taggedTemplateLiteral(["\n flex-basis: ", "px;\n padding-right: ", "px;\n "])), getSlideWidth(mockup.hd), mockup.hd.slide.paddingRight));
252
-
253
214
  var SlideshowFlexBox = /*#__PURE__*/_styledComponents["default"].div.withConfig({
254
215
  displayName: "slideshow__SlideshowFlexBox",
255
216
  componentId: "sc-1skir21-11"
256
217
  })(["", " width:100%;display:flex;justify-content:space-between;flex-wrap:wrap;", " ", " ", ""], function (props) {
257
218
  return getSlideshowFlexBoxStyles(props.theme.name);
258
219
  }, _mediaQuery["default"].tabletAndBelow(_templateObject22 || (_templateObject22 = _taggedTemplateLiteral(["\n width: 100%;\n "]))), _mediaQuery["default"].desktopOnly(_templateObject23 || (_templateObject23 = _taggedTemplateLiteral(["\n width: ", "px;\n "])), mockup.desktop.container.width), _mediaQuery["default"].hdOnly(_templateObject24 || (_templateObject24 = _taggedTemplateLiteral(["\n width: ", "px;\n "])), mockup.hd.container.width));
259
-
260
220
  function getSlideshowFlexBoxStyles(themeName) {
261
221
  switch (themeName) {
262
222
  case _theme["default"].article.v2.photo:
263
223
  return (0, _styledComponents.css)(["", "{border-color:", ";}", "{background-color:", ";&::after{border-color:", ";}}", "{color:", ";}"], PrevButton, _color.colorGrayscale.gray400, ImageNumberCircle, _color.colorSupportive.main, _color.COLOR_PINK_ARTICLE.darkBlue, ImageNumber, _color.COLOR_PINK_ARTICLE.darkBlue);
264
-
265
224
  case _theme["default"].article.v2.pink:
266
225
  return (0, _styledComponents.css)(["", "{border-color:", ";}", "{background-color:", ";&::after{border-color:", ";}}", "{color:", ";}"], PrevButton, _color.colorGrayscale.gray300, ImageNumberCircle, _color.COLOR_PINK_ARTICLE.pink, _color.colorGrayscale.white, ImageNumber, _color.colorGrayscale.white);
267
-
268
226
  case _theme["default"].article.v2["default"]:
269
227
  default:
270
228
  return (0, _styledComponents.css)(["", "{border-color:", ";}", "{background-color:", ";&::after{border-color:", ";}}", "{color:", ";}"], PrevButton, _color.colorGrayscale.gray300, ImageNumberCircle, _color.colorSupportive.main, _color.colorGrayscale.white, ImageNumber, _color.colorGrayscale.white);
271
229
  }
272
230
  }
231
+
273
232
  /**
274
233
  * @typedef {Object} SlideMockup
275
234
  * @property {number} width
@@ -299,58 +258,48 @@ function getSlideshowFlexBoxStyles(themeName) {
299
258
  * @param {number} unit
300
259
  * @return {number}
301
260
  */
302
-
303
-
304
261
  function getTranslateX(deviceMockup, unit) {
305
- var slideWidth = getSlideWidth(deviceMockup); // total slides width including padding
262
+ var slideWidth = getSlideWidth(deviceMockup);
306
263
 
307
- var translateX = unit * slideWidth; // add left mask width and padding
264
+ // total slides width including padding
265
+ var translateX = unit * slideWidth;
308
266
 
267
+ // add left mask width and padding
309
268
  translateX = translateX + deviceMockup.offset.left;
310
269
  return translateX; // px
311
270
  }
271
+
312
272
  /**
313
273
  * @param {DeviceMockup} deviceMockup
314
274
  * @return {number}
315
275
  */
316
-
317
-
318
276
  function getContainerWidth(deviceMockup) {
319
277
  return deviceMockup.container.width;
320
278
  }
279
+
321
280
  /**
322
281
  * @param {DeviceMockup} deviceMockup
323
282
  * @return {number}
324
283
  */
325
-
326
-
327
284
  function getSlideWidth(deviceMockup) {
328
285
  return deviceMockup.slide.width + deviceMockup.slide.paddingRight;
329
286
  }
330
-
331
287
  var imageProp = _propTypes["default"].shape({
332
288
  url: _propTypes["default"].string.isRequired
333
289
  });
334
-
335
290
  var contentProp = _propTypes["default"].arrayOf(_propTypes["default"].shape({
336
291
  description: _propTypes["default"].string,
337
292
  desktop: imageProp.isRequired,
338
293
  mobile: imageProp.isRequired,
339
294
  tablet: imageProp.isRequired
340
295
  }));
341
-
342
- var Slideshow = /*#__PURE__*/function (_PureComponent) {
296
+ var Slideshow = exports["default"] = /*#__PURE__*/function (_PureComponent) {
343
297
  _inherits(Slideshow, _PureComponent);
344
-
345
298
  var _super = _createSuper(Slideshow);
346
-
347
299
  function Slideshow(props) {
348
300
  var _this;
349
-
350
301
  _classCallCheck(this, Slideshow);
351
-
352
302
  _this = _super.call(this, props);
353
-
354
303
  _defineProperty(_assertThisInitialized(_this), "buildSlides", (0, _memoizeOne["default"])(function (images) {
355
304
  // add last `slidesOffset` elements into top of images array.
356
305
  // add first `slidesOffset` elements into bottom of images array.
@@ -359,7 +308,6 @@ var Slideshow = /*#__PURE__*/function (_PureComponent) {
359
308
  // input images: [ a, b, c, d ]
360
309
  // output images: [c, d, a, b, c, d, a, b]
361
310
  var _images = [].concat(images.slice(-slidesOffset), images, images.slice(defaultCurIndex, slidesOffset));
362
-
363
311
  return _.map(_images, function (img, index) {
364
312
  return (
365
313
  /*#__PURE__*/
@@ -376,7 +324,6 @@ var Slideshow = /*#__PURE__*/function (_PureComponent) {
376
324
  );
377
325
  });
378
326
  }));
379
-
380
327
  _this.defaultTranslateXUnit = -slidesOffset;
381
328
  _this.state = {
382
329
  // value of curSlideIndex would be in [ 0 ~ props.data.content.length ] range,
@@ -389,24 +336,19 @@ var Slideshow = /*#__PURE__*/function (_PureComponent) {
389
336
  _this.slideToNext = _this._slideToNext.bind(_assertThisInitialized(_this));
390
337
  return _this;
391
338
  }
392
-
393
339
  _createClass(Slideshow, [{
394
340
  key: "_slideToPrev",
395
341
  value: function _slideToPrev() {
396
342
  var _this2 = this;
397
-
398
343
  var total = _.get(this.props, 'data.content.length', 0);
399
-
400
344
  this.setState({
401
345
  isSliding: true,
402
346
  translateXUint: this.state.translateXUint + 1
403
347
  }, function () {
404
348
  var curSlideIndex = _this2.state.curSlideIndex - 1;
405
-
406
349
  if (curSlideIndex < defaultCurIndex) {
407
350
  curSlideIndex = total + curSlideIndex;
408
351
  }
409
-
410
352
  setTimeout(function () {
411
353
  _this2.setState({
412
354
  isSliding: false,
@@ -420,19 +362,15 @@ var Slideshow = /*#__PURE__*/function (_PureComponent) {
420
362
  key: "_slideToNext",
421
363
  value: function _slideToNext() {
422
364
  var _this3 = this;
423
-
424
365
  var total = _.get(this.props, 'data.content.length', 0);
425
-
426
366
  this.setState({
427
367
  isSliding: true,
428
368
  translateXUint: this.state.translateXUint - 1
429
369
  }, function () {
430
370
  var curSlideIndex = _this3.state.curSlideIndex + 1;
431
-
432
371
  if (curSlideIndex >= total) {
433
372
  curSlideIndex = curSlideIndex % total;
434
373
  }
435
-
436
374
  setTimeout(function () {
437
375
  _this3.setState({
438
376
  isSliding: false,
@@ -447,17 +385,13 @@ var Slideshow = /*#__PURE__*/function (_PureComponent) {
447
385
  value: function render() {
448
386
  var className = this.props.className;
449
387
  var _this$state = this.state,
450
- curSlideIndex = _this$state.curSlideIndex,
451
- isSliding = _this$state.isSliding,
452
- translateXUint = _this$state.translateXUint;
453
-
388
+ curSlideIndex = _this$state.curSlideIndex,
389
+ isSliding = _this$state.isSliding,
390
+ translateXUint = _this$state.translateXUint;
454
391
  var images = _.get(this.props, 'data.content', []);
455
-
456
392
  var total = images.length;
457
393
  var slides = this.buildSlides(images);
458
-
459
394
  var desc = _.get(images, [curSlideIndex, 'description']);
460
-
461
395
  var appendedClassName = className + ' avoid-break';
462
396
  return /*#__PURE__*/_react["default"].createElement(SlideshowFlexBox, {
463
397
  className: appendedClassName
@@ -472,19 +406,14 @@ var Slideshow = /*#__PURE__*/function (_PureComponent) {
472
406
  }, /*#__PURE__*/_react["default"].createElement(NextArrowSvg, null))), /*#__PURE__*/_react["default"].createElement(ImageNumberCircle, null, /*#__PURE__*/_react["default"].createElement(ImageNumber, null, curSlideIndex + 1), /*#__PURE__*/_react["default"].createElement(ImageTotal, null, total)), desc ? /*#__PURE__*/_react["default"].createElement(Desc, null, desc) : /*#__PURE__*/_react["default"].createElement(EmptyDesc, null));
473
407
  }
474
408
  }]);
475
-
476
409
  return Slideshow;
477
410
  }(_react.PureComponent);
478
-
479
- exports["default"] = Slideshow;
480
-
481
411
  _defineProperty(Slideshow, "propTypes", {
482
412
  className: _propTypes["default"].string,
483
413
  data: _propTypes["default"].shape({
484
414
  content: contentProp.isRequired
485
415
  })
486
416
  });
487
-
488
417
  _defineProperty(Slideshow, "defaultProps", {
489
418
  className: '',
490
419
  data: {
@@ -0,0 +1,141 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
9
+ var _propTypes = _interopRequireDefault(require("prop-types"));
10
+ var _color = require("@twreporter/core/lib/constants/color");
11
+ var _paragraph = require("@twreporter/react-components/lib/text/paragraph");
12
+ var _headline = require("@twreporter/react-components/lib/text/headline");
13
+ var _date = require("@twreporter/core/lib/utils/date");
14
+ var _mediaQuery = _interopRequireDefault(require("@twreporter/core/lib/utils/media-query"));
15
+ var _body = _interopRequireDefault(require("../../constants/prop-types/body"));
16
+ var _annotation = _interopRequireDefault(require("./annotation"));
17
+ var _paragraph2 = _interopRequireDefault(require("./paragraph"));
18
+ var _image = _interopRequireDefault(require("./image"));
19
+ var _infobox = _interopRequireDefault(require("./infobox"));
20
+ var _list = _interopRequireDefault(require("./list"));
21
+ var _centeredQuote = _interopRequireDefault(require("./centered-quote"));
22
+ var _blockquote = _interopRequireDefault(require("./blockquote"));
23
+ var _map = _interopRequireDefault(require("lodash/map"));
24
+ var _templateObject, _templateObject2, _templateObject3; // @twreporter
25
+ // constants
26
+ // components
27
+ // lodash
28
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
29
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
30
+ var _ = {
31
+ map: _map["default"]
32
+ };
33
+ var TrackingSectionContainer = /*#__PURE__*/_styledComponents["default"].div.withConfig({
34
+ displayName: "tracking-section__TrackingSectionContainer",
35
+ componentId: "sc-104lyb5-0"
36
+ })(["display:flex;flex-direction:column;width:100%;"]);
37
+ var Dot = /*#__PURE__*/_styledComponents["default"].div.withConfig({
38
+ displayName: "tracking-section__Dot",
39
+ componentId: "sc-104lyb5-1"
40
+ })(["width:8px;height:8px;background-color:", ";border-radius:50%;"], _color.colorSupportive.heavy);
41
+ var P2Gray600 = /*#__PURE__*/(0, _styledComponents["default"])(_paragraph.P2).withConfig({
42
+ displayName: "tracking-section__P2Gray600",
43
+ componentId: "sc-104lyb5-2"
44
+ })(["color:", ";"], _color.colorGrayscale.gray600);
45
+ var H4Gray800 = /*#__PURE__*/(0, _styledComponents["default"])(_headline.H4).withConfig({
46
+ displayName: "tracking-section__H4Gray800",
47
+ componentId: "sc-104lyb5-3"
48
+ })(["color:", ";"], _color.colorGrayscale.gray800);
49
+ var DateRow = /*#__PURE__*/_styledComponents["default"].div.withConfig({
50
+ displayName: "tracking-section__DateRow",
51
+ componentId: "sc-104lyb5-4"
52
+ })(["display:flex;width:100%;gap:24px;&:first-child{align-items:center;}"]);
53
+ var ContentContainer = /*#__PURE__*/_styledComponents["default"].div.withConfig({
54
+ displayName: "tracking-section__ContentContainer",
55
+ componentId: "sc-104lyb5-5"
56
+ })(["display:flex;margin-top:20px;margin-left:4px;border-left:1px solid ", ";"], _color.colorGrayscale.gray300);
57
+ var Content = /*#__PURE__*/_styledComponents["default"].div.withConfig({
58
+ displayName: "tracking-section__Content",
59
+ componentId: "sc-104lyb5-6"
60
+ })(["display:flex;flex-direction:column;margin-left:24px;gap:20px;"]);
61
+ var InfoBoxContainer = /*#__PURE__*/_styledComponents["default"].div.withConfig({
62
+ displayName: "tracking-section__InfoBoxContainer",
63
+ componentId: "sc-104lyb5-7"
64
+ })(["", " ", " ", ""], _mediaQuery["default"].mobileOnly(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n width: 296px;\n "]))), _mediaQuery["default"].tabletOnly(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n width: 456px;\n "]))), _mediaQuery["default"].desktopAndAbove(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n width: 556px;\n "]))));
65
+ var TrackingSection = function TrackingSection(_ref) {
66
+ var data = _ref.data;
67
+ var title = data.title,
68
+ publishDate = data.publishDate,
69
+ content = data.content;
70
+ var createContentElement = function createContentElement(data, idx) {
71
+ if (!data.id) {
72
+ data.id = "body_element_".concat(idx);
73
+ }
74
+ switch (data.type) {
75
+ case 'annotation':
76
+ return /*#__PURE__*/_react["default"].createElement(_annotation["default"], {
77
+ key: data.id,
78
+ data: data
79
+ });
80
+ case 'centered-quote':
81
+ case 'quoteby':
82
+ return /*#__PURE__*/_react["default"].createElement(_centeredQuote["default"], {
83
+ key: data.id,
84
+ data: data
85
+ });
86
+ case 'blockquote':
87
+ return /*#__PURE__*/_react["default"].createElement(_blockquote["default"], {
88
+ key: data.id,
89
+ data: data
90
+ });
91
+ case 'unstyled':
92
+ return /*#__PURE__*/_react["default"].createElement(_paragraph2["default"], {
93
+ key: data.id,
94
+ data: data
95
+ });
96
+ case 'small-image':
97
+ case 'image':
98
+ case 'image-link':
99
+ return /*#__PURE__*/_react["default"].createElement(_image["default"], {
100
+ key: data.id,
101
+ data: data
102
+ });
103
+ case 'infobox':
104
+ return /*#__PURE__*/_react["default"].createElement(InfoBoxContainer, {
105
+ key: data.id
106
+ }, /*#__PURE__*/_react["default"].createElement(_infobox["default"], {
107
+ data: data,
108
+ forTrackingSection: true
109
+ }));
110
+ case 'ordered-list-item':
111
+ return /*#__PURE__*/_react["default"].createElement(_list["default"].OrderedList, {
112
+ key: data.id,
113
+ data: data
114
+ });
115
+ case 'unordered-list-item':
116
+ return /*#__PURE__*/_react["default"].createElement(_list["default"].UnorderedList, {
117
+ key: data.id,
118
+ data: data
119
+ });
120
+ default:
121
+ return null;
122
+ }
123
+ };
124
+ var contentJSX = Array.isArray(content) ? _.map(content, function (data, idx) {
125
+ var elementJSX = createContentElement(data, idx);
126
+ return elementJSX;
127
+ }) : null;
128
+ return /*#__PURE__*/_react["default"].createElement(TrackingSectionContainer, null, /*#__PURE__*/_react["default"].createElement(DateRow, null, /*#__PURE__*/_react["default"].createElement(Dot, null), /*#__PURE__*/_react["default"].createElement(P2Gray600, {
129
+ text: (0, _date.date2yyyymmdd)(publishDate, '/')
130
+ })), /*#__PURE__*/_react["default"].createElement(ContentContainer, null, /*#__PURE__*/_react["default"].createElement(Content, null, /*#__PURE__*/_react["default"].createElement(H4Gray800, {
131
+ text: title
132
+ }), contentJSX)));
133
+ };
134
+ TrackingSection.propTypes = {
135
+ data: _propTypes["default"].shape({
136
+ title: _propTypes["default"].string,
137
+ publishDate: _propTypes["default"].string,
138
+ content: _propTypes["default"].arrayOf(_body["default"].elementData)
139
+ }).isRequired
140
+ };
141
+ var _default = exports["default"] = TrackingSection;