@twreporter/react-components 8.5.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 (43) hide show
  1. package/CHANGELOG.md +544 -0
  2. package/LICENSE +21 -0
  3. package/README.md +46 -0
  4. package/lib/bookmark-list/bookmark.js +251 -0
  5. package/lib/bookmark-list/bookmarks.js +93 -0
  6. package/lib/bookmark-list/customized-link.js +45 -0
  7. package/lib/bookmark-list/image-wrapper.js +119 -0
  8. package/lib/bookmark-list/index.js +312 -0
  9. package/lib/bookmark-list/redirect-to-sign-in.js +35 -0
  10. package/lib/bookmark-widget/index.js +259 -0
  11. package/lib/confirmation/index.js +125 -0
  12. package/lib/donation-link.js +75 -0
  13. package/lib/error/index.js +17 -0
  14. package/lib/error/message.js +567 -0
  15. package/lib/footer/constants/paths.js +8 -0
  16. package/lib/footer/constants/styles.js +81 -0
  17. package/lib/footer/content.js +227 -0
  18. package/lib/footer/icon-list.js +191 -0
  19. package/lib/footer/index.js +123 -0
  20. package/lib/footer/logo.js +92 -0
  21. package/lib/is-fetching-wrapper.js +126 -0
  22. package/lib/link-with-tracker.js +153 -0
  23. package/lib/listing-page/components/image.js +185 -0
  24. package/lib/listing-page/components/list-item.js +197 -0
  25. package/lib/listing-page/components/list.js +188 -0
  26. package/lib/listing-page/components/topics/index.js +215 -0
  27. package/lib/listing-page/components/topics/page-content.js +44 -0
  28. package/lib/listing-page/components/topics/post-item.js +139 -0
  29. package/lib/listing-page/components/topics/posts.js +24 -0
  30. package/lib/listing-page/components/topics/section.js +104 -0
  31. package/lib/listing-page/components/topics/topic-item.js +206 -0
  32. package/lib/listing-page/constants/mockup-spec.js +39 -0
  33. package/lib/listing-page/constants/predefined-css.js +21 -0
  34. package/lib/listing-page/constants/topics.js +13 -0
  35. package/lib/listing-page/index.js +30 -0
  36. package/lib/mobile-pop-up-modal.js +161 -0
  37. package/lib/more.js +98 -0
  38. package/lib/pagination/index.js +310 -0
  39. package/lib/podcast-link.js +73 -0
  40. package/lib/side-bar/index.js +317 -0
  41. package/lib/table-of-contents/index.js +532 -0
  42. package/lib/utils/link-with-params.js +27 -0
  43. package/package.json +33 -0
@@ -0,0 +1,197 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = void 0;
9
+
10
+ var _entityPath = _interopRequireDefault(require("@twreporter/core/lib/constants/entity-path"));
11
+
12
+ var _fontWeight = require("@twreporter/core/lib/constants/font-weight");
13
+
14
+ var _image = _interopRequireDefault(require("./image"));
15
+
16
+ var _reactRouterDom = require("react-router-dom");
17
+
18
+ var _mockupSpec = _interopRequireDefault(require("../constants/mockup-spec"));
19
+
20
+ var _mediaQuery = _interopRequireDefault(require("@twreporter/core/lib/utils/media-query"));
21
+
22
+ var _propTypes = _interopRequireDefault(require("prop-types"));
23
+
24
+ var _react = _interopRequireWildcard(require("react"));
25
+
26
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
27
+
28
+ var _forEach = _interopRequireDefault(require("lodash/forEach"));
29
+
30
+ var _get = _interopRequireDefault(require("lodash/get"));
31
+
32
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9;
33
+
34
+ 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); }
35
+
36
+ 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; }
37
+
38
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
39
+
40
+ 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
+
44
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
45
+
46
+ 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); }
47
+
48
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
49
+
50
+ 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
+ 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
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
55
+
56
+ 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
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
59
+
60
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
61
+
62
+ var _ = {
63
+ forEach: _forEach["default"],
64
+ get: _get["default"]
65
+ };
66
+
67
+ var Container = /*#__PURE__*/_styledComponents["default"].div.withConfig({
68
+ displayName: "list-item__Container",
69
+ componentId: "sc-1dx5lew-0"
70
+ })(["width:", "px;", " ", " ", " a{color:#4a4949;}"], _mockupSpec["default"].hd.cardWidth, _mediaQuery["default"].desktopOnly(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n width: ", "px;\n "])), _mockupSpec["default"].desktop.cardWidth), _mediaQuery["default"].tabletOnly(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n width: ", "px;\n "])), _mockupSpec["default"].tablet.cardWidth), _mediaQuery["default"].mobileOnly(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n width: ", "%;\n "])), _mockupSpec["default"].mobile.cardWidth / _mockupSpec["default"].mobile.maxWidth * 100));
71
+
72
+ var HoverEffect = /*#__PURE__*/_styledComponents["default"].div.withConfig({
73
+ displayName: "list-item__HoverEffect",
74
+ componentId: "sc-1dx5lew-1"
75
+ })(["opacity:1;", ""], _mediaQuery["default"].tabletAndAbove(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n &:hover {\n opacity: 0.7;\n }\n transition: 200ms opacity linear;\n "]))));
76
+
77
+ var ImgFrame = /*#__PURE__*/_styledComponents["default"].div.withConfig({
78
+ displayName: "list-item__ImgFrame",
79
+ componentId: "sc-1dx5lew-2"
80
+ })(["height:", "px;", " ", " ", ""], _mockupSpec["default"].hd.imgHeight, _mediaQuery["default"].desktopOnly(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n height: ", "px;\n "])), _mockupSpec["default"].desktop.imgHeight), _mediaQuery["default"].tabletOnly(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n height: ", "px;\n "])), _mockupSpec["default"].tablet.imgHeight), _mediaQuery["default"].mobileOnly(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n height: ", "px;\n "])), _mockupSpec["default"].mobile.imgHeight));
81
+
82
+ var TextBlock = /*#__PURE__*/_styledComponents["default"].div.withConfig({
83
+ displayName: "list-item__TextBlock",
84
+ componentId: "sc-1dx5lew-3"
85
+ })(["width:", "%;margin:12px auto 0 auto;cursor:pointer;", ""], _mockupSpec["default"].desktop.textWidth / _mockupSpec["default"].desktop.cardWidth * 100, _mediaQuery["default"].mobileOnly(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n width: 100%;\n "]))));
86
+
87
+ var Category = /*#__PURE__*/_styledComponents["default"].div.withConfig({
88
+ displayName: "list-item__Category",
89
+ componentId: "sc-1dx5lew-4"
90
+ })(["color:#c4333e;font-size:12px;line-height:1.33;margin-bottom:10px;"]);
91
+
92
+ var Title = /*#__PURE__*/_styledComponents["default"].div.withConfig({
93
+ displayName: "list-item__Title",
94
+ componentId: "sc-1dx5lew-5"
95
+ })(["font-size:20px;font-weight:", ";line-height:1.4;color:#4a4949;margin-bottom:10px;"], _fontWeight.sourceHanSansTC.bold);
96
+
97
+ var Desc = /*#__PURE__*/_styledComponents["default"].div.withConfig({
98
+ displayName: "list-item__Desc",
99
+ componentId: "sc-1dx5lew-6"
100
+ })(["position:relative;font-size:16px;line-height:1.5;text-align:justify;padding-bottom:30px;"]);
101
+
102
+ var Tags = /*#__PURE__*/_styledComponents["default"].ul.withConfig({
103
+ displayName: "list-item__Tags",
104
+ componentId: "sc-1dx5lew-7"
105
+ })(["list-style:none;width:", "%;margin-bottom:40px;padding-left:15px;line-height:1;", ""], _mockupSpec["default"].desktop.tagsWidth / _mockupSpec["default"].desktop.cardWidth * 100, _mediaQuery["default"].mobileOnly(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n width: ", "%;\n padding-left: 0;\n "])), _mockupSpec["default"].mobile.tagsWidth / _mockupSpec["default"].mobile.cardWidth * 100));
106
+
107
+ var PubDate = /*#__PURE__*/_styledComponents["default"].div.withConfig({
108
+ displayName: "list-item__PubDate",
109
+ componentId: "sc-1dx5lew-8"
110
+ })(["position:absolute;bottom:-20px;font-size:12px;right:0;"]);
111
+
112
+ var Tag = /*#__PURE__*/_styledComponents["default"].li.withConfig({
113
+ displayName: "list-item__Tag",
114
+ componentId: "sc-1dx5lew-9"
115
+ })(["background-color:", ";border:2px solid #c4333e;border-radius:68px;color:", ";display:inline-block;text-decoration:none;line-height:1.45;font-size:12px;font-weight:", ";padding:2px 10px;margin-right:13px;margin-bottom:10px;"], function (props) {
116
+ return props.selected ? '#c4333e' : '#f1f1f1';
117
+ }, function (props) {
118
+ return props.selected ? '#ffffff' : '#c4333e';
119
+ }, _fontWeight.sourceHanSansTC.bold);
120
+
121
+ var ListItem = /*#__PURE__*/function (_PureComponent) {
122
+ _inherits(ListItem, _PureComponent);
123
+
124
+ var _super = _createSuper(ListItem);
125
+
126
+ function ListItem() {
127
+ _classCallCheck(this, ListItem);
128
+
129
+ return _super.apply(this, arguments);
130
+ }
131
+
132
+ _createClass(ListItem, [{
133
+ key: "render",
134
+ value: function render() {
135
+ var _this$props = this.props,
136
+ title = _this$props.title,
137
+ desc = _this$props.desc,
138
+ img = _this$props.img,
139
+ link = _this$props.link,
140
+ category = _this$props.category,
141
+ tags = _this$props.tags,
142
+ pubDate = _this$props.pubDate;
143
+ var tagsJSX = [];
144
+
145
+ _.forEach(tags, function (tag) {
146
+ var id = _.get(tag, 'id');
147
+
148
+ var name = _.get(tag, 'name');
149
+
150
+ if (id && name) {
151
+ tagsJSX.push( /*#__PURE__*/_react["default"].createElement(_reactRouterDom.Link, {
152
+ key: id,
153
+ to: _entityPath["default"].tag + id
154
+ }, /*#__PURE__*/_react["default"].createElement(Tag, {
155
+ selected: _.get(tag, 'selected')
156
+ }, name)));
157
+ }
158
+ });
159
+
160
+ return /*#__PURE__*/_react["default"].createElement(Container, null, /*#__PURE__*/_react["default"].createElement(_reactRouterDom.Link, link, /*#__PURE__*/_react["default"].createElement(HoverEffect, null, /*#__PURE__*/_react["default"].createElement(ImgFrame, null, /*#__PURE__*/_react["default"].createElement(_image["default"], {
161
+ alt: _.get(img, 'alt', ''),
162
+ src: _.get(img, 'src', '')
163
+ })), /*#__PURE__*/_react["default"].createElement(TextBlock, null, /*#__PURE__*/_react["default"].createElement(Category, null, category), /*#__PURE__*/_react["default"].createElement(Title, null, title), /*#__PURE__*/_react["default"].createElement(Desc, null, desc, /*#__PURE__*/_react["default"].createElement(PubDate, null, pubDate))))), /*#__PURE__*/_react["default"].createElement(Tags, null, tagsJSX));
164
+ }
165
+ }]);
166
+
167
+ return ListItem;
168
+ }(_react.PureComponent);
169
+
170
+ ListItem.defaultProps = {
171
+ tags: [],
172
+ link: {
173
+ to: '',
174
+ target: ''
175
+ }
176
+ };
177
+ ListItem.propTypes = {
178
+ title: _propTypes["default"].string.isRequired,
179
+ desc: _propTypes["default"].string.isRequired,
180
+ img: _propTypes["default"].shape({
181
+ src: _propTypes["default"].string.isRequired,
182
+ alt: _propTypes["default"].string
183
+ }).isRequired,
184
+ link: _propTypes["default"].shape({
185
+ to: _propTypes["default"].string.isRequired,
186
+ target: _propTypes["default"].string
187
+ }),
188
+ category: _propTypes["default"].string.isRequired,
189
+ pubDate: _propTypes["default"].string.isRequired,
190
+ tags: _propTypes["default"].arrayOf(_propTypes["default"].shape({
191
+ id: _propTypes["default"].string.isRequired,
192
+ name: _propTypes["default"].string.isRequired,
193
+ selected: _propTypes["default"].bool
194
+ }))
195
+ };
196
+ var _default = ListItem;
197
+ exports["default"] = _default;
@@ -0,0 +1,188 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = void 0;
9
+
10
+ var _date = require("@twreporter/core/lib/utils/date");
11
+
12
+ var _entityPath = _interopRequireDefault(require("@twreporter/core/lib/constants/entity-path"));
13
+
14
+ var _isFetchingWrapper = _interopRequireDefault(require("../../is-fetching-wrapper"));
15
+
16
+ var _fontWeight = require("@twreporter/core/lib/constants/font-weight");
17
+
18
+ var _listItem = _interopRequireDefault(require("./list-item"));
19
+
20
+ var _mockupSpec = _interopRequireDefault(require("../constants/mockup-spec"));
21
+
22
+ var _mediaQuery = _interopRequireDefault(require("@twreporter/core/lib/utils/media-query"));
23
+
24
+ var _propTypes = _interopRequireDefault(require("prop-types"));
25
+
26
+ var _react = _interopRequireWildcard(require("react"));
27
+
28
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
29
+
30
+ var _forEach = _interopRequireDefault(require("lodash/forEach"));
31
+
32
+ var _get = _interopRequireDefault(require("lodash/get"));
33
+
34
+ var _map = _interopRequireDefault(require("lodash/map"));
35
+
36
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4;
37
+
38
+ 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); }
39
+
40
+ 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; }
41
+
42
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
43
+
44
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
45
+
46
+ 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); } }
47
+
48
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
49
+
50
+ 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); }
51
+
52
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
53
+
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); }; }
55
+
56
+ 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); }
57
+
58
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
59
+
60
+ 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; } }
61
+
62
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
63
+
64
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
65
+
66
+ var _ = {
67
+ forEach: _forEach["default"],
68
+ get: _get["default"],
69
+ map: _map["default"]
70
+ };
71
+
72
+ var Container = /*#__PURE__*/_styledComponents["default"].div.withConfig({
73
+ displayName: "list__Container",
74
+ componentId: "sc-1olquk4-0"
75
+ })(["margin:45px auto 0 auto;"]);
76
+
77
+ var Header = /*#__PURE__*/_styledComponents["default"].div.withConfig({
78
+ displayName: "list__Header",
79
+ componentId: "sc-1olquk4-1"
80
+ })(["font-size:36px;font-weight:", ";color:#404040;margin:0 auto 45px auto;text-align:center;", ""], _fontWeight.sourceHanSansTC.bold, _mediaQuery["default"].mobileOnly(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n width: ", "%;\n text-align: left;\n "])), _mockupSpec["default"].mobile.cardWidth / _mockupSpec["default"].mobile.maxWidth * 100));
81
+
82
+ var FlexItems = /*#__PURE__*/_styledComponents["default"].div.withConfig({
83
+ displayName: "list__FlexItems",
84
+ componentId: "sc-1olquk4-2"
85
+ })(["width:", "px;margin:0 auto;display:flex;justify-content:flex-start;align-items:flex-start;flex-wrap:wrap;> div:nth-child(odd){margin-right:", "px;}", " ", " ", ""], _mockupSpec["default"].hd.maxWidth, _mockupSpec["default"].marginBetweenItems, _mediaQuery["default"].desktopOnly(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n width: ", "px;\n "])), _mockupSpec["default"].desktop.maxWidth), _mediaQuery["default"].tabletOnly(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n width: ", "px;\n "])), _mockupSpec["default"].tablet.maxWidth), _mediaQuery["default"].mobileOnly(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n width: 100%;\n > div:nth-child(odd) {\n margin-right: 0;\n }\n justify-content: center;\n "]))));
86
+
87
+ var Items = (0, _isFetchingWrapper["default"])(FlexItems);
88
+
89
+ var List = /*#__PURE__*/function (_PureComponent) {
90
+ _inherits(List, _PureComponent);
91
+
92
+ var _super = _createSuper(List);
93
+
94
+ function List() {
95
+ _classCallCheck(this, List);
96
+
97
+ return _super.apply(this, arguments);
98
+ }
99
+
100
+ _createClass(List, [{
101
+ key: "render",
102
+ value: function render() {
103
+ var _this$props = this.props,
104
+ data = _this$props.data,
105
+ catName = _this$props.catName,
106
+ tagName = _this$props.tagName,
107
+ isFetching = _this$props.isFetching,
108
+ showSpinner = _this$props.showSpinner;
109
+ var listJSX = [];
110
+
111
+ _.forEach(data, function (item) {
112
+ var style = _.get(item, 'style');
113
+
114
+ var slug = _.get(item, 'slug'); // TODO extract interactive as to a const file
115
+
116
+
117
+ var to = style === 'interactive' ? _entityPath["default"].interactiveArticle + slug : _entityPath["default"].article + slug;
118
+
119
+ var tags = _.map(_.get(item, 'tags'), function (tag) {
120
+ if (_.get(tag, 'name') === tagName) {
121
+ return {
122
+ id: tag.id,
123
+ name: tag.name,
124
+ selected: true
125
+ };
126
+ }
127
+
128
+ return {
129
+ id: _.get(tag, 'id'),
130
+ name: _.get(tag, 'name', '')
131
+ };
132
+ });
133
+
134
+ listJSX.push( /*#__PURE__*/_react["default"].createElement(_listItem["default"], {
135
+ key: _.get(item, 'id'),
136
+ title: _.get(item, 'title', ''),
137
+ desc: _.get(item, 'og_description', ''),
138
+ img: {
139
+ alt: _.get(item, 'hero_image.description'),
140
+ // Displaying `hero_image` is a default setting for listing.
141
+ // In cases which do not have `hero_image`, display `og_image` as fallback.
142
+ src: _.get(item, 'hero_image.resized_targets.mobile.url') || _.get(item, 'og_image.resized_targets.mobile.url')
143
+ },
144
+ category: _.get(item, 'categories.0.name', ''),
145
+ pubDate: (0, _date.date2yyyymmdd)(_.get(item, 'published_date', ''), '.'),
146
+ tags: tags,
147
+ link: {
148
+ to: to,
149
+ target: style === 'interactive' ? '_blank' : ''
150
+ }
151
+ }));
152
+ });
153
+
154
+ return /*#__PURE__*/_react["default"].createElement(Container, null, /*#__PURE__*/_react["default"].createElement(Header, null, catName || (tagName ? "#".concat(tagName) : '')), /*#__PURE__*/_react["default"].createElement(Items, {
155
+ isFetching: isFetching,
156
+ showSpinner: showSpinner
157
+ }, listJSX));
158
+ }
159
+ }]);
160
+
161
+ return List;
162
+ }(_react.PureComponent);
163
+
164
+ List.defaultProps = {
165
+ data: [],
166
+ catName: '',
167
+ tagName: '',
168
+ isFetching: false,
169
+ showSpinner: false
170
+ };
171
+ List.propTypes = {
172
+ data: _propTypes["default"].arrayOf(_propTypes["default"].shape({
173
+ id: _propTypes["default"].string.isRequired,
174
+ title: _propTypes["default"].string.isRequired,
175
+ og_description: _propTypes["default"].string.isRequired,
176
+ hero_image: _propTypes["default"].object.isRequired,
177
+ categories: _propTypes["default"].array,
178
+ published_date: _propTypes["default"].string.isRequired,
179
+ tags: _propTypes["default"].array,
180
+ style: _propTypes["default"].string
181
+ })),
182
+ tagName: _propTypes["default"].string,
183
+ catName: _propTypes["default"].string,
184
+ isFetching: _propTypes["default"].bool,
185
+ showSpinner: _propTypes["default"].bool
186
+ };
187
+ var _default = List;
188
+ exports["default"] = _default;
@@ -0,0 +1,215 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+
8
+ var _topics = require("../../constants/topics");
9
+
10
+ var _section = require("./section");
11
+
12
+ var _isFetchingWrapper = _interopRequireDefault(require("../../../is-fetching-wrapper"));
13
+
14
+ var _fontWeight = require("@twreporter/core/lib/constants/font-weight");
15
+
16
+ var _pageContent = _interopRequireDefault(require("./page-content"));
17
+
18
+ var _postItem = _interopRequireDefault(require("./post-item"));
19
+
20
+ var _posts = _interopRequireDefault(require("./posts"));
21
+
22
+ var _propTypes = _interopRequireDefault(require("prop-types"));
23
+
24
+ var _react = _interopRequireWildcard(require("react"));
25
+
26
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
27
+
28
+ var _topicItem = _interopRequireDefault(require("./topic-item"));
29
+
30
+ var _get = _interopRequireDefault(require("lodash/get"));
31
+
32
+ var _map = _interopRequireDefault(require("lodash/map"));
33
+
34
+ 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); }
35
+
36
+ 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; }
37
+
38
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
39
+
40
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
41
+
42
+ 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
+
46
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
47
+
48
+ 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); }
49
+
50
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
51
+
52
+ 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
+ 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
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
57
+
58
+ 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
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
61
+
62
+ var _ = {
63
+ get: _get["default"],
64
+ map: _map["default"]
65
+ };
66
+
67
+ var NoData = /*#__PURE__*/_styledComponents["default"].div.withConfig({
68
+ displayName: "topics__NoData",
69
+ componentId: "sc-1n6udj1-0"
70
+ })(["width:100%;font-size:16px;color:#4a4949;font-weight:", ";text-align:center;"], _fontWeight.sourceHanSansTC.normal);
71
+
72
+ var Topics = /*#__PURE__*/function (_Component) {
73
+ _inherits(Topics, _Component);
74
+
75
+ var _super = _createSuper(Topics);
76
+
77
+ function Topics() {
78
+ _classCallCheck(this, Topics);
79
+
80
+ return _super.apply(this, arguments);
81
+ }
82
+
83
+ _createClass(Topics, [{
84
+ key: "_buildRelatedPosts",
85
+ value: function _buildRelatedPosts(posts) {
86
+ var _buildPostJSX = function _buildPostJSX(post) {
87
+ if (_typeof(post) !== 'object' || post === null) {
88
+ return null;
89
+ }
90
+
91
+ var id = post.id,
92
+ linkTarget = post.linkTarget,
93
+ linkTo = post.linkTo,
94
+ title = post.title,
95
+ imgUrl = post.imgUrl;
96
+ return /*#__PURE__*/_react["default"].createElement(_postItem["default"], {
97
+ key: "post-".concat(id),
98
+ title: title,
99
+ imgUrl: imgUrl,
100
+ linkTo: linkTo,
101
+ linkTarget: linkTarget
102
+ });
103
+ };
104
+
105
+ return _.map(posts, _buildPostJSX);
106
+ }
107
+ }, {
108
+ key: "_buildTopicBoxes",
109
+ value: function _buildTopicBoxes(topics) {
110
+ var _buildTopicBox = function _buildTopicBox(item, index) {
111
+ var id = item.id,
112
+ linkTo = item.linkTo,
113
+ title = item.title,
114
+ updatedAt = item.updatedAt,
115
+ description = item.description,
116
+ imgUrl = item.imgUrl,
117
+ imgAlt = item.imgAlt;
118
+ return /*#__PURE__*/_react["default"].createElement(_topicItem["default"], {
119
+ key: "topic-".concat(id),
120
+ title: title,
121
+ updatedAt: updatedAt,
122
+ description: description,
123
+ imgUrl: imgUrl,
124
+ imgAlt: imgAlt,
125
+ isTop: index === 0,
126
+ linkTo: linkTo
127
+ });
128
+ };
129
+
130
+ return _.map(topics, _buildTopicBox);
131
+ }
132
+ }, {
133
+ key: "render",
134
+ value: function render() {
135
+ var _this$props = this.props,
136
+ topics = _this$props.topics,
137
+ currentPage = _this$props.currentPage,
138
+ isFetching = _this$props.isFetching,
139
+ showSpinner = _this$props.showSpinner;
140
+
141
+ if (!isFetching && _.get(topics, 'length', 0) <= 0) {
142
+ return /*#__PURE__*/_react["default"].createElement(_pageContent["default"], null, /*#__PURE__*/_react["default"].createElement(NoData, null, "\u7121\u8CC7\u6599"));
143
+ }
144
+
145
+ var isFirstPage = currentPage === 1;
146
+ /* Build PageContent */
147
+
148
+ var topicsJSX = this._buildTopicBoxes(topics);
149
+
150
+ var topTopicJSX = null;
151
+ var listedTopicsJSX = null;
152
+ var topRelatedPosts = null;
153
+ var topTopicName = null;
154
+ var topicUrl = null;
155
+ var topSectionJSX = null;
156
+
157
+ if (isFirstPage && !isFetching) {
158
+ topTopicJSX = topicsJSX[0];
159
+ listedTopicsJSX = topicsJSX.slice(1);
160
+ topRelatedPosts = _.get(topics, [0, 'relateds'], []).slice(-3);
161
+ /* take last 3 posts from the end */
162
+
163
+ topTopicName = _.get(topics, [0, 'topic_name'], '');
164
+ topicUrl = _.get(topics, [0, 'linkTo'], '');
165
+ topSectionJSX = [/*#__PURE__*/_react["default"].createElement(_section.SectionTitle, {
166
+ key: "top-title"
167
+ }, _topics.TEXT.SECTION_TITLE_FEATURED), /*#__PURE__*/_react["default"].createElement(_section.TopSectionContent, {
168
+ key: "top-section",
169
+ topicName: topTopicName,
170
+ topicUrl: topicUrl
171
+ }, topTopicJSX, /*#__PURE__*/_react["default"].createElement(_posts["default"], null, this._buildRelatedPosts(topRelatedPosts)))];
172
+ } else {
173
+ listedTopicsJSX = topicsJSX;
174
+ }
175
+
176
+ var WrappedListSectionContent = (0, _isFetchingWrapper["default"])( /*#__PURE__*/_react["default"].createElement(_section.ListSectionContent, null, listedTopicsJSX));
177
+ return /*#__PURE__*/_react["default"].createElement(_pageContent["default"], null, topSectionJSX, isFetching && isFirstPage ? null : /*#__PURE__*/_react["default"].createElement(_section.SectionTitle, null, _topics.TEXT.SECTION_TITLE_OTHERS), /*#__PURE__*/_react["default"].createElement(WrappedListSectionContent, {
178
+ isFetching: isFetching,
179
+ showSpinner: showSpinner
180
+ }));
181
+ }
182
+ }]);
183
+
184
+ return Topics;
185
+ }(_react.Component);
186
+
187
+ Topics.propTypes = {
188
+ topics: _propTypes["default"].arrayOf(_propTypes["default"].shape({
189
+ id: _propTypes["default"].string.isRequired,
190
+ linkTo: _propTypes["default"].string.isRequired,
191
+ title: _propTypes["default"].string.isRequired,
192
+ topic_name: _propTypes["default"].string.isRequired,
193
+ updatedAt: _propTypes["default"].string.isRequired,
194
+ description: _propTypes["default"].string.isRequired,
195
+ imgUrl: _propTypes["default"].string.isRequired,
196
+ imgAlt: _propTypes["default"].string.isRequired,
197
+ relateds: _propTypes["default"].arrayOf(_propTypes["default"].shape({
198
+ id: _propTypes["default"].string.isRequired,
199
+ title: _propTypes["default"].string.isRequired,
200
+ imgUrl: _propTypes["default"].string.isRequired,
201
+ linkTarget: _propTypes["default"].string,
202
+ linkTo: _propTypes["default"].string.isRequired
203
+ }))
204
+ })),
205
+ currentPage: _propTypes["default"].number.isRequired,
206
+ isFetching: _propTypes["default"].bool.isRequired,
207
+ showSpinner: _propTypes["default"].bool
208
+ };
209
+ Topics.defaultProps = {
210
+ topics: [],
211
+ currentPage: 1,
212
+ showSpinner: false
213
+ };
214
+ var _default = Topics;
215
+ exports["default"] = _default;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+
8
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
9
+
10
+ var _predefinedCss = require("../../constants/predefined-css");
11
+
12
+ var _mediaQuery = _interopRequireDefault(require("@twreporter/core/lib/utils/media-query"));
13
+
14
+ var _templateObject, _templateObject2;
15
+
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
17
+
18
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
19
+
20
+ var styles = {
21
+ contentWidth: {
22
+ min: 300,
23
+ // px
24
+ mobile: 95,
25
+ // %
26
+ tablet: 700,
27
+ // px
28
+ desktop: 870 // px
29
+
30
+ },
31
+ titlePadding: 0,
32
+ titleMargin: {
33
+ mobile: [0, 0, 19, 0],
34
+ tablet: [0, 0, 33, 0]
35
+ }
36
+ };
37
+
38
+ var PageContent = /*#__PURE__*/_styledComponents["default"].div.withConfig({
39
+ displayName: "page-content__PageContent",
40
+ componentId: "sc-1x8tj4h-0"
41
+ })(["min-width:", "px;width:", "%;", " ", " margin:0 auto;", ""], styles.contentWidth.min, styles.contentWidth.mobile, _mediaQuery["default"].tabletOnly(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n width: ", "px;\n "])), styles.contentWidth.tablet), _mediaQuery["default"].desktopAndAbove(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n width: ", "px;\n "])), styles.contentWidth.desktop), _predefinedCss.resetLinkStyle);
42
+
43
+ var _default = PageContent;
44
+ exports["default"] = _default;